package com.njcn.product.auth.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.product.auth.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.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2021/12/29 14:56
 */
@Data
public class UserParam {

    @ApiModelProperty("用户名")
    @NotBlank(message = UserValidMessage.USERNAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.USERNAME_REGEX, message = UserValidMessage.USERNAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("部门id")
    private String deptId;

    @ApiModelProperty("电话号码")
    @Pattern(regexp = PatternRegex.PHONE_REGEX_OR_NULL, message = UserValidMessage.PHONE_FORMAT_ERROR)
    private String phone;

    @ApiModelProperty("邮箱")
    @Pattern(regexp = PatternRegex.EMAIL_REGEX_OR_NULL, message = UserValidMessage.EMAIL_FORMAT_ERROR)
    private String email;

    @ApiModelProperty("起始IP")
    @NotBlank(message = UserValidMessage.LIMIT_IP_START_NOT_BLANK)
    @Pattern(regexp = PatternRegex.IP_REGEX, message = UserValidMessage.LIMIT_IP_START_FORMAT_ERROR)
    private String limitIpStart;

    @ApiModelProperty("结束IP")
    @NotBlank(message =  UserValidMessage.LIMIT_IP_END_NOT_BLANK)
    @Pattern(regexp = PatternRegex.IP_REGEX, message = UserValidMessage.LIMIT_IP_END_FORMAT_ERROR)
    private String limitIpEnd;

    @ApiModelProperty("时间段")
    @NotBlank(message = UserValidMessage.LIMIT_TIME_NOT_BLANK)
    private String limitTime;

    @ApiModelProperty("用户类型")
    @NotNull(message = UserValidMessage.CASUAL_USER_NOT_BLANK)
    @Range(min = 0, max = 1, message = UserValidMessage.PARAM_FORMAT_ERROR)
    private Integer casualUser;

    @ApiModelProperty("用户权限类型")
    @NotNull(message = UserValidMessage.CASUAL_USER_NOT_BLANK)
    @Range(min = 0, max = 2, message = UserValidMessage.PARAM_FORMAT_ERROR)
    private Integer type;

    @ApiModelProperty("短信通知")
    @NotNull(message = UserValidMessage.SMS_NOTICE_NOT_BLANK)
    @Range(min = 0, max = 1, message = UserValidMessage.PARAM_FORMAT_ERROR)
    private Integer smsNotice;

    @ApiModelProperty("邮件通知")
    @NotNull(message = UserValidMessage.EMAIL_NOTICE_NOT_BLANK)
    @Range(min = 0, max = 1, message = UserValidMessage.PARAM_FORMAT_ERROR)
    private Integer emailNotice;

    @ApiModelProperty("角色")
    @NotEmpty(message = UserValidMessage.ROLE_NOT_BLANK)
    private List<String> role;

    @ApiModelProperty("手机识别码")
    private String devCode;

    @ApiModelProperty("移动端用户头像")
    private String headSculpture;

    /**
     * 用户新增操作实体
     *
     * 需要填写的参数：登录名、密码
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UserAddParam extends UserParam {

        @ApiModelProperty("登录名")
        @NotBlank(message = UserValidMessage.LOGIN_NAME_NOT_BLANK)
        @Pattern(regexp = PatternRegex.LOGIN_NAME_REGEX, message = UserValidMessage.LOGIN_NAME_FORMAT_ERROR)
        private String loginName;

        @ApiModelProperty("用户表Id")
        @NotNull(message = UserValidMessage.ID_NOT_BLANK)
        private String id;
    }


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

        @ApiModelProperty("用户表Id")
        @NotBlank(message = UserValidMessage.ID_NOT_BLANK)
        private String id;
    }

    /**
     * 分页查询实体
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UserQueryParam extends BaseParam {

        @ApiModelProperty("用户类型")
        @NotNull(message = UserValidMessage.CASUAL_USER_NOT_BLANK)
        @Range(min = -1, max = 1, message = UserValidMessage.PARAM_FORMAT_ERROR)
        private Integer casualUser;
    }



}
