Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public record CommentResponse(
Long commentId,
Long feedId,
Long participationId,
String description,
Long parentId,
Integer depth,
Expand All @@ -22,6 +23,7 @@ public static CommentResponse from(Comment comment) {
return new CommentResponse(
comment.getId(),
comment.getFeed().getId(),
comment.getParticipationId(),
comment.getDescription(),
comment.getParentId(),
comment.getDepth(),
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/Mua/Mua_backend/domain/comment/entity/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,26 @@ public class Comment extends BaseTimeEntity {
@Column(name = "is_deleted", nullable = false)
private boolean isDeleted = false;

@Column(name = "participation_id")
private Long participationId;

@Builder(access = AccessLevel.PRIVATE)
private Comment(
String description,
Long parentId,
Integer depth,
CommentType commentType,
Member member,
Feed feed
Feed feed,
Long participationId
) {
this.description = description;
this.parentId = parentId;
this.depth = depth;
this.commentType = commentType;
this.member = member;
this.feed = feed;
this.participationId = participationId;
}

// USER 댓글 생성
Expand All @@ -90,7 +95,8 @@ public static Comment createUserComment(
// SYSTEM 댓글 생성
public static Comment createSystemComment(
String description,
Feed feed
Feed feed,
Long participationId
) {
return Comment.builder()
.description(description)
Expand All @@ -99,6 +105,7 @@ public static Comment createSystemComment(
.commentType(CommentType.SYSTEM)
.member(null)
.feed(feed)
.participationId(participationId)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ public List<CommentResponse> getComments(Long feedId) {
}

// 시스템 댓글 생성
public void createSystemComment(Long feedId, String message) {
public void createSystemComment(Long feedId, String message, Long participationId) {
Feed feed = feedRepository.findById(feedId)
.orElseThrow(() -> new IllegalArgumentException("피드가 존재하지 않습니다."));

Comment comment = Comment.createSystemComment(message, feed);
Comment comment = Comment.createSystemComment(message, feed, participationId);
commentRepository.save(comment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void apply(Long feedId, Member member) {
participationRepository.save(participation);

String message = member.getNickname() + "님이 참가 신청했습니다.";
commentService.createSystemComment(feed.getId(), message);
commentService.createSystemComment(feed.getId(), message, participation.getId());
}

// 참가자 전체 조회
Expand Down