PageRenderTime 1284ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/SHJS/src/main/java/com/sunwave/app/model/SysUser.java

https://gitlab.com/dannyblue/danny-project
Java | 199 lines | 155 code | 36 blank | 8 comment | 4 complexity | 707a95370009300a93dbae70cc2ce797 MD5 | raw file
  1. package com.sunwave.app.model;
  2. import static javax.persistence.GenerationType.IDENTITY;
  3. import java.util.HashSet;
  4. import java.util.Set;
  5. import javax.persistence.Column;
  6. import javax.persistence.Entity;
  7. import javax.persistence.FetchType;
  8. import javax.persistence.GeneratedValue;
  9. import javax.persistence.Id;
  10. import javax.persistence.JoinColumn;
  11. import javax.persistence.JoinTable;
  12. import javax.persistence.ManyToMany;
  13. import javax.persistence.ManyToOne;
  14. import javax.persistence.Table;
  15. import javax.persistence.Transient;
  16. import com.alibaba.fastjson.annotation.JSONField;
  17. /**
  18. * SysUser entity. @author MyEclipse Persistence Tools
  19. */
  20. @Entity
  21. @Table(name = "sys_user", catalog = "inmm")
  22. public class SysUser implements java.io.Serializable {
  23. // Fields
  24. private Integer id;
  25. private SlArea slArea;
  26. private String username;
  27. private String userShowName;
  28. private String password;
  29. private Integer userType;
  30. private String salt;
  31. private Integer locked;
  32. private Set<SysRole> sysRoles = new HashSet<SysRole>(0);
  33. private String roleName;
  34. private String roleId;
  35. private String roleIdQ;
  36. // Constructors
  37. /** default constructor */
  38. public SysUser() {
  39. }
  40. /** full constructor */
  41. public SysUser(SlArea slArea, String username, String userShowName,
  42. String password, Integer userType, String salt, Integer locked,
  43. Set<SysRole> sysRoles) {
  44. this.slArea = slArea;
  45. this.username = username;
  46. this.userShowName = userShowName;
  47. this.password = password;
  48. this.userType = userType;
  49. this.salt = salt;
  50. this.locked = locked;
  51. this.sysRoles = sysRoles;
  52. }
  53. // Property accessors
  54. @Id
  55. @GeneratedValue(strategy = IDENTITY)
  56. @Column(name = "id", unique = true, nullable = false)
  57. public Integer getId() {
  58. return this.id;
  59. }
  60. public void setId(Integer id) {
  61. this.id = id;
  62. }
  63. @ManyToOne(fetch = FetchType.LAZY)
  64. @JoinColumn(name = "area_id")
  65. public SlArea getSlArea() {
  66. return this.slArea;
  67. }
  68. public void setSlArea(SlArea slArea) {
  69. this.slArea = slArea;
  70. }
  71. @Column(name = "username", length = 50)
  72. public String getUsername() {
  73. return this.username;
  74. }
  75. public void setUsername(String username) {
  76. this.username = username;
  77. }
  78. @Column(name = "user_show_name", length = 200)
  79. public String getUserShowName() {
  80. return this.userShowName;
  81. }
  82. public void setUserShowName(String userShowName) {
  83. this.userShowName = userShowName;
  84. }
  85. @Column(name = "password", length = 200)
  86. public String getPassword() {
  87. return this.password;
  88. }
  89. public void setPassword(String password) {
  90. this.password = password;
  91. }
  92. @Column(name = "user_type")
  93. public Integer getUserType() {
  94. return this.userType;
  95. }
  96. public void setUserType(Integer userType) {
  97. this.userType = userType;
  98. }
  99. @Column(name = "salt", length = 100)
  100. public String getSalt() {
  101. return this.salt;
  102. }
  103. public void setSalt(String salt) {
  104. this.salt = salt;
  105. }
  106. @Transient
  107. public String getCredentialsSalt() {
  108. return username + salt;
  109. }
  110. @Column(name = "locked")
  111. public Integer getLocked() {
  112. return this.locked;
  113. }
  114. public void setLocked(Integer locked) {
  115. this.locked = locked;
  116. }
  117. @JSONField(serialize=false)
  118. @ManyToMany(fetch = FetchType.LAZY)
  119. @JoinTable(name = "sys_user_role", catalog = "inmm", joinColumns = { @JoinColumn(name = "user_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role_id", updatable = false) })
  120. public Set<SysRole> getSysRoles() {
  121. return this.sysRoles;
  122. }
  123. public void setSysRoles(Set<SysRole> sysRoles) {
  124. this.sysRoles = sysRoles;
  125. }
  126. @Transient
  127. public String getRoleName() {
  128. Set<SysRole> roles = getSysRoles();
  129. roleName="";
  130. for(SysRole r :roles){
  131. roleName+=r.getRoleName()+",";
  132. }
  133. if(!"".equals(roleName)){
  134. roleName=roleName.substring(0, roleName.length()-1);
  135. }
  136. return roleName;
  137. }
  138. public void setRoleName(String roleName) {
  139. this.roleName = roleName;
  140. }
  141. @Transient
  142. public String getRoleId() {
  143. Set<SysRole> roles = getSysRoles();
  144. roleId="";
  145. for(SysRole r :roles){
  146. roleId+=r.getId()+",";
  147. }
  148. if(!"".equals(roleId)){
  149. roleId=roleId.substring(0, roleId.length()-1);
  150. }
  151. return roleId;
  152. }
  153. public void setRoleId(String roleId) {
  154. this.roleId = roleId;
  155. }
  156. @Transient
  157. public String getRoleIdQ() {
  158. return roleIdQ;
  159. }
  160. public void setRoleIdQ(String roleIdQ) {
  161. this.roleIdQ = roleIdQ;
  162. }
  163. }