feat(creatorname): 레거시 조회와 검색에 언어별 이름을 적용한다
This commit is contained in:
+7
-3
@@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.comment
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.useraction.ActionType
|
||||
import kr.co.vividnext.sodalive.useraction.UserActionService
|
||||
@@ -18,7 +19,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||
@RestController
|
||||
class AudioContentCommentController(
|
||||
private val service: AudioContentCommentService,
|
||||
private val userActionService: UserActionService
|
||||
private val userActionService: UserActionService,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
@PostMapping("/audio-content/comment")
|
||||
fun registerComment(
|
||||
@@ -79,7 +81,8 @@ class AudioContentCommentController(
|
||||
audioContentId = audioContentId,
|
||||
memberId = member.id!!,
|
||||
timezone = timezone,
|
||||
pageable = pageable
|
||||
pageable = pageable,
|
||||
lang = langContext.lang
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -98,7 +101,8 @@ class AudioContentCommentController(
|
||||
commentId = commentId,
|
||||
memberId = member.id!!,
|
||||
timezone = timezone,
|
||||
pageable = pageable
|
||||
pageable = pageable,
|
||||
lang = langContext.lang
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+27
-15
@@ -1,16 +1,18 @@
|
||||
package kr.co.vividnext.sodalive.content.comment
|
||||
|
||||
import com.querydsl.core.types.dsl.CaseBuilder
|
||||
import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.jpa.JPAExpressions
|
||||
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.extensions.removeDeletedNicknamePrefix
|
||||
import kr.co.vividnext.sodalive.fcm.PushTokenInfo
|
||||
import kr.co.vividnext.sodalive.fcm.QPushToken.pushToken
|
||||
import kr.co.vividnext.sodalive.fcm.QPushTokenInfo
|
||||
import kr.co.vividnext.sodalive.i18n.Lang
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import kr.co.vividnext.sodalive.member.block.QBlockMember.blockMember
|
||||
import kr.co.vividnext.sodalive.v2.creatorname.adapter.out.persistence.CreatorNameJoin
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.LocalDateTime
|
||||
@@ -26,7 +28,8 @@ interface AudioContentCommentQueryRepository {
|
||||
isContentCreator: Boolean,
|
||||
timezone: String,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
lang: Lang? = null
|
||||
): List<GetAudioContentCommentListItem>
|
||||
|
||||
fun totalCountCommentByContentId(contentId: Long, memberId: Long, isContentCreator: Boolean): Int
|
||||
@@ -37,7 +40,8 @@ interface AudioContentCommentQueryRepository {
|
||||
memberId: Long,
|
||||
timezone: String,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
lang: Lang? = null
|
||||
): List<GetAudioContentCommentListItem>
|
||||
|
||||
fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||
@@ -58,8 +62,13 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
isContentCreator: Boolean,
|
||||
timezone: String,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
lang: Lang?
|
||||
): List<GetAudioContentCommentListItem> {
|
||||
val creatorName = lang?.let { CreatorNameJoin(member, it, "audioCommentWriterName") }
|
||||
val originalName = CaseBuilder().`when`(member.nickname.startsWith("deleted_"))
|
||||
.then(member.nickname.substring(8)).otherwise(member.nickname)
|
||||
val displayName = creatorName?.name?.displayName?.coalesce(originalName) ?: originalName
|
||||
var where = audioContentComment.audioContent.id.eq(contentId)
|
||||
.and(audioContentComment.isActive.isTrue)
|
||||
.and(audioContentComment.parent.isNull)
|
||||
@@ -85,12 +94,12 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
"%Y.%m.%d %W %h:%i %p"
|
||||
)
|
||||
|
||||
return queryFactory
|
||||
val query = queryFactory
|
||||
.select(
|
||||
QGetAudioContentCommentListItem(
|
||||
audioContentComment.id,
|
||||
audioContentComment.member.id,
|
||||
audioContentComment.member.nickname,
|
||||
displayName,
|
||||
audioContentComment.member.profileImage.prepend("/").prepend(cloudFrontHost),
|
||||
audioContentComment.comment,
|
||||
audioContentComment.languageCode,
|
||||
@@ -107,10 +116,10 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
.offset(offset)
|
||||
.limit(limit.toLong())
|
||||
.orderBy(audioContentComment.createdAt.desc())
|
||||
.fetch()
|
||||
if (creatorName != null) query.leftJoin(creatorName.name).on(creatorName.condition)
|
||||
return query.fetch()
|
||||
.map {
|
||||
it.copy(
|
||||
nickname = it.nickname.removeDeletedNicknamePrefix(),
|
||||
replyCount = commentReplyCountByAudioContentCommentId(it.id, memberId)
|
||||
)
|
||||
}
|
||||
@@ -160,8 +169,13 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
memberId: Long,
|
||||
timezone: String,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
lang: Lang?
|
||||
): List<GetAudioContentCommentListItem> {
|
||||
val creatorName = lang?.let { CreatorNameJoin(member, it, "audioReplyWriterName") }
|
||||
val originalName = CaseBuilder().`when`(member.nickname.startsWith("deleted_"))
|
||||
.then(member.nickname.substring(8)).otherwise(member.nickname)
|
||||
val displayName = creatorName?.name?.displayName?.coalesce(originalName) ?: originalName
|
||||
val formattedDate = Expressions.stringTemplate(
|
||||
"DATE_FORMAT({0}, {1})",
|
||||
Expressions.dateTimeTemplate(
|
||||
@@ -174,12 +188,12 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
"%Y.%m.%d %W %h:%i %p"
|
||||
)
|
||||
|
||||
return queryFactory
|
||||
val query = queryFactory
|
||||
.select(
|
||||
QGetAudioContentCommentListItem(
|
||||
audioContentComment.id,
|
||||
audioContentComment.member.id,
|
||||
audioContentComment.member.nickname,
|
||||
displayName,
|
||||
audioContentComment.member.profileImage.prepend("/").prepend(cloudFrontHost),
|
||||
audioContentComment.comment,
|
||||
audioContentComment.languageCode,
|
||||
@@ -201,10 +215,8 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||
.offset(offset)
|
||||
.limit(limit.toLong())
|
||||
.orderBy(audioContentComment.createdAt.desc())
|
||||
.fetch()
|
||||
.map {
|
||||
it.copy(nickname = it.nickname.removeDeletedNicknamePrefix())
|
||||
}
|
||||
if (creatorName != null) query.leftJoin(creatorName.name).on(creatorName.condition)
|
||||
return query.fetch()
|
||||
}
|
||||
|
||||
override fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||
|
||||
+15
-5
@@ -9,10 +9,12 @@ import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||
import kr.co.vividnext.sodalive.fcm.notification.PushNotificationCategory
|
||||
import kr.co.vividnext.sodalive.i18n.Lang
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import kr.co.vividnext.sodalive.v2.creatorname.application.CreatorLocalizedNameService
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.data.domain.Pageable
|
||||
@@ -30,6 +32,7 @@ class AudioContentCommentService(
|
||||
private val orderRepository: OrderRepository,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
private val localizedNameService: CreatorLocalizedNameService,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
@@ -49,7 +52,9 @@ class AudioContentCommentService(
|
||||
val creator = audioContent.member!!
|
||||
val isBlocked = isBlockedBetweenMembers(memberId = member.id!!, creatorId = creator.id!!)
|
||||
if (isBlocked) {
|
||||
throw SodaException(formatMessage("content.comment.error.blocked_by_creator", creator.nickname))
|
||||
val name = localizedNameService.findLocalizedNames(listOf(creator.id!!), langContext.lang)[creator.id]
|
||||
?: creator.nickname
|
||||
throw SodaException(formatMessage("content.comment.error.blocked_by_creator", name))
|
||||
}
|
||||
|
||||
val (isExistsAudioContent, _) = orderRepository.isExistOrderedAndOrderType(
|
||||
@@ -86,6 +91,7 @@ class AudioContentCommentService(
|
||||
} else {
|
||||
member.nickname
|
||||
},
|
||||
titleMemberId = parent?.member?.id ?: member.id,
|
||||
messageKey = if (parent != null) {
|
||||
"content.comment.notification.reply"
|
||||
} else {
|
||||
@@ -140,7 +146,8 @@ class AudioContentCommentService(
|
||||
audioContentId: Long,
|
||||
memberId: Long,
|
||||
timezone: String,
|
||||
pageable: Pageable
|
||||
pageable: Pageable,
|
||||
lang: Lang? = null
|
||||
): GetAudioContentCommentListResponse {
|
||||
val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId)
|
||||
?: return GetAudioContentCommentListResponse(totalCount = 0, items = listOf())
|
||||
@@ -157,7 +164,8 @@ class AudioContentCommentService(
|
||||
isContentCreator = isContentCreator,
|
||||
timezone = timezone,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize
|
||||
limit = pageable.pageSize,
|
||||
lang = lang
|
||||
)
|
||||
val totalCount = repository.totalCountCommentByContentId(
|
||||
contentId = audioContentId,
|
||||
@@ -172,7 +180,8 @@ class AudioContentCommentService(
|
||||
commentId: Long,
|
||||
memberId: Long,
|
||||
timezone: String,
|
||||
pageable: Pageable
|
||||
pageable: Pageable,
|
||||
lang: Lang? = null
|
||||
): GetAudioContentCommentListResponse {
|
||||
val parentComment = repository.findByIdOrNull(id = commentId)
|
||||
?: return GetAudioContentCommentListResponse(totalCount = 0, items = listOf())
|
||||
@@ -187,7 +196,8 @@ class AudioContentCommentService(
|
||||
memberId = memberId,
|
||||
timezone = timezone,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize
|
||||
limit = pageable.pageSize,
|
||||
lang = lang
|
||||
)
|
||||
val totalCount = repository.commentReplyCountByAudioContentCommentId(commentId, memberId)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user