From c9fbc5d5a097590d1847e8d6b059f6a1eff773a2 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Sep 2024 09:46:41 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8C=93=EA=B8=80=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crew/main/comment/v2/service/CommentV2ServiceImpl.java | 3 ++- .../makers/crew/main/entity/comment/CommentRepository.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java index 9f0fc855..664a756c 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java @@ -235,7 +235,8 @@ public void deleteComment(Integer commentId, Integer userId) { Post post = postRepository.findByIdOrThrow(comment.getPostId()); post.decreaseCommentCount(); - Comments childComments = new Comments(commentRepository.findAllByParentIdOrderByOrderDesc(comment.getId())); + Comments childComments = new Comments( + commentRepository.findAllByParentIdAndDepthOrderByOrderDesc(comment.getId(), IS_REPLY_COMMENT)); if (comment.getDepth() == IS_REPLY_COMMENT || !childComments.hasChild()) { commentRepository.delete(comment); diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java index f41879e0..6123a033 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java @@ -19,7 +19,7 @@ default Comment findByIdOrThrow(Integer commentId) { Optional findFirstByParentIdOrderByOrderDesc(Integer parentId); - List findAllByParentIdOrderByOrderDesc(Integer parentId); + List findAllByParentIdAndDepthOrderByOrderDesc(Integer parentId, int depth); Optional findByIdAndPostId(Integer id, Integer postId);