Skip to content

Commit 79b44d6

Browse files
authored
[Fix]: 좋아요 있는 게시글, 댓글 삭제 시 같이 지워지도록 변경 (#156)
1 parent 44b1885 commit 79b44d6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

back/src/main/java/com/back/domain/comment/entity/Comment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.back.domain.comment.entity;
22

3+
import com.back.domain.like.entity.CommentLike;
34
import com.back.domain.post.entity.Post;
45
import com.back.domain.user.entity.User;
56
import com.back.global.baseentity.BaseEntity;
@@ -47,6 +48,10 @@ public class Comment extends BaseEntity {
4748

4849
private int likeCount;
4950

51+
@OneToMany(mappedBy = "comment", cascade = CascadeType.ALL, orphanRemoval = true)
52+
@Builder.Default
53+
private List<CommentLike> commentLikes = new ArrayList<>();
54+
5055
@LastModifiedDate
5156
private LocalDateTime updatedAt;
5257

back/src/main/java/com/back/domain/post/entity/Post.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.back.domain.post.entity;
22

33
import com.back.domain.comment.entity.Comment;
4+
import com.back.domain.like.entity.PostLike;
45
import com.back.domain.poll.entity.PollVote;
56
import com.back.domain.post.enums.PostCategory;
67
import com.back.domain.scenario.entity.Scenario;
@@ -72,6 +73,10 @@ public class Post extends BaseEntity {
7273
@Builder.Default
7374
private List<PollVote> pollVotes = new ArrayList<>();
7475

76+
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
77+
@Builder.Default
78+
private List<PostLike> postLikes = new ArrayList<>();
79+
7580
@OneToOne(fetch = FetchType.LAZY)
7681
@JoinColumn(name = "scenario_id")
7782
private Scenario scenario;

0 commit comments

Comments
 (0)