PageRenderTime 197ms CodeModel.GetById 13ms RepoModel.GetById 6ms app.codeStats 0ms

/src/com/jieshuhuiyou/entity/User.java

https://bitbucket.org/leafiwan/collegemailsystem
Java | 338 lines | 246 code | 86 blank | 6 comment | 13 complexity | e0f42827219473a58905924327b43626 MD5 | raw file
  1. package com.jieshuhuiyou.entity;
  2. import java.io.Serializable;
  3. import java.util.Date;
  4. import javax.persistence.Column;
  5. import javax.persistence.Entity;
  6. import javax.persistence.GeneratedValue;
  7. import javax.persistence.Id;
  8. import javax.persistence.ManyToOne;
  9. import org.apache.struts2.json.annotations.JSON;
  10. import com.alibaba.fastjson.annotation.JSONField;
  11. import com.jieshuhuiyou.Config;
  12. /**
  13. * 用户类
  14. * @author psjay
  15. *
  16. */
  17. @Entity
  18. public class User implements Serializable {
  19. private static final long serialVersionUID = -2883585313597518351L;
  20. @Id
  21. @GeneratedValue
  22. private int id; //ID
  23. private String name; //姓名
  24. @Column(length = 100, nullable = false)
  25. private String email; //邮箱
  26. @Column(length = 32, nullable = false)
  27. private String password; //密码+salt(MD5)
  28. @Column(length = 16, nullable = false)
  29. private String passwordSalt;//salt(MD5)
  30. @Column(length = 15)
  31. private String qq; //QQ号码
  32. @Column(length = 15)
  33. private String phoneNumber; //电话号码
  34. private String smallAvatar; //小头像
  35. private String largeAvatar; // 大头像
  36. @ManyToOne
  37. private School school; //学校
  38. @Column(length = 200)
  39. private String description; //自我描述
  40. @Column(columnDefinition = "timestamp not null default current_timestamp")
  41. private Date signUpDate; //注册时间
  42. @Column(nullable = false)
  43. private boolean isBlock = false; //用户是否被关黑屋
  44. @Column(nullable = false)
  45. private int integral = Config.INTEGRAL_DEFAULT_NUM; //积分
  46. @Column(nullable = false)
  47. private float credit = 0; //信誉
  48. @Column(nullable = false)
  49. private int evalutedNum = 0; //已经给他评价信誉度的人数
  50. private int sharingCount; //共享总数
  51. private int borrowedCount; //借阅总数
  52. private int receivedBorrowRequestsCount; // 收到的借阅请求数
  53. private int sendedBorrowRequestsCount; //发出的借阅请求数
  54. private int borrowingCount; // 借出总数
  55. private int reviewsCount; // 书评总数
  56. private int followingBookCount; //关注的书籍数
  57. private int followingUserCount; //关注的用户数
  58. private int followersCount; // 关注者的数量
  59. public User() {
  60. }
  61. @Override
  62. public boolean equals(Object obj) {
  63. if (this == obj)
  64. return true;
  65. if (obj == null)
  66. return false;
  67. if (getClass() != obj.getClass())
  68. return false;
  69. User other = (User) obj;
  70. if (email == null) {
  71. if (other.email != null)
  72. return false;
  73. } else if (!email.equals(other.email))
  74. return false;
  75. return true;
  76. }
  77. @Override
  78. public int hashCode() {
  79. final int prime = 31;
  80. int result = 1;
  81. result = prime * result + ((email == null) ? 0 : email.hashCode());
  82. return result;
  83. }
  84. // setters and getters
  85. @JSONField(serialize = false)
  86. public int getBorrowedCount() {
  87. return borrowedCount;
  88. }
  89. @JSONField(serialize = false)
  90. @JSON(serialize = false)
  91. public String getDescription() {
  92. return description;
  93. }
  94. @JSONField(serialize = false)
  95. @JSON(serialize = false)
  96. public String getEmail() {
  97. return email;
  98. }
  99. public int getId() {
  100. return id;
  101. }
  102. public void setId(int id) {
  103. this.id = id;
  104. }
  105. public String getLargeAvatar() {
  106. return largeAvatar;
  107. }
  108. public String getName() {
  109. return name;
  110. }
  111. @JSONField(serialize = false)
  112. @JSON(serialize = false)
  113. public String getPassword() {
  114. return password;
  115. }
  116. @JSONField(serialize = false)
  117. @JSON(serialize = false)
  118. public String getPasswordSalt() {
  119. return passwordSalt;
  120. }
  121. public String getPhoneNumber() {
  122. return phoneNumber;
  123. }
  124. public String getQq() {
  125. return qq;
  126. }
  127. @JSONField(serialize = false)
  128. public int getSharingCount() {
  129. return sharingCount;
  130. }
  131. @JSONField(serialize = false)
  132. @JSON(serialize = false)
  133. public Date getSignUpDate() {
  134. return signUpDate;
  135. }
  136. @JSONField(serialize = false)
  137. public int getEvalutedNum() {
  138. return evalutedNum;
  139. }
  140. public void setEvalutedNum(int evalutedNum) {
  141. this.evalutedNum = evalutedNum;
  142. }
  143. public String getSmallAvatar() {
  144. return smallAvatar;
  145. }
  146. public School getSchool() {
  147. return school;
  148. }
  149. public void setBorrowedCount(int borrowedCount) {
  150. this.borrowedCount = borrowedCount;
  151. }
  152. public void setDescription(String description) {
  153. this.description = description;
  154. }
  155. public void setEmail(String email) {
  156. this.email = email;
  157. }
  158. public void setLargeAvatar(String largeAvatar) {
  159. this.largeAvatar = largeAvatar;
  160. }
  161. public void setName(String name) {
  162. this.name = name;
  163. }
  164. public void setPassword(String password) {
  165. this.password = password;
  166. }
  167. public void setPasswordSalt(String passwordSalt) {
  168. this.passwordSalt = passwordSalt;
  169. }
  170. public void setPhoneNumber(String phoneNumber) {
  171. this.phoneNumber = phoneNumber;
  172. }
  173. public void setQq(String qq) {
  174. this.qq = qq;
  175. }
  176. public void setSharingCount(int sharingCount) {
  177. this.sharingCount = sharingCount;
  178. }
  179. public void setSignUpDate(Date signUpDate) {
  180. this.signUpDate = signUpDate;
  181. }
  182. public void setSmallAvatar(String smallAvatar) {
  183. this.smallAvatar = smallAvatar;
  184. }
  185. @JSONField(serialize = false)
  186. public int getReceivedBorrowRequestsCount() {
  187. return receivedBorrowRequestsCount;
  188. }
  189. public void setReceivedBorrowRequestsCount(int receivedBorrowRequestsCount) {
  190. this.receivedBorrowRequestsCount = receivedBorrowRequestsCount;
  191. }
  192. @JSONField(serialize = false)
  193. public int getSendedBorrowRequestsCount() {
  194. return sendedBorrowRequestsCount;
  195. }
  196. public void setSendedBorrowRequestsCount(int sendedBorrowRequestsCount) {
  197. this.sendedBorrowRequestsCount = sendedBorrowRequestsCount;
  198. }
  199. @JSONField(serialize = false)
  200. public int getBorrowingCount() {
  201. return borrowingCount;
  202. }
  203. public void setBorrowingCount(int borrowingCount) {
  204. this.borrowingCount = borrowingCount;
  205. }
  206. public void setSchool(School school) {
  207. this.school = school;
  208. }
  209. @JSONField(serialize = false)
  210. public int getReviewsCount() {
  211. return reviewsCount;
  212. }
  213. public void setReviewsCount(int reviewsCount) {
  214. this.reviewsCount = reviewsCount;
  215. }
  216. public int getFollowingBookCount() {
  217. return followingBookCount;
  218. }
  219. public void setFollowingBookCount(int followingBookCount) {
  220. this.followingBookCount = followingBookCount;
  221. }
  222. public int getFollowingUserCount() {
  223. return followingUserCount;
  224. }
  225. public void setFollowingUserCount(int followingUserCount) {
  226. this.followingUserCount = followingUserCount;
  227. }
  228. public int getFollowersCount() {
  229. return followersCount;
  230. }
  231. public void setFollowersCount(int followersCount) {
  232. this.followersCount = followersCount;
  233. }
  234. public int getIntegral() {
  235. return integral;
  236. }
  237. public void setIntegral(int integral) {
  238. this.integral = integral;
  239. }
  240. public float getCredit() {
  241. return credit;
  242. }
  243. public void setCredit(float f) {
  244. this.credit = f;
  245. }
  246. public boolean isBlock() {
  247. return isBlock;
  248. }
  249. public void setBlock(boolean isBlock) {
  250. this.isBlock = isBlock;
  251. }
  252. }