package com.njcn.user.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.user.pojo.constant.UserValidMessage;
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;
import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/1/19 9:16
 */
@Data
public class ComponentParam {

    @ApiModelProperty("资源id")
    private String functionId;

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

    @ApiModelProperty("功能组件名称")
    @NotBlank(message = UserValidMessage.USERNAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.FUNCTION_NAME, message = UserValidMessage.PATH_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("功能数组")
    private List<Integer> functionGroup;

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

    @ApiModelProperty("功能组件表示")
    @NotBlank(message = UserValidMessage.COMPONENT_CODE_NOT_BLANK)
    private String code;

    @ApiModelProperty("路径")
    private String path;

    @ApiModelProperty("图标标识")
    private String icon;

    @ApiModelProperty("图表")
    private String image;

    @ApiModelProperty("时间标识")
    private List<String> timeKeys;

    @ApiModelProperty("系统类型")
    @NotBlank(message = "系统类型不为空")
    private String systemType;

    @ApiModelProperty("组件类型")
    private String componentType;

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

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


}
