User.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright 2019-2020 Zheng Jie
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package me.zhengjie.dao.mybatis.entity;
  17. import com.baomidou.mybatisplus.annotation.TableField;
  18. import io.swagger.annotations.ApiModelProperty;
  19. import lombok.Getter;
  20. import lombok.Setter;
  21. import me.zhengjie.base.BaseEntity;
  22. import javax.persistence.*;
  23. import javax.validation.constraints.Email;
  24. import javax.validation.constraints.NotBlank;
  25. import javax.validation.constraints.NotNull;
  26. import org.apache.commons.lang3.StringUtils;
  27. import java.io.Serializable;
  28. import java.util.Date;
  29. import java.util.Objects;
  30. import java.util.Set;
  31. /**
  32. * @author Zheng Jie
  33. * @date 2018-11-22
  34. */
  35. @Entity
  36. @Getter
  37. @Setter
  38. @Table(name = "sys_user")
  39. public class User extends BaseEntity implements Serializable {
  40. @Id
  41. @Column(name = "user_id")
  42. @NotNull(groups = Update.class)
  43. @GeneratedValue(strategy = GenerationType.IDENTITY)
  44. @ApiModelProperty(value = "ID", hidden = true)
  45. private Long id;
  46. @ManyToMany(fetch = FetchType.EAGER)
  47. @ApiModelProperty(value = "用户角色")
  48. @JoinTable(name = "sys_users_roles", joinColumns = {
  49. @JoinColumn(name = "user_id", referencedColumnName = "user_id") }, inverseJoinColumns = {
  50. @JoinColumn(name = "role_id", referencedColumnName = "role_id") })
  51. private Set<Role> roles;
  52. @ManyToMany(fetch = FetchType.EAGER)
  53. @ApiModelProperty(value = "用户岗位")
  54. @JoinTable(name = "sys_users_jobs", joinColumns = {
  55. @JoinColumn(name = "user_id", referencedColumnName = "user_id") }, inverseJoinColumns = {
  56. @JoinColumn(name = "job_id", referencedColumnName = "job_id") })
  57. private Set<Job> jobs;
  58. @OneToOne
  59. @JoinColumn(name = "dept_id")
  60. @ApiModelProperty(value = "用户部门")
  61. private Dept dept;
  62. @NotBlank
  63. @Column(unique = true)
  64. @ApiModelProperty(value = "用户名称")
  65. private String username;
  66. @NotBlank
  67. @ApiModelProperty(value = "用户昵称")
  68. private String nickName;
  69. @Email
  70. // @NotBlank
  71. @ApiModelProperty(value = "邮箱")
  72. private String email;
  73. @NotBlank
  74. @ApiModelProperty(value = "电话号码")
  75. private String phone;
  76. @ApiModelProperty(value = "用户性别")
  77. private String gender;
  78. @ApiModelProperty(value = "头像真实名称", hidden = true)
  79. private String avatarName;
  80. @ApiModelProperty(value = "头像存储的路径", hidden = true)
  81. private String avatarPath;
  82. @ApiModelProperty(value = "密码")
  83. private String password;
  84. @NotNull
  85. @ApiModelProperty(value = "是否启用")
  86. private Boolean enabled;
  87. @ApiModelProperty(value = "是否为admin账号", hidden = true)
  88. private Boolean isAdmin = false;
  89. @Column(name = "pwd_reset_time")
  90. @ApiModelProperty(value = "最后修改密码的时间", hidden = true)
  91. private Date pwdResetTime;
  92. @Column(name = "org_id")
  93. @ApiModelProperty(value = "机构的id") // 银行或者公证处
  94. private String orgId;
  95. @Column(name = "id_card")
  96. @ApiModelProperty(value = "身份证") // 用户身份证
  97. private String idCard;
  98. @Column(name = "sign_img_id")
  99. @ApiModelProperty(value = "签名图片id")
  100. private String signImgId;
  101. @Column(name = "axq_user_id")
  102. @ApiModelProperty(value = "安心签用户ID")
  103. private String axqUserId;
  104. @Column(name = "axq_seal_id")
  105. @ApiModelProperty(value = "安心签签名图片ID")
  106. private String axqSealId;
  107. @Column(name = "axq_is_auth")
  108. @ApiModelProperty(value = "安心签签名授权标记")
  109. private String axqIsAuth;
  110. @Transient
  111. @TableField(exist = false)
  112. @ApiModelProperty(value = "安心签签名授权验证码")
  113. private String checkCode;
  114. @Transient
  115. @TableField(exist = false)
  116. @ApiModelProperty(value = "图片的id的值")
  117. private String imageId;
  118. /**
  119. * 获取用户类型
  120. *
  121. * @return
  122. */
  123. public String getUserType() {
  124. if (StringUtils.isNotBlank(orgId) && orgId.contains(",")) {
  125. return orgId.split("_")[0];
  126. }
  127. return "";
  128. }
  129. /**
  130. * 获取公司ID
  131. *
  132. * @return
  133. */
  134. public String getComId() {
  135. // 增加非空判断
  136. if (StringUtils.isNotBlank(orgId) && orgId.contains(",")) {
  137. return orgId.split("_")[1];
  138. }
  139. return "";
  140. }
  141. @Override
  142. public boolean equals(Object o) {
  143. if (this == o) {
  144. return true;
  145. }
  146. if (o == null || getClass() != o.getClass()) {
  147. return false;
  148. }
  149. User user = (User) o;
  150. return Objects.equals(id, user.id) && Objects.equals(username, user.username);
  151. }
  152. @Override
  153. public int hashCode() {
  154. return Objects.hash(id, username);
  155. }
  156. }