크리에이터 프로필 조회 API에서 languageCode를 별도로 받던 것을 LangContext를 사용하도록 리팩토링
This commit is contained in:
@@ -52,7 +52,6 @@ class ExplorerController(private val service: ExplorerService) {
|
|||||||
fun getCreatorProfile(
|
fun getCreatorProfile(
|
||||||
@PathVariable("id") creatorId: Long,
|
@PathVariable("id") creatorId: Long,
|
||||||
@RequestParam timezone: String,
|
@RequestParam timezone: String,
|
||||||
@RequestParam("languageCode", required = false) languageCode: String? = null,
|
|
||||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
) = run {
|
) = run {
|
||||||
@@ -61,7 +60,6 @@ class ExplorerController(private val service: ExplorerService) {
|
|||||||
service.getCreatorProfile(
|
service.getCreatorProfile(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
languageCode = languageCode,
|
|
||||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
member = member
|
member = member
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.explorer.profile.PutWriteCheersRequest
|
|||||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunityService
|
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunityService
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||||
|
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||||
import kr.co.vividnext.sodalive.live.room.detail.GetRoomDetailUser
|
import kr.co.vividnext.sodalive.live.room.detail.GetRoomDetailUser
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import kr.co.vividnext.sodalive.member.MemberRole
|
import kr.co.vividnext.sodalive.member.MemberRole
|
||||||
@@ -49,6 +50,8 @@ class ExplorerService(
|
|||||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||||
private val contentTranslationRepository: ContentTranslationRepository,
|
private val contentTranslationRepository: ContentTranslationRepository,
|
||||||
|
|
||||||
|
private val langContext: LangContext,
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val cloudFrontHost: String
|
private val cloudFrontHost: String
|
||||||
) {
|
) {
|
||||||
@@ -172,7 +175,6 @@ class ExplorerService(
|
|||||||
fun getCreatorProfile(
|
fun getCreatorProfile(
|
||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
timezone: String,
|
timezone: String,
|
||||||
languageCode: String?,
|
|
||||||
isAdultContentVisible: Boolean,
|
isAdultContentVisible: Boolean,
|
||||||
member: Member
|
member: Member
|
||||||
): GetCreatorProfileResponse {
|
): GetCreatorProfileResponse {
|
||||||
@@ -235,24 +237,19 @@ class ExplorerService(
|
|||||||
listOf()
|
listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
val translatedContentList = if (!languageCode.isNullOrBlank() && contentList.isNotEmpty()) {
|
val contentIds = contentList.map { it.contentId }
|
||||||
val contentIds = contentList.map { it.contentId }
|
val translatedContentList = if (contentIds.isNotEmpty()) {
|
||||||
|
val translations = contentTranslationRepository
|
||||||
|
.findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code)
|
||||||
|
.associateBy { it.contentId }
|
||||||
|
|
||||||
if (contentIds.isNotEmpty()) {
|
contentList.map { item ->
|
||||||
val translations = contentTranslationRepository
|
val translatedTitle = translations[item.contentId]?.renderedPayload?.title
|
||||||
.findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode)
|
if (translatedTitle.isNullOrBlank()) {
|
||||||
.associateBy { it.contentId }
|
item
|
||||||
|
} else {
|
||||||
contentList.map { item ->
|
item.copy(title = translatedTitle)
|
||||||
val translatedTitle = translations[item.contentId]?.renderedPayload?.title
|
|
||||||
if (translatedTitle.isNullOrBlank()) {
|
|
||||||
item
|
|
||||||
} else {
|
|
||||||
item.copy(title = translatedTitle)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
contentList
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contentList
|
contentList
|
||||||
|
|||||||
Reference in New Issue
Block a user