Message.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. package com.uas.service.donate.model;
  2. import com.alibaba.fastjson.annotation.JSONField;
  3. import com.fasterxml.jackson.annotation.JsonIgnore;
  4. import org.hibernate.validator.constraints.Length;
  5. import javax.persistence.*;
  6. import java.io.Serializable;
  7. import java.util.Date;
  8. import java.util.Set;
  9. /**
  10. * 消息通知表
  11. *
  12. */
  13. @Entity
  14. @Table(name = "donate$message")
  15. public class Message implements Serializable {
  16. /**
  17. * 序号
  18. */
  19. private static final long serialVersionUID = 1L;
  20. /**
  21. * id
  22. */
  23. @Id
  24. @GeneratedValue(strategy = GenerationType.IDENTITY)
  25. @Column(name = "dm_id")
  26. private Long id;
  27. /**
  28. * 发布用户UU
  29. */
  30. @Column(name = "dm_useruu")
  31. private Long userUU;
  32. /**
  33. * 发布用户
  34. */
  35. @OneToOne(cascade = CascadeType.REFRESH)
  36. @JoinColumn(name = "dm_useruu", insertable = false, updatable = false)
  37. private User user;
  38. /**
  39. * 提交时间
  40. */
  41. @Column(name = "dm_date")
  42. private Date date;
  43. /**
  44. * 发布时间
  45. */
  46. @Column(name = "dm_publishdate")
  47. private Date publishDate;
  48. /**
  49. * 消息标题
  50. */
  51. @Column(name = "dm_title")
  52. private String title;
  53. /**
  54. * 消息正文
  55. */
  56. @Column(name = "dm_context")
  57. @Length(max = 600)
  58. private String context;
  59. /**
  60. * 消息类型(角色类型、机构对象、指定用户、所有用户)
  61. */
  62. @Column(name = "dm_type")
  63. private String type;
  64. /**
  65. * 来源表
  66. */
  67. @Column(name = "dm_table")
  68. private String table;
  69. /**
  70. * 来源id
  71. */
  72. @Column(name = "dm_sourceid")
  73. private Long sourceId;
  74. /**
  75. * 单据链接
  76. */
  77. @Column(name = "dm_url")
  78. private String url;
  79. /**
  80. * 消息明细
  81. */
  82. @OneToMany(mappedBy = "message", cascade = CascadeType.REFRESH)
  83. @OrderBy("dmd_id DESC")
  84. private Set<MessageDetail> messageDetails;
  85. /**
  86. * 接收对象
  87. */
  88. @Column(name = "dm_receiver")
  89. private String receiver;
  90. /**
  91. * 阅读人数
  92. */
  93. @Column(name = "dm_readernum")
  94. private Integer readerNum;
  95. /**
  96. * 消息接收人数
  97. */
  98. @Column(name = "dm_receivernum")
  99. private Integer receiverNum;
  100. public Message() {
  101. }
  102. public Message(Long userUU, String title, String context, String type, String table, Long sourceId, String url, String receiver) {
  103. this.userUU = userUU;
  104. this.title = title;
  105. this.context = context;
  106. this.type = type;
  107. this.table = table;
  108. this.sourceId = sourceId;
  109. this.url = url;
  110. this.receiver = receiver;
  111. this.date = new Date();
  112. this.publishDate = new Date();
  113. this.readerNum = 0;
  114. }
  115. public Long getId() {
  116. return id;
  117. }
  118. public void setId(Long id) {
  119. this.id = id;
  120. }
  121. public Long getUserUU() {
  122. return userUU;
  123. }
  124. public void setUserUU(Long userUU) {
  125. this.userUU = userUU;
  126. }
  127. public User getUser() {
  128. return user;
  129. }
  130. public void setUser(User user) {
  131. this.user = user;
  132. }
  133. public Date getDate() {
  134. return date;
  135. }
  136. public void setDate(Date date) {
  137. this.date = date;
  138. }
  139. public Date getPublishDate() {
  140. return publishDate;
  141. }
  142. public void setPublishDate(Date publishDate) {
  143. this.publishDate = publishDate;
  144. }
  145. public String getTitle() {
  146. return title;
  147. }
  148. public void setTitle(String title) {
  149. this.title = title;
  150. }
  151. public String getContext() {
  152. return context;
  153. }
  154. public void setContext(String context) {
  155. this.context = context;
  156. }
  157. public String getType() {
  158. return type;
  159. }
  160. public void setType(String type) {
  161. this.type = type;
  162. }
  163. public String getTable() {
  164. return table;
  165. }
  166. public void setTable(String table) {
  167. this.table = table;
  168. }
  169. public Long getSourceId() {
  170. return sourceId;
  171. }
  172. public void setSourceId(Long sourceId) {
  173. this.sourceId = sourceId;
  174. }
  175. public String getUrl() {
  176. return url;
  177. }
  178. public void setUrl(String url) {
  179. this.url = url;
  180. }
  181. @JsonIgnore
  182. @JSONField(serialize = false)
  183. public Set<MessageDetail> getMessageDetails() {
  184. return messageDetails;
  185. }
  186. public void setMessageDetails(Set<MessageDetail> messageDetails) {
  187. this.messageDetails = messageDetails;
  188. }
  189. public String getReceiver() {
  190. return receiver;
  191. }
  192. public void setReceiver(String receiver) {
  193. this.receiver = receiver;
  194. }
  195. public Integer getReaderNum() {
  196. return readerNum;
  197. }
  198. public void setReaderNum(Integer readerNum) {
  199. this.readerNum = readerNum;
  200. }
  201. public Integer getReceiverNum() {
  202. return this.receiverNum;
  203. }
  204. public void setReceiverNum(Integer receiverNum) {
  205. this.receiverNum = receiverNum;
  206. }
  207. }