From 6c7f41186985fd6bcac0414047b950e03bc77182 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 19 Aug 2025 23:37:24 +0900 Subject: [PATCH] =?UTF-8?q?feat(character-comment):=20=EC=BA=90=EB=A6=AD?= =?UTF-8?q?=ED=84=B0=20=EB=8C=93=EA=B8=80/=EB=8B=B5=EA=B8=80=20API=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9D=91=EB=8B=B5=20=ED=99=95=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 댓글 리스트에 댓글 개수 추가 --- .../chat/character/comment/CharacterCommentDto.kt | 9 +++++++++ .../chat/character/comment/CharacterCommentService.kt | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentDto.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentDto.kt index 437fdf0..769719c 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentDto.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentDto.kt @@ -43,3 +43,12 @@ data class CharacterCommentRepliesResponse( val original: CharacterCommentResponse, val replies: List ) + +// 댓글 리스트 조회 Response 컨테이너 +// - 전체 댓글 개수(totalCount) +// - 댓글 목록(comments) + +data class CharacterCommentListResponse( + val totalCount: Int, + val comments: List +) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentService.kt index 64b6e65..7619ad7 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/comment/CharacterCommentService.kt @@ -83,13 +83,18 @@ class CharacterCommentService( } @Transactional(readOnly = true) - fun listComments(imageHost: String, characterId: Long, limit: Int = 20): List { + fun listComments(imageHost: String, characterId: Long, limit: Int = 20): CharacterCommentListResponse { val pageable = PageRequest.of(0, limit) val comments = commentRepository.findByChatCharacter_IdAndIsActiveTrueAndParentIsNullOrderByCreatedAtDesc( characterId, pageable ) - return comments.map { toCommentResponse(imageHost, it) } + val items = comments.map { toCommentResponse(imageHost, it) } + val total = getTotalCommentCount(characterId) + return CharacterCommentListResponse( + totalCount = total, + comments = items + ) } @Transactional(readOnly = true)