From 59f1809961214d3f49adcf2ded38e32792cd8133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9A=A9=EC=A4=80?= <59381113+jjuny0310@users.noreply.github.com> Date: Mon, 30 Oct 2023 00:58:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8C=93=EA=B8=80=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EC=8B=9C=20=EB=8C=93=EA=B8=80=20=EC=88=98=EA=B0=80=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 댓글 삭제 시 개수가 줄어들지 않는 버그 수정 * refactor: 코드 간결하게 수정 --- .../ssafy/ssafsound/domain/post/dto/GetPostElement.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java b/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java index 42debfac5..53ad0f1f6 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java +++ b/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java @@ -38,13 +38,18 @@ public GetPostElement(Post post) { this.title = post.getTitle(); this.content = post.getContent(); this.likeCount = post.getLikes().size(); - this.commentCount = post.getComments().size(); + this.commentCount = getCommentSize(post); this.createdAt = post.getCreatedAt(); this.nickname = anonymity ? "익명" : post.getMember().getNickname(); this.anonymity = anonymity; this.thumbnail = findThumbnailUrl(post); } + private int getCommentSize(Post post) { + return (int) post.getComments().stream() + .filter(comment -> !comment.getDeletedComment()).count(); + } + private String findThumbnailUrl(Post post) { List images = post.getImages(); if (images.size() >= 1)