package com.njcn.product.cnuser.user.pojo.param;

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

/**
 * @author caozehui
 * @data 2024/11/11
 */
@Data
public class SysRoleParam {


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

    @ApiModelProperty("编码")
    @NotNull(message = UserValidMessage.CODE_NOT_BLANK)
    private String code;

    /**
     * 角色类型 0:超级管理员；1:管理员；2:普通用户
     */
    @ApiModelProperty("类型")
    @Range(min = 0, max = 2, message = UserValidMessage.PARAM_FORMAT_ERROR)
    private Integer type;

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

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

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

    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {
        @ApiModelProperty("名称")
        private String name;

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

        @ApiModelProperty("类型")
        private Integer type;
    }

    /**
     * 角色绑定菜单（资源）参数
     */
    @Data
    public static class RoleBindFunction {
        @ApiModelProperty("角色id")
        @NotBlank(message = UserValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = UserValidMessage.ID_FORMAT_ERROR)
        private String roleId;

        @ApiModelProperty("菜单ids")
        private List<String> functionIds;
    }
}
