From feaa2230f55ae472fc3876ea4b305d22a48f9c27 Mon Sep 17 00:00:00 2001 From: jae-2024 Date: Sun, 8 Mar 2026 22:15:38 +0900 Subject: [PATCH] =?UTF-8?q?[#61]=20Refactor:=20commentSystem=EC=97=90=20?= =?UTF-8?q?=EC=B0=B8=EA=B0=80id=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/comment/dto/response/CommentResponse.java | 2 ++ .../Mua_backend/domain/comment/entity/Comment.java | 11 +++++++++-- .../domain/comment/service/CommentService.java | 4 ++-- .../participation/service/ParticipationService.java | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/Mua/Mua_backend/domain/comment/dto/response/CommentResponse.java b/src/main/java/Mua/Mua_backend/domain/comment/dto/response/CommentResponse.java index 1cf377f..8e43d51 100644 --- a/src/main/java/Mua/Mua_backend/domain/comment/dto/response/CommentResponse.java +++ b/src/main/java/Mua/Mua_backend/domain/comment/dto/response/CommentResponse.java @@ -9,6 +9,7 @@ public record CommentResponse( Long commentId, Long feedId, + Long participationId, String description, Long parentId, Integer depth, @@ -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(), diff --git a/src/main/java/Mua/Mua_backend/domain/comment/entity/Comment.java b/src/main/java/Mua/Mua_backend/domain/comment/entity/Comment.java index 83c4c54..3980215 100644 --- a/src/main/java/Mua/Mua_backend/domain/comment/entity/Comment.java +++ b/src/main/java/Mua/Mua_backend/domain/comment/entity/Comment.java @@ -53,6 +53,9 @@ 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, @@ -60,7 +63,8 @@ private Comment( Integer depth, CommentType commentType, Member member, - Feed feed + Feed feed, + Long participationId ) { this.description = description; this.parentId = parentId; @@ -68,6 +72,7 @@ private Comment( this.commentType = commentType; this.member = member; this.feed = feed; + this.participationId = participationId; } // USER 댓글 생성 @@ -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) @@ -99,6 +105,7 @@ public static Comment createSystemComment( .commentType(CommentType.SYSTEM) .member(null) .feed(feed) + .participationId(participationId) .build(); } diff --git a/src/main/java/Mua/Mua_backend/domain/comment/service/CommentService.java b/src/main/java/Mua/Mua_backend/domain/comment/service/CommentService.java index 0d49caf..a3c301b 100644 --- a/src/main/java/Mua/Mua_backend/domain/comment/service/CommentService.java +++ b/src/main/java/Mua/Mua_backend/domain/comment/service/CommentService.java @@ -84,11 +84,11 @@ public List 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); } diff --git a/src/main/java/Mua/Mua_backend/domain/participation/service/ParticipationService.java b/src/main/java/Mua/Mua_backend/domain/participation/service/ParticipationService.java index 5699ec7..4682e8a 100644 --- a/src/main/java/Mua/Mua_backend/domain/participation/service/ParticipationService.java +++ b/src/main/java/Mua/Mua_backend/domain/participation/service/ParticipationService.java @@ -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()); } // 참가자 전체 조회