Skip to content

Commit

Permalink
hotfix: 댓글 조회 수정
Browse files Browse the repository at this point in the history
hotfix: 댓글 조회 수정
  • Loading branch information
mikekks authored Sep 1, 2024
2 parents 5fa27b4 + c9fbc5d commit a354b39
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default Comment findByIdOrThrow(Integer commentId) {

Optional<Comment> findFirstByParentIdOrderByOrderDesc(Integer parentId);

List<Comment> findAllByParentIdOrderByOrderDesc(Integer parentId);
List<Comment> findAllByParentIdAndDepthOrderByOrderDesc(Integer parentId, int depth);

Optional<Comment> findByIdAndPostId(Integer id, Integer postId);

Expand Down

0 comments on commit a354b39

Please sign in to comment.