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)