콘텐츠 댓글 조회 수정
- 콘텐츠 크리에이터 - 댓글 전체 조회 - 일반 유저 - 공개 댓글 + 내가 쓴 댓글
This commit is contained in:
@@ -55,6 +55,7 @@ class AudioContentCommentController(private val service: AudioContentCommentServ
|
||||
ApiResponse.ok(
|
||||
service.getCommentList(
|
||||
audioContentId = audioContentId,
|
||||
memberId = member.id!!,
|
||||
timezone = timezone,
|
||||
pageable = pageable
|
||||
)
|
||||
|
@@ -16,12 +16,14 @@ interface AudioContentCommentQueryRepository {
|
||||
fun findByContentId(
|
||||
cloudFrontHost: String,
|
||||
contentId: Long,
|
||||
memberId: Long,
|
||||
isContentCreator: Boolean,
|
||||
timezone: String,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
): List<GetAudioContentCommentListItem>
|
||||
|
||||
fun totalCountCommentByContentId(contentId: Long): Int
|
||||
fun totalCountCommentByContentId(contentId: Long, memberId: Long, isContentCreator: Boolean): Int
|
||||
fun commentReplyCountByAudioContentCommentId(commentId: Long): Int
|
||||
fun getAudioContentCommentReplyList(
|
||||
cloudFrontHost: String,
|
||||
@@ -45,21 +47,32 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
override fun findByContentId(
|
||||
cloudFrontHost: String,
|
||||
contentId: Long,
|
||||
memberId: Long,
|
||||
isContentCreator: Boolean,
|
||||
timezone: String,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
): List<GetAudioContentCommentListItem> {
|
||||
return queryFactory.selectFrom(audioContentComment)
|
||||
.where(
|
||||
audioContentComment.audioContent.id.eq(contentId)
|
||||
.and(audioContentComment.isActive.isTrue)
|
||||
.and(audioContentComment.parent.isNull)
|
||||
var where = audioContentComment.audioContent.id.eq(contentId)
|
||||
.and(audioContentComment.isActive.isTrue)
|
||||
.and(audioContentComment.parent.isNull)
|
||||
|
||||
if (!isContentCreator) {
|
||||
where = where.and(
|
||||
audioContentComment.isSecret.isFalse
|
||||
.or(audioContentComment.member.id.eq(memberId))
|
||||
)
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(audioContentComment)
|
||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
||||
.innerJoin(audioContentComment.member, member)
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit.toLong())
|
||||
.orderBy(audioContentComment.createdAt.desc())
|
||||
.fetch()
|
||||
.asSequence()
|
||||
.map {
|
||||
val date = it.createdAt!!
|
||||
.atZone(ZoneId.of("UTC"))
|
||||
@@ -75,22 +88,32 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
"$cloudFrontHost/profile/default-profile.png"
|
||||
},
|
||||
comment = it.comment,
|
||||
isSecret = it.isSecret,
|
||||
donationCan = it.donationCan ?: 0,
|
||||
date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
||||
replyCount = commentReplyCountByAudioContentCommentId(it.id!!)
|
||||
)
|
||||
}
|
||||
.toList()
|
||||
}
|
||||
|
||||
override fun totalCountCommentByContentId(contentId: Long): Int {
|
||||
return queryFactory.select(audioContentComment.id)
|
||||
.from(audioContentComment)
|
||||
.where(
|
||||
audioContentComment.audioContent.id.eq(contentId)
|
||||
.and(audioContentComment.parent.isNull)
|
||||
.and(audioContentComment.isActive.isTrue)
|
||||
override fun totalCountCommentByContentId(contentId: Long, memberId: Long, isContentCreator: Boolean): Int {
|
||||
var where = audioContentComment.audioContent.id.eq(contentId)
|
||||
.and(audioContentComment.isActive.isTrue)
|
||||
.and(audioContentComment.parent.isNull)
|
||||
|
||||
if (!isContentCreator) {
|
||||
where = where.and(
|
||||
audioContentComment.isSecret.isFalse
|
||||
.or(audioContentComment.member.id.eq(memberId))
|
||||
)
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(audioContentComment.id)
|
||||
.from(audioContentComment)
|
||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
||||
.innerJoin(audioContentComment.member, member)
|
||||
.where(where)
|
||||
.fetch()
|
||||
.size
|
||||
}
|
||||
@@ -140,6 +163,7 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
"$cloudFrontHost/profile/default-profile.png"
|
||||
},
|
||||
comment = it.comment,
|
||||
isSecret = it.isSecret,
|
||||
donationCan = it.donationCan ?: 0,
|
||||
date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
||||
replyCount = 0
|
||||
|
@@ -107,16 +107,27 @@ class AudioContentCommentService(
|
||||
}
|
||||
}
|
||||
|
||||
fun getCommentList(audioContentId: Long, timezone: String, pageable: Pageable): GetAudioContentCommentListResponse {
|
||||
val commentList =
|
||||
repository.findByContentId(
|
||||
cloudFrontHost = cloudFrontHost,
|
||||
contentId = audioContentId,
|
||||
timezone = timezone,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize
|
||||
)
|
||||
val totalCount = repository.totalCountCommentByContentId(audioContentId)
|
||||
fun getCommentList(
|
||||
audioContentId: Long,
|
||||
memberId: Long,
|
||||
timezone: String,
|
||||
pageable: Pageable
|
||||
): GetAudioContentCommentListResponse {
|
||||
val isContentCreator = audioContentRepository.isContentCreator(audioContentId, memberId)
|
||||
val commentList = repository.findByContentId(
|
||||
cloudFrontHost = cloudFrontHost,
|
||||
contentId = audioContentId,
|
||||
memberId = memberId,
|
||||
isContentCreator = isContentCreator,
|
||||
timezone = timezone,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize
|
||||
)
|
||||
val totalCount = repository.totalCountCommentByContentId(
|
||||
contentId = audioContentId,
|
||||
memberId = memberId,
|
||||
isContentCreator = isContentCreator
|
||||
)
|
||||
|
||||
return GetAudioContentCommentListResponse(totalCount, commentList)
|
||||
}
|
||||
|
@@ -1,16 +1,19 @@
|
||||
package kr.co.vividnext.sodalive.content.comment
|
||||
|
||||
import com.querydsl.core.annotations.QueryProjection
|
||||
|
||||
data class GetAudioContentCommentListResponse(
|
||||
val totalCount: Int,
|
||||
val items: List<GetAudioContentCommentListItem>
|
||||
)
|
||||
|
||||
data class GetAudioContentCommentListItem(
|
||||
data class GetAudioContentCommentListItem @QueryProjection constructor(
|
||||
val id: Long,
|
||||
val writerId: Long,
|
||||
val nickname: String,
|
||||
val profileUrl: String,
|
||||
val comment: String,
|
||||
val isSecret: Boolean,
|
||||
val donationCan: Int,
|
||||
val date: String,
|
||||
val replyCount: Int
|
||||
|
Reference in New Issue
Block a user