File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
src/main/java/com/back/domain/board/post/entity Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ public class Post extends BaseEntity {
2626 @ Column (nullable = false )
2727 private Long likeCount = 0L ;
2828
29+ @ Column (nullable = false )
30+ private Long bookmarkCount = 0L ;
31+
32+ @ Column (nullable = false )
33+ private Long commentCount = 0L ;
34+
2935 @ OneToMany (mappedBy = "post" , cascade = CascadeType .ALL , orphanRemoval = true )
3036 private List <PostCategoryMapping > postCategoryMappings = new ArrayList <>();
3137
@@ -72,6 +78,30 @@ public void decreaseLikeCount() {
7278 }
7379 }
7480
81+ // 북마크 수 증가
82+ public void increaseBookmarkCount () {
83+ this .bookmarkCount ++;
84+ }
85+
86+ // 북마크 수 감소
87+ public void decreaseBookmarkCount () {
88+ if (this .bookmarkCount > 0 ) {
89+ this .bookmarkCount --;
90+ }
91+ }
92+
93+ // 댓글 수 증가
94+ public void increaseCommentCount () {
95+ this .commentCount ++;
96+ }
97+
98+ // 댓글 수 감소
99+ public void decreaseCommentCount () {
100+ if (this .commentCount > 0 ) {
101+ this .commentCount --;
102+ }
103+ }
104+
75105 // -------------------- 헬퍼 메서드 --------------------
76106 // 게시글에 연결된 카테고리 목록 조회
77107 public List <PostCategory > getCategories () {
You can’t perform that action at this time.
0 commit comments