feat(character-comment): 캐릭터 댓글/답글 API 및 응답 확장
- 댓글 리스트에 댓글 개수 추가
This commit is contained in:
parent
f61c45e89a
commit
6c7f411869
|
@ -43,3 +43,12 @@ data class CharacterCommentRepliesResponse(
|
||||||
val original: CharacterCommentResponse,
|
val original: CharacterCommentResponse,
|
||||||
val replies: List<CharacterReplyResponse>
|
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)
|
@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 pageable = PageRequest.of(0, limit)
|
||||||
val comments = commentRepository.findByChatCharacter_IdAndIsActiveTrueAndParentIsNullOrderByCreatedAtDesc(
|
val comments = commentRepository.findByChatCharacter_IdAndIsActiveTrueAndParentIsNullOrderByCreatedAtDesc(
|
||||||
characterId,
|
characterId,
|
||||||
pageable
|
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)
|
@Transactional(readOnly = true)
|
||||||
|
|
Loading…
Reference in New Issue