package com.njcn.gather.user.user.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.user.pojo.constant.UserValidMessage;
import com.njcn.web.pojo.param.BaseParam;
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.Null;
import javax.validation.constraints.Pattern;

/**
 * @author caozehui
 * @data 2024/11/12
 */
@Data
public class SysFunctionParam {
    @ApiModelProperty("父节点")
    @NotBlank(message = UserValidMessage.PID_NOT_BLANK)
    private String pid;

    @ApiModelProperty("名称")
    @NotBlank(message = UserValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.FUNCTION_NAME_REGEX, message = UserValidMessage.FUNCTION_NAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("编码")
    @NotBlank(message = UserValidMessage.CODE_NOT_BLANK)
    @Pattern(regexp = PatternRegex.FUNCTION_CODE_REGEX, message = UserValidMessage.FUNCTION_CODE_FORMAT_ERROR)
    private String code;

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

    @ApiModelProperty("组件地址")
    private String component;

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

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

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

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

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {
        @ApiModelProperty("名称")
        @Pattern(regexp = PatternRegex.FUNCTION_NAME_REGEX, message = UserValidMessage.FUNCTION_NAME_FORMAT_ERROR)
        private String name;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends SysFunctionParam {

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