diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerController.kt index b47792a..bf367df 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerController.kt @@ -52,6 +52,7 @@ class ExplorerController(private val service: ExplorerService) { fun getCreatorProfile( @PathVariable("id") creatorId: Long, @RequestParam timezone: String, + @RequestParam("languageCode", required = false) languageCode: String? = null, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? ) = run { @@ -60,6 +61,7 @@ class ExplorerController(private val service: ExplorerService) { service.getCreatorProfile( creatorId = creatorId, timezone = timezone, + languageCode = languageCode, isAdultContentVisible = isAdultContentVisible ?: true, member = member ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt index 4ca9dc0..73dd9e3 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt @@ -7,6 +7,7 @@ import kr.co.vividnext.sodalive.content.LanguageDetectEvent import kr.co.vividnext.sodalive.content.LanguageDetectTargetType import kr.co.vividnext.sodalive.content.SortType import kr.co.vividnext.sodalive.content.series.ContentSeriesService +import kr.co.vividnext.sodalive.content.translation.ContentTranslationRepository import kr.co.vividnext.sodalive.explorer.follower.GetFollowerListResponse import kr.co.vividnext.sodalive.explorer.follower.GetFollowerListResponseItem import kr.co.vividnext.sodalive.explorer.profile.ChannelNotice @@ -46,6 +47,7 @@ class ExplorerService( private val seriesService: ContentSeriesService, private val applicationEventPublisher: ApplicationEventPublisher, + private val contentTranslationRepository: ContentTranslationRepository, @Value("\${cloud.aws.cloud-front.host}") private val cloudFrontHost: String @@ -170,6 +172,7 @@ class ExplorerService( fun getCreatorProfile( creatorId: Long, timezone: String, + languageCode: String?, isAdultContentVisible: Boolean, member: Member ): GetCreatorProfileResponse { @@ -233,6 +236,29 @@ class ExplorerService( listOf() } + val translatedContentList = if (!languageCode.isNullOrBlank() && contentList.isNotEmpty()) { + val contentIds = contentList.map { it.contentId } + + if (contentIds.isNotEmpty()) { + val translations = contentTranslationRepository + .findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode) + .associateBy { it.contentId } + + contentList.map { item -> + val translatedTitle = translations[item.contentId]?.renderedPayload?.title + if (translatedTitle.isNullOrBlank()) { + item + } else { + item.copy(title = translatedTitle) + } + } + } else { + contentList + } + } else { + contentList + } + // 크리에이터의 최신 오디오 콘텐츠 1개 val latestContent = if (isCreator) { audioContentService.getLatestCreatorAudioContent(creatorId, member, isAdultContentVisible) @@ -333,7 +359,7 @@ class ExplorerService( userDonationRanking = memberDonationRanking, similarCreatorList = similarCreatorList, liveRoomList = liveRoomList, - contentList = contentList, + contentList = translatedContentList, latestContent = latestContent, totalContentCount = totalContentCount, ownedContentCount = ownedContentCount,