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;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/1/17 10:25
 */
@Data
public class FunctionParam {

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

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

    @ApiModelProperty("资源标识")
    @NotBlank(message = UserValidMessage.CODE_NOT_BLANK)
    private String code;

    @ApiModelProperty("路径")
    @NotBlank(message = UserValidMessage.PATH_NOT_BLANK)
    @Pattern(regexp = PatternRegex.FUNCTION_URL, message = UserValidMessage.PATH_FORMAT_ERROR)
    private String path;

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

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

    @ApiModelProperty("资源类型")
    @NotNull(message = UserValidMessage.TYPE_NOT_BLANK)
    @Range(min = 0, max = 4, message = UserValidMessage.PARAM_FORMAT_ERROR)
    private Integer type;

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

    @ApiModelProperty("路由名称")
    private String routeName;

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

        @ApiModelProperty("资源Id")
        @NotBlank(message = UserValidMessage.FUNCTION_ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = UserValidMessage.FUNCTION_ID_FORMAT_ERROR)
        private String id;
    }


}
