package com.backendsys.modules.system.entity;

import com.backendsys.entity.validator.Phone;
import com.backendsys.entity.validator.RangeArray;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.util.LinkedHashMap;
import java.util.List;

@Data
public class SysUserDTO {
  public static interface Detail{}
  public static interface Login{}
  public static interface LoginWithPhone{}
  public static interface ForgotPassword{}
  public static interface Create{}
  public static interface Register{}
  public static interface Update{}
  public static interface UpdatePassword{}
  public static interface ResetPassword{}
  public static interface Audit{}
  public static interface Delete{}
  public static interface Kick{}

  /**
   * sys_user
   */
  private Long id;
  @NotEmpty(message="用户名不能为空", groups = { Login.class, Create.class, Register.class })
  @Size(min = 2, max = 20, message = "用户名长度在 {min}-{max} 字符", groups = { Login.class, Create.class, Register.class })
  private String username;
  @NotEmpty(message="密码不能为空", groups = { Login.class, Create.class, Register.class, UpdatePassword.class, ForgotPassword.class })
  private String password;
  private Boolean is_remember;
  @NotEmpty(message="原密码不能为空", groups = { UpdatePassword.class })
  private String old_password;
  @NotEmpty(message="验证码不能为空", groups = { Login.class, Register.class })
  private String captcha;

  /**
   * sys_user_info
   */
  @NotNull(message="user_id 不能为空", groups = { ResetPassword.class, Detail.class, Kick.class, Audit.class })
  private Long user_id;
  private List<Long> user_ids;

  

  private String role_ids;

  @Size(min = 2, max = 20, message = "昵称长度在 {min}-{max} 字符", groups = { Create.class, Update.class })
  private String nickname;
  @Email(message="邮箱格式不正确", groups = { Create.class, Update.class })
  private String email;

  @NotEmpty(message="手机号码不能为空", groups = { Register.class, LoginWithPhone.class, ForgotPassword.class })
  @Phone(message="手机号码格式不正确", groups = { Create.class, Update.class, LoginWithPhone.class, ForgotPassword.class })
  @Size(min = 9, max = 20, message = "手机号码长度在 {min}-{max} 字符", groups = { Create.class, Update.class, LoginWithPhone.class, ForgotPassword.class })
  private String phone;

  @NotNull(message="验证码不能为空", groups = { Register.class, LoginWithPhone.class, ForgotPassword.class })
  @Min(value = 100000, message = "验证码长度是 6 位字符", groups = { Register.class })
  @Max(value = 999999, message = "验证码长度是 6 位字符", groups = { Register.class })
  private Integer phone_valid_code;

  @NotNull(message="区号/国家码不能为空", groups = { Register.class, LoginWithPhone.class, ForgotPassword.class })
  @Max(value = 999999, message = "区号/国家码长度不超过 {value} 字符", groups = { Register.class })
  private Integer phone_area_code;

  @RangeArray(message="性别取值有误，范围应是(1男, 2女, 3保密)", value = {"1", "2", "3"}, groups = { Create.class })
  private Integer gender;
  @Size(max = 1000, message = "头像路径长度不超过 {max} 字符", groups = { Create.class, Update.class })
  private String avatar;
  @RangeArray(message="是否管理员取值有误，范围应是(-1否, 1是)", value = {"-1", "1"}, groups = { Create.class, Update.class })
  private Integer is_super;
  @RangeArray(message="状态取值有误，范围应是(-1禁用, 1启用)", value = {"-1", "1"}, groups = { Create.class, Update.class })
  private Integer status;

  @RangeArray(message="审核状态取值有误，范围应是(-1审核拒绝, 1待审核, 2审核通过)", value = {"-1", "1", "2"}, groups = { Audit.class })
  private Integer audit_status;
  @Size(max = 1000, message = "审核备注长度不超过 {max} 字符", groups = { Audit.class })
  private String audit_note;

  private String last_login_ip;
  private String last_login_uuid;
  private String last_login_time;
  private String create_time;
  private String update_time;
  private Integer del_flag;


  private Float point_balance;

  @Size(max = 50, message = "密钥长度不超过 {max} 字符", groups = { Register.class })
//  @NotEmpty(message="密钥不能为空", groups = { Register.class })
  private String invite_code;

  @NotEmpty(message="角色不能为空", groups = { Create.class })
  private List<Long> role_id;
  private List<LinkedHashMap<String, Object>> roles;
  private List<String> modules;

}
