Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 댓글 삭제 시 댓글 좋아요, 싫어요 삭제한다. #146

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/life/offonoff/ab/domain/comment/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -29,6 +31,7 @@ public class Comment extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "topic_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private Topic topic;

private int likeCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import jakarta.persistence.*;
import life.offonoff.ab.domain.BaseEntity;
import life.offonoff.ab.domain.member.Member;
import life.offonoff.ab.domain.topic.Topic;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -18,10 +19,12 @@ public class HatedComment extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private Member hater;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "comment_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private Comment comment;

public HatedComment(Member member, Comment comment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -17,10 +19,12 @@ public class LikedComment extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private Member liker;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "comment_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private Comment comment;

public LikedComment(Member liker, Comment comment) {
Expand Down
Loading