Comment.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package nju.seec.helper.data.entity;
  2. import lombok.Data;
  3. import nju.seec.helper.util.enums.UserType;
  4. import org.hibernate.annotations.CreationTimestamp;
  5. import javax.persistence.*;
  6. import java.time.LocalDateTime;
  7. import java.util.Collections;
  8. import java.util.Set;
  9. /**
  10. * @author cst
  11. */
  12. @Data
  13. @Entity
  14. @Table(name = "comment")
  15. public class Comment {
  16. @Id
  17. @GeneratedValue(strategy = GenerationType.IDENTITY)
  18. private Integer id;
  19. @Column(name = "item_id")
  20. private Integer itemId;
  21. @Column(name = "user_id")
  22. private Integer userId;
  23. @Column(name = "user_name")
  24. private String username;
  25. @Enumerated(EnumType.STRING)
  26. @Column(name = "user_type")
  27. private UserType userType;
  28. private String content;
  29. @Column(name = "publish_time", updatable = false)
  30. @CreationTimestamp
  31. private LocalDateTime publishTime;
  32. @OneToMany(cascade = CascadeType.ALL, mappedBy = "fatherComment")
  33. private Set<Comment> followComments = Collections.emptySet();
  34. @ManyToOne
  35. @JoinColumn(name = "father_comment_id")
  36. private Comment fatherComment;
  37. }