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 javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.util.List;

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

    @ApiModelProperty("用户名(别名)")
    @NotBlank(message = UserValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.USERNAME_REGEX, message = UserValidMessage.NAME_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("角色ids")
    private List<String> roleIds;

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class SysUserAddParam extends SysUserParam {

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

        @ApiModelProperty("密码")
        @NotBlank(message = UserValidMessage.PASSWORD_NOT_BLANK)
        @Pattern(regexp = PatternRegex.PASSWORD_REGEX, message = UserValidMessage.PASSWORD_FORMAT_ERROR)
        private String password;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class SysUserUpdateParam extends SysUserParam {

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

    }

    @Data
    public static class SysUserUpdatePasswordParam {
        @ApiModelProperty("用户Id")
        @NotBlank(message = UserValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = UserValidMessage.ID_FORMAT_ERROR)
        private String id;

        @ApiModelProperty("旧密码")
        @NotBlank(message = UserValidMessage.OLD_PASSWORD_NOT_BLANK)
        @Pattern(regexp = PatternRegex.PASSWORD_REGEX, message = UserValidMessage.PASSWORD_FORMAT_ERROR)
        private String oldPassword;

        @ApiModelProperty("新密码")
        @NotBlank(message = UserValidMessage.NEW_PASSWORD_NOT_BLANK)
        @Pattern(regexp = PatternRegex.PASSWORD_REGEX, message = UserValidMessage.PASSWORD_FORMAT_ERROR)
        private String newPassword;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class SysUserQueryParam extends BaseParam {
        @ApiModelProperty("用户名(别名)")
        private String name;

    }

    @Data
    public static class LoginParam {
        @ApiModelProperty("登录名")
        @NotBlank(message = UserValidMessage.LOGIN_NAME_NOT_BLANK)
        @Pattern(regexp = PatternRegex.LOGIN_NAME_REGEX, message = UserValidMessage.LOGIN_NAME_FORMAT_ERROR)
        private String username;

        @ApiModelProperty("密码")
        @NotBlank(message = UserValidMessage.PASSWORD_NOT_BLANK)
        @Pattern(regexp = PatternRegex.PASSWORD_REGEX, message = UserValidMessage.PASSWORD_FORMAT_ERROR)
        private String password;
    }
}
