SysUser.java 4.2 KB

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