캐릭터 챗봇 #338
|
@ -43,3 +43,12 @@ data class CharacterCommentRepliesResponse(
|
|||
val original: CharacterCommentResponse,
|
||||
val replies: List<CharacterReplyResponse>
|
||||
)
|
||||
|
||||
// 댓글 리스트 조회 Response 컨테이너
|
||||
// - 전체 댓글 개수(totalCount)
|
||||
// - 댓글 목록(comments)
|
||||
|
||||
data class CharacterCommentListResponse(
|
||||
val totalCount: Int,
|
||||
val comments: List<CharacterCommentResponse>
|
||||
)
|
||||
|
|
|
@ -83,13 +83,18 @@ class CharacterCommentService(
|
|||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun listComments(imageHost: String, characterId: Long, limit: Int = 20): List<CharacterCommentResponse> {
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue