package cn.stylefeng.team.meta.api.entity;

import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseBusinessEntity;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.List;

@TableName("devops_meta_model")
@Data
@EqualsAndHashCode(callSuper = true)
public class MetaModel extends BaseBusinessEntity {

    @TableId(value = "meta_model_id", type = IdType.ASSIGN_ID)
    @ChineseDescription("模型id")
    private Long metaModelId;

    @TableField("business_category_id")
    @ChineseDescription("所属业务分类id")
    private Long businessCategoryId;

    @TableField("business_id")
    @ChineseDescription("所属业务id")
    private Long businessId;

    @TableField("meta_model_name")
    @ChineseDescription("模型名称")
    private String metaModelName;

    @TableField("meta_model_code")
    @ChineseDescription("模型编码")
    private String metaModelCode;

    @TableField("system_code")
    @ChineseDescription("系统编码，这里用十进制存储，但是展示的时候是3位36进制的字符串，例如展示的时候可能显示：#AZZZ")
    private Integer systemCode;

    @TableField("system_code_show")
    @ChineseDescription("系统编码，用于展示")
    private String systemCodeShow;

    @TableField("current_version")
    @ChineseDescription("当前版本号，默认1.0")
    private String currentVersion;

    @TableField("current_definition_id")
    @ChineseDescription("当前的模型定义id")
    private Long currentDefinitionId;

    @TableField("description")
    @ChineseDescription("项目描述")
    private String description;

    @TableField("meta_model_type")
    @ChineseDescription("模型类型：1-新建表，2-外部表")
    private Integer metaModelType;

    @TableField("link_model_id")
    @ChineseDescription("关联的外部模型的id")
    private Long linkModelId;

    @TableField("main_flag")
    @ChineseDescription("是否是主表：Y-是，N-否")
    private String mainFlag;

    @TableField(value = "sub_table_field_code", insertStrategy = FieldStrategy.ALWAYS, updateStrategy = FieldStrategy.ALWAYS)
    @ChineseDescription("子表中关联主表主键id的字段编码，例如子表中的user_id属性")
    private String subTableFieldCode;

    @TableField("sub_table_type")
    @ChineseDescription("子表类型：1-一对一，2-一对多")
    private Integer subTableType;

    @TableField("fld_sort")
    @ChineseDescription("排序")
    private BigDecimal fldSort;

    @TableField(value = "tenant_id", fill = FieldFill.INSERT)
    @ChineseDescription("租户id")
    private Long tenantId;

    @TableField(exist = false)
    @ChineseDescription("模型字段")
    private List<MetaField> metaFieldList;

    @TableField(exist = false)
    @ChineseDescription("数据库是否已经创建了该表")
    private Boolean tableCreateFlag = false;

}
