package com.njcn.system.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.web.constant.ValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;

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

@Data
public class DicParam {

    @ApiModelProperty("节点")
    @NotBlank(message = ValidMessage.PID_NOT_BLANK)
    private String pid;

    @ApiModelProperty("名称")
    @NotBlank(message = ValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.DIC_REGEX, message = ValidMessage.NAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("编号")
    @NotBlank(message = ValidMessage.CODE_NOT_BLANK)
    private String code;

    @ApiModelProperty("排序")
    @NotNull(message = ValidMessage.SORT_NOT_NULL)
    @Range(min = 0, max = 999, message = ValidMessage.PARAM_FORMAT_ERROR)
    private Integer sort;

    @ApiModelProperty("描述")
    private String remark;


    /**
     * 更新操作实体
     * 需要填写的参数：id
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends DicParam {

        @ApiModelProperty("Id")
        @NotBlank(message = ValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
        private String id;
    }
}
