SysUser.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package com.ydtech.modules.admin.model;
  2. import cn.afterturn.easypoi.excel.annotation.Excel;
  3. import com.baomidou.mybatisplus.annotation.FieldFill;
  4. import com.baomidou.mybatisplus.annotation.TableField;
  5. import com.baomidou.mybatisplus.annotation.TableId;
  6. import com.baomidou.mybatisplus.annotation.TableName;
  7. import com.fasterxml.jackson.annotation.JsonFormat;
  8. import com.ydtech.core.page.HttpResult;
  9. import com.ydtech.exception.SystemException;
  10. import com.ydtech.modules.base.model.BaseEntity;
  11. import com.ydtech.security.utils.PasswordUtils;
  12. import io.swagger.annotations.ApiModel;
  13. import io.swagger.annotations.ApiModelProperty;
  14. import lombok.Data;
  15. import org.apache.ibatis.annotations.Select;
  16. import springfox.documentation.annotations.ApiIgnore;
  17. import javax.validation.constraints.NotBlank;
  18. import javax.validation.constraints.Size;
  19. import java.util.Date;
  20. /**
  21. * 用户
  22. *
  23. * @TableName sys_user
  24. */
  25. @TableName(value = "sys_user")
  26. @Data
  27. @ApiModel
  28. public class SysUser extends BaseEntity {
  29. @TableField(exist = false)
  30. private static final long serialVersionUID = 1L;
  31. /**
  32. * 编号
  33. */
  34. @ApiModelProperty(value = "用户ID")
  35. @TableId(value = "id")
  36. private String id;
  37. /**
  38. * 姓名
  39. */
  40. @Excel(name = "姓名")
  41. @ApiModelProperty(value = "姓名")
  42. @NotBlank(message = "姓名不能为空")
  43. @Size(min = 0, max = 30, message = "姓名长度不能超过30个字符")
  44. @TableField(value = "name")
  45. private String name;
  46. /**
  47. * 密码
  48. */
  49. @Excel(name = "密码")
  50. @ApiModelProperty(value = "密码")
  51. @TableField(value = "password")
  52. private String password;
  53. /**
  54. * 盐
  55. */
  56. @TableField(value = "salt")
  57. private String salt;
  58. /**
  59. * 手机号
  60. */
  61. @Excel(name = "手机号")
  62. @ApiModelProperty(value = "手机号")
  63. @NotBlank(message = "手机号不能为空")
  64. @TableField(value = "mobile")
  65. private String mobile;
  66. /**
  67. * 状态 1:正常 0:离司 2:新注册
  68. */
  69. @ApiModelProperty(value = "状态 1:正常 0:删除 2:新注册 3:审批不通过")
  70. @TableField(value = "status")
  71. private Integer status;
  72. /**
  73. * 机构ID
  74. */
  75. @ApiModelProperty(value = "机构ID")
  76. @NotBlank(message = "机构不能为空")
  77. @TableField(value = "dept_id")
  78. private String deptId;
  79. /**
  80. * 微信id
  81. */
  82. @TableField(value = "openid")
  83. private String openid;
  84. /**
  85. * 审批意见
  86. */
  87. @ApiModelProperty(value = "审批意见")
  88. @TableField(value = "approval_opinion")
  89. private String approvalOpinion;
  90. @ApiModelProperty(value = "身份证号")
  91. @TableField(value = "identity")
  92. private String identity;
  93. //------------------
  94. /**
  95. * 角色ID
  96. */
  97. @ApiModelProperty(value = "角色ID")
  98. @TableField(exist = false)
  99. private String roleId;
  100. /**
  101. * 角色名称
  102. */
  103. @Excel(name = "角色")
  104. @ApiModelProperty(value = "角色名称")
  105. @TableField(exist = false)
  106. private String roleName;
  107. /**
  108. * 机构名称
  109. */
  110. @ApiModelProperty(value = "机构名称")
  111. @TableField(exist = false)
  112. private String deptName;
  113. @TableField(exist = false)
  114. @Excel(name = "状态")
  115. private String excelStatus;
  116. @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
  117. @Excel(name = "离职时间")
  118. @TableField(value = "logout_time")
  119. private Date logoutTime;
  120. @TableField(exist = false)
  121. @Excel(name = "推荐人ID")
  122. private String referrerId;
  123. @TableField(exist = false)
  124. @Excel(name = "推荐人名称")
  125. private String referrerName;
  126. /**
  127. * 验证用户
  128. *
  129. * @author: lig
  130. * @date: 2023年07月03日 0003
  131. */
  132. @ApiIgnore
  133. public static void verifyUser(SysUser user){
  134. // 账号不存在、密码错误
  135. if (user == null) {
  136. throw new SystemException("账号不存在");
  137. }
  138. // 账号锁定
  139. if (user.getStatus() == 0) {
  140. throw new SystemException("账号已被锁定,请联系管理员");
  141. }
  142. // // 新注册用户需要审核
  143. // if (user.getStatus() == 2) {
  144. // throw new SystemException("新注册用户需要审核,请联系管理员");
  145. // }
  146. // 新注册用户审核不通过
  147. if (user.getStatus() == 3) {
  148. throw new SystemException("新注册用户审核不通过,请联系管理员");
  149. }
  150. }
  151. }