Compare commits

..

No commits in common. "da3175292b0f4c23bb4cad067f7e8b07858b725e" and "dd229f15acf91a3b730316469ce6dff81b5fb5eb" have entirely different histories.

5 changed files with 50 additions and 87 deletions

View File

@ -166,7 +166,7 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
.and(useCan.createdAt.loe(endDate))
)
.groupBy(donationFormattedDate, audioContent.id)
.orderBy(member.id.asc(), donationFormattedDate.desc(), audioContent.id.desc())
.orderBy(member.id.asc(), donationFormattedDate.desc())
.fetch()
}
@ -219,7 +219,7 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
.and(useCan.createdAt.loe(endDate))
)
.groupBy(formattedDate, creatorCommunity.id, creatorSettlementRatio.communitySettlementRatio)
.orderBy(member.id.asc(), formattedDate.desc(), creatorCommunity.id.desc())
.orderBy(member.id.asc(), formattedDate.desc())
.offset(offset)
.limit(limit)
.fetch()

View File

@ -74,7 +74,6 @@ class AudioContentCommentController(private val service: AudioContentCommentServ
return ApiResponse.ok(
service.getCommentReplyList(
commentId = commentId,
memberId = member.id!!,
timezone = timezone,
pageable = pageable
)

View File

@ -1,14 +1,13 @@
package kr.co.vividnext.sodalive.content.comment
import com.querydsl.core.types.dsl.Expressions
import com.querydsl.jpa.impl.JPAQueryFactory
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
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.stereotype.Repository
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
@Repository
interface AudioContentCommentRepository : JpaRepository<AudioContentComment, Long>, AudioContentCommentQueryRepository
@ -29,7 +28,6 @@ interface AudioContentCommentQueryRepository {
fun getAudioContentCommentReplyList(
cloudFrontHost: String,
commentId: Long,
memberId: Long,
timezone: String,
offset: Long,
limit: Int
@ -66,50 +64,35 @@ 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
.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)
.selectFrom(audioContentComment)
.innerJoin(audioContentComment.audioContent, audioContent)
.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)
.offset(offset)
.limit(limit.toLong())
.orderBy(audioContentComment.createdAt.desc())
.fetch()
.map {
it.replyCount = commentReplyCountByAudioContentCommentId(it.id)
it
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 = commentReplyCountByAudioContentCommentId(it.id!!)
)
}
}
@ -150,46 +133,11 @@ class AudioContentCommentQueryRepositoryImpl(
override fun getAudioContentCommentReplyList(
cloudFrontHost: String,
commentId: Long,
memberId: Long,
timezone: String,
offset: Long,
limit: Int
): List<GetAudioContentCommentListItem> {
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))
)
return queryFactory.selectFrom(audioContentComment)
.where(
audioContentComment.parent.isNotNull
.and(audioContentComment.parent.id.eq(commentId))
@ -199,6 +147,29 @@ class AudioContentCommentQueryRepositoryImpl(
.limit(limit.toLong())
.orderBy(audioContentComment.createdAt.desc())
.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(

View File

@ -132,16 +132,10 @@ class AudioContentCommentService(
return GetAudioContentCommentListResponse(totalCount, commentList)
}
fun getCommentReplyList(
commentId: Long,
memberId: Long,
timezone: String,
pageable: Pageable
): GetAudioContentCommentListResponse {
fun getCommentReplyList(commentId: Long, timezone: String, pageable: Pageable): GetAudioContentCommentListResponse {
val commentList = repository.getAudioContentCommentReplyList(
cloudFrontHost = cloudFrontHost,
commentId = commentId,
memberId = memberId,
timezone = timezone,
offset = pageable.offset,
limit = pageable.pageSize

View File

@ -14,8 +14,7 @@ data class GetAudioContentCommentListItem @QueryProjection constructor(
val profileUrl: String,
val comment: String,
val isSecret: Boolean,
val isWriterBlock: Boolean,
val donationCan: Int,
val date: String,
var replyCount: Int = 0
val replyCount: Int
)