| package com.example.myproject.entity; |
| |
| import com.fasterxml.jackson.annotation.JsonBackReference; |
| import javax.persistence.*; |
| import java.util.Date; |
| |
| @Entity |
| @Table(name = "comments") |
| public class Comments { |
| |
| @Id |
| @GeneratedValue(strategy = GenerationType.IDENTITY) |
| @Column(name = "comment_id") |
| private Long commentId; |
| |
| @ManyToOne |
| @JoinColumn(name = "post_id", nullable = false) |
| @JsonBackReference |
| private Post post; |
| |
| @Column(name = "content", nullable = false) |
| private String content; |
| |
| @Column(name = "is_anonymous") |
| private Boolean isAnonymous; // 是否匿名 |
| |
| @Column(name = "likes_count") |
| private Integer likesCount = 0; // 点赞数 |
| |
| @Column(name = "reply_count") |
| private Integer replyCount = 0; // 回复数 |
| |
| @Column(name = "comment_time", nullable = false) |
| private Date commentTime; // 评论时间 |
| |
| @Column(name = "user_id", nullable = false) |
| private Long userId; // 评论者的 user_id |
| |
| |
| @Column(name = "com_comment_id", nullable = false) |
| private Long com_comment_id; |
| |
| // Getters and Setters |
| |
| public Long getCommentId() { |
| return commentId; |
| } |
| |
| public void setCommentId(Long commentId) { |
| this.commentId = commentId; |
| } |
| |
| public Post getPost() { |
| return post; |
| } |
| |
| public void setPost(Post post) { |
| this.post = post; |
| } |
| |
| public String getContent() { |
| return content; |
| } |
| |
| public void setContent(String content) { |
| this.content = content; |
| } |
| |
| public Boolean getIsAnonymous() { |
| return isAnonymous; |
| } |
| |
| public void setIsAnonymous(Boolean isAnonymous) { |
| this.isAnonymous = isAnonymous; |
| } |
| |
| public Integer getLikesCount() { |
| return likesCount; |
| } |
| |
| public void setLikesCount(Integer likesCount) { |
| this.likesCount = likesCount; |
| } |
| |
| public Integer getReplyCount() { |
| return replyCount; |
| } |
| |
| public void setReplyCount(Integer replyCount) { |
| this.replyCount = replyCount; |
| } |
| |
| public Date getCommentTime() { |
| return commentTime; |
| } |
| |
| public void setCommentTime(Date commentTime) { |
| this.commentTime = commentTime; |
| } |
| |
| public Long getUserId() { |
| return userId; |
| } |
| |
| public void setUserId(Long userId) { |
| this.userId = userId; |
| } |
| |
| public Long getParentComment() { |
| return com_comment_id; |
| } |
| |
| public void setParentComment(Long com_comment_id) { |
| this.com_comment_id = com_comment_id; |
| } |
| } |