package cn.stylefeng.team.meta.modular.pojo.request;

import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.team.meta.api.entity.MetaField;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
public class MetaFieldRequest extends BaseRequest {

    @ChineseDescription("字段id")
    private Long fieldId;

    @NotNull(message = "所属业务分类id不能为空", groups = {add.class, edit.class})
    @ChineseDescription("所属业务分类id")
    private Long businessCategoryId;

    @NotNull(message = "所属业务id不能为空", groups = {add.class, edit.class, getMainMetaFieldList.class})
    @ChineseDescription("所属业务id")
    private Long businessId;

    @ChineseDescription("所属模型id")
    private Long metaModelId;

    @ChineseDescription("所属模型定义id")
    @NotNull(message = "所属模型定义id不能为空", groups = {getFieldList.class, saveOrUpdateFieldList.class, updateVirtualField.class})
    private Long metaDefinitionId;

    @ChineseDescription("属性编码(下划线命名)，例如：user_account")
    private String fieldCode;

    @ChineseDescription(
            "字段类型：10-可变字符串，11-超长字符串，12-固定长度字符串，20-整型，21-长整型，30-浮点数，50-日期时间，51-日期，52-时间，60-对象，61-列表（集合）")
    private Integer fieldType;

    @ChineseDescription("长度")
    private Integer fieldLength;

    @ChineseDescription("小数位数")
    private Integer decimalLength;

    @ChineseDescription("非空标识：Y-非空，N-可为空")
    private String notEmptyFlag;

    @ChineseDescription("主键标识：Y-主键，N-非主键")
    private String keyFlag;

    @ChineseDescription("默认值")
    private String defaultValue;

    @ChineseDescription("是否是真实字段：Y-真实，N-不真实")
    private String realFlag;

    @ChineseDescription("描述")
    private String description;

    @ChineseDescription("模型字段列表")
    @NotEmpty(message = "模型字段列表不能为空", groups = {saveOrUpdateFieldList.class})
    private List<MetaField> metaFieldList;

    @ChineseDescription("模型定义id集合")
    @NotEmpty(message = "模型定义id集合不能为空", groups = {fieldCollection.class})
    private List<Long> metaDefinitionIdList;

    @ChineseDescription("字段查询类型：1-查询实际字段，2-查询虚拟字段")
    private Integer fieldQueryType;

    public @interface getFieldList {
    }

    public @interface saveOrUpdateFieldList {
    }

    public @interface fieldCollection {
    }

    public @interface getMainMetaFieldList {

    }

    public @interface updateVirtualField {

    }

}
