package com.njcn.gather.system.dictionary.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2021年2月7日 15:49
 */
@Data
public class DictDataParam {

    private static final String DICT_DATA_NAME_REGEX = "^[\\u4e00-\\u9fa5\\w\\-\\s\\.\\/\\\\%℃、。《》（）；]{1,64}$";

    @ApiModelProperty("字典类型id")
    @NotBlank(message = SystemValidMessage.DICT_TYPE_ID_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DICT_TYPE_ID_FORMAT_ERROR)
    private String typeId;

    @ApiModelProperty("名称")
    @NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = DICT_DATA_NAME_REGEX, message = SystemValidMessage.DICT_DATA_NAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("编码")
    @NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
    @Pattern(regexp = PatternRegex.DICT_DATA_CODE_REGEX, message = SystemValidMessage.DICT_DATA_CODE_FORMAT_ERROR)
    private String code;

    @ApiModelProperty("排序")
    @NotNull(message = SystemValidMessage.SORT_NOT_NULL)
    @Min(value = 1, message = SystemValidMessage.SORT_FORMAT_ERROR)
    @Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
    private Integer sort;

    @ApiModelProperty("事件等级：0-普通；1-中等；2-严重(默认为0)")
    private Integer level;

    @ApiModelProperty("与高级算法内部Id描述对应")
    private Integer algoDescribe;

    // todo 待定
    @ApiModelProperty("字典值")
    private String value;

    /**
     * 是否开启使用Value值：0-关闭；1-开启(默认为0)
     */
    @ApiModelProperty("是否开启使用value值")
    private Integer openValue;

    /**
     * 更新操作实体
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends DictDataParam {

        /**
         * 表id
         */
        @ApiModelProperty("id")
        @NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
        private String id;
    }

    /**
     * 根据字典类型id分页查询字典数据
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {

        @ApiModelProperty("字典类型id")
        @NotBlank(message = SystemValidMessage.DICT_TYPE_ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DICT_TYPE_ID_FORMAT_ERROR)
        private String typeId;

        @ApiModelProperty("名称")
        private String name;

        @ApiModelProperty("编码")
        private String code;
    }

}
