parent
b70c9518eb
commit
da3175292b
|
@ -74,6 +74,7 @@ class AudioContentCommentController(private val service: AudioContentCommentServ
|
||||||
return ApiResponse.ok(
|
return ApiResponse.ok(
|
||||||
service.getCommentReplyList(
|
service.getCommentReplyList(
|
||||||
commentId = commentId,
|
commentId = commentId,
|
||||||
|
memberId = member.id!!,
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
pageable = pageable
|
pageable = pageable
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package kr.co.vividnext.sodalive.content.comment
|
package kr.co.vividnext.sodalive.content.comment
|
||||||
|
|
||||||
|
import com.querydsl.core.types.dsl.Expressions
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||||
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
import kr.co.vividnext.sodalive.member.QMember.member
|
||||||
|
import kr.co.vividnext.sodalive.member.block.QBlockMember.blockMember
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.ZoneId
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
interface AudioContentCommentRepository : JpaRepository<AudioContentComment, Long>, AudioContentCommentQueryRepository
|
interface AudioContentCommentRepository : JpaRepository<AudioContentComment, Long>, AudioContentCommentQueryRepository
|
||||||
|
@ -28,6 +29,7 @@ interface AudioContentCommentQueryRepository {
|
||||||
fun getAudioContentCommentReplyList(
|
fun getAudioContentCommentReplyList(
|
||||||
cloudFrontHost: String,
|
cloudFrontHost: String,
|
||||||
commentId: Long,
|
commentId: Long,
|
||||||
|
memberId: Long,
|
||||||
timezone: String,
|
timezone: String,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Int
|
limit: Int
|
||||||
|
@ -64,35 +66,50 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val formattedDate = Expressions.stringTemplate(
|
||||||
|
"DATE_FORMAT({0}, {1})",
|
||||||
|
Expressions.dateTimeTemplate(
|
||||||
|
LocalDateTime::class.java,
|
||||||
|
"CONVERT_TZ({0},{1},{2})",
|
||||||
|
audioContentComment.createdAt,
|
||||||
|
"UTC",
|
||||||
|
"Asia/Seoul"
|
||||||
|
),
|
||||||
|
"%Y.%m.%d %W %h:%i %p"
|
||||||
|
)
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.selectFrom(audioContentComment)
|
.select(
|
||||||
|
QGetAudioContentCommentListItem(
|
||||||
|
audioContentComment.id,
|
||||||
|
audioContentComment.member.id,
|
||||||
|
audioContentComment.member.nickname,
|
||||||
|
audioContentComment.member.profileImage.prepend("/").prepend(cloudFrontHost),
|
||||||
|
audioContentComment.comment,
|
||||||
|
audioContentComment.isSecret,
|
||||||
|
blockMember.id.isNotNull,
|
||||||
|
audioContentComment.donationCan.coalesce(0),
|
||||||
|
formattedDate,
|
||||||
|
Expressions.constant(0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(audioContentComment)
|
||||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
.innerJoin(audioContentComment.audioContent, audioContent)
|
||||||
.innerJoin(audioContentComment.member, member)
|
.innerJoin(audioContentComment.member, member)
|
||||||
|
.leftJoin(blockMember)
|
||||||
|
.on(
|
||||||
|
member.id.eq(blockMember.blockedMember.id)
|
||||||
|
.and(blockMember.isActive.isTrue)
|
||||||
|
.and(blockMember.member.id.eq(memberId))
|
||||||
|
)
|
||||||
.where(where)
|
.where(where)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit.toLong())
|
.limit(limit.toLong())
|
||||||
.orderBy(audioContentComment.createdAt.desc())
|
.orderBy(audioContentComment.createdAt.desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
.map {
|
.map {
|
||||||
val date = it.createdAt!!
|
it.replyCount = commentReplyCountByAudioContentCommentId(it.id)
|
||||||
.atZone(ZoneId.of("UTC"))
|
it
|
||||||
.withZoneSameInstant(ZoneId.of(timezone))
|
|
||||||
|
|
||||||
GetAudioContentCommentListItem(
|
|
||||||
id = it.id!!,
|
|
||||||
writerId = it.member!!.id!!,
|
|
||||||
nickname = it.member!!.nickname,
|
|
||||||
profileUrl = if (it.member!!.profileImage != null) {
|
|
||||||
"$cloudFrontHost/${it.member!!.profileImage}"
|
|
||||||
} else {
|
|
||||||
"$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!!)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +150,46 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
override fun getAudioContentCommentReplyList(
|
override fun getAudioContentCommentReplyList(
|
||||||
cloudFrontHost: String,
|
cloudFrontHost: String,
|
||||||
commentId: Long,
|
commentId: Long,
|
||||||
|
memberId: Long,
|
||||||
timezone: String,
|
timezone: String,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Int
|
limit: Int
|
||||||
): List<GetAudioContentCommentListItem> {
|
): List<GetAudioContentCommentListItem> {
|
||||||
return queryFactory.selectFrom(audioContentComment)
|
val formattedDate = Expressions.stringTemplate(
|
||||||
|
"DATE_FORMAT({0}, {1})",
|
||||||
|
Expressions.dateTimeTemplate(
|
||||||
|
LocalDateTime::class.java,
|
||||||
|
"CONVERT_TZ({0},{1},{2})",
|
||||||
|
audioContentComment.createdAt,
|
||||||
|
"UTC",
|
||||||
|
"Asia/Seoul"
|
||||||
|
),
|
||||||
|
"%Y.%m.%d %W %h:%i %p"
|
||||||
|
)
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
QGetAudioContentCommentListItem(
|
||||||
|
audioContentComment.id,
|
||||||
|
audioContentComment.member.id,
|
||||||
|
audioContentComment.member.nickname,
|
||||||
|
audioContentComment.member.profileImage.prepend("/").prepend(cloudFrontHost),
|
||||||
|
audioContentComment.comment,
|
||||||
|
audioContentComment.isSecret,
|
||||||
|
blockMember.id.isNotNull,
|
||||||
|
audioContentComment.donationCan.coalesce(0),
|
||||||
|
formattedDate,
|
||||||
|
Expressions.constant(0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(audioContentComment)
|
||||||
|
.innerJoin(audioContentComment.member, member)
|
||||||
|
.leftJoin(blockMember)
|
||||||
|
.on(
|
||||||
|
member.id.eq(blockMember.blockedMember.id)
|
||||||
|
.and(blockMember.isActive.isTrue)
|
||||||
|
.and(blockMember.member.id.eq(memberId))
|
||||||
|
)
|
||||||
.where(
|
.where(
|
||||||
audioContentComment.parent.isNotNull
|
audioContentComment.parent.isNotNull
|
||||||
.and(audioContentComment.parent.id.eq(commentId))
|
.and(audioContentComment.parent.id.eq(commentId))
|
||||||
|
@ -147,29 +199,6 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
.limit(limit.toLong())
|
.limit(limit.toLong())
|
||||||
.orderBy(audioContentComment.createdAt.desc())
|
.orderBy(audioContentComment.createdAt.desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
.asSequence()
|
|
||||||
.map {
|
|
||||||
val date = it.createdAt!!
|
|
||||||
.atZone(ZoneId.of("UTC"))
|
|
||||||
.withZoneSameInstant(ZoneId.of(timezone))
|
|
||||||
|
|
||||||
GetAudioContentCommentListItem(
|
|
||||||
id = it.id!!,
|
|
||||||
writerId = it.member!!.id!!,
|
|
||||||
nickname = it.member!!.nickname,
|
|
||||||
profileUrl = if (it.member!!.profileImage != null) {
|
|
||||||
"$cloudFrontHost/${it.member!!.profileImage}"
|
|
||||||
} else {
|
|
||||||
"$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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.toList()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
override fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||||
|
|
|
@ -132,10 +132,16 @@ class AudioContentCommentService(
|
||||||
return GetAudioContentCommentListResponse(totalCount, commentList)
|
return GetAudioContentCommentListResponse(totalCount, commentList)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCommentReplyList(commentId: Long, timezone: String, pageable: Pageable): GetAudioContentCommentListResponse {
|
fun getCommentReplyList(
|
||||||
|
commentId: Long,
|
||||||
|
memberId: Long,
|
||||||
|
timezone: String,
|
||||||
|
pageable: Pageable
|
||||||
|
): GetAudioContentCommentListResponse {
|
||||||
val commentList = repository.getAudioContentCommentReplyList(
|
val commentList = repository.getAudioContentCommentReplyList(
|
||||||
cloudFrontHost = cloudFrontHost,
|
cloudFrontHost = cloudFrontHost,
|
||||||
commentId = commentId,
|
commentId = commentId,
|
||||||
|
memberId = memberId,
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
offset = pageable.offset,
|
offset = pageable.offset,
|
||||||
limit = pageable.pageSize
|
limit = pageable.pageSize
|
||||||
|
|
|
@ -14,7 +14,8 @@ data class GetAudioContentCommentListItem @QueryProjection constructor(
|
||||||
val profileUrl: String,
|
val profileUrl: String,
|
||||||
val comment: String,
|
val comment: String,
|
||||||
val isSecret: Boolean,
|
val isSecret: Boolean,
|
||||||
|
val isWriterBlock: Boolean,
|
||||||
val donationCan: Int,
|
val donationCan: Int,
|
||||||
val date: String,
|
val date: String,
|
||||||
val replyCount: Int
|
var replyCount: Int = 0
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue