blob: fdf89fa06594b57d3a5ec4527d6b4a35e82a303d [file] [log] [blame]
223011385e9c35a2025-06-04 15:52:45 +08001package com.example.myproject.entity;
2
3import com.fasterxml.jackson.annotation.JsonBackReference;
4import javax.persistence.*;
5import java.util.Date;
6
7@Entity
8@Table(name = "comments")
9public class Comments {
10
11 @Id
12 @GeneratedValue(strategy = GenerationType.IDENTITY)
13 @Column(name = "comment_id")
14 private Long commentId;
15
16 @ManyToOne
17 @JoinColumn(name = "post_id", nullable = false)
18 @JsonBackReference
19 private Post post;
20
21 @Column(name = "content", nullable = false)
22 private String content;
23
24 @Column(name = "is_anonymous")
25 private Boolean isAnonymous; // 是否匿名
26
27 @Column(name = "likes_count")
28 private Integer likesCount = 0; // 点赞数
29
30 @Column(name = "reply_count")
31 private Integer replyCount = 0; // 回复数
32
33 @Column(name = "comment_time", nullable = false)
34 private Date commentTime; // 评论时间
35
36 @Column(name = "user_id", nullable = false)
37 private Long userId; // 评论者的 user_id
38
39
40 @Column(name = "com_comment_id", nullable = false)
41 private Long com_comment_id;
42
43 // Getters and Setters
44
45 public Long getCommentId() {
46 return commentId;
47 }
48
49 public void setCommentId(Long commentId) {
50 this.commentId = commentId;
51 }
52
53 public Post getPost() {
54 return post;
55 }
56
57 public void setPost(Post post) {
58 this.post = post;
59 }
60
61 public String getContent() {
62 return content;
63 }
64
65 public void setContent(String content) {
66 this.content = content;
67 }
68
69 public Boolean getIsAnonymous() {
70 return isAnonymous;
71 }
72
73 public void setIsAnonymous(Boolean isAnonymous) {
74 this.isAnonymous = isAnonymous;
75 }
76
77 public Integer getLikesCount() {
78 return likesCount;
79 }
80
81 public void setLikesCount(Integer likesCount) {
82 this.likesCount = likesCount;
83 }
84
85 public Integer getReplyCount() {
86 return replyCount;
87 }
88
89 public void setReplyCount(Integer replyCount) {
90 this.replyCount = replyCount;
91 }
92
93 public Date getCommentTime() {
94 return commentTime;
95 }
96
97 public void setCommentTime(Date commentTime) {
98 this.commentTime = commentTime;
99 }
100
101 public Long getUserId() {
102 return userId;
103 }
104
105 public void setUserId(Long userId) {
106 this.userId = userId;
107 }
108
109 public Long getParentComment() {
110 return com_comment_id;
111 }
112
113 public void setParentComment(Long com_comment_id) {
114 this.com_comment_id = com_comment_id;
115 }
116}