From 59949e5aeed31976c7f65c55c30400c554152b1d Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 12 Dec 2025 19:40:21 +0900 Subject: [PATCH] =?UTF-8?q?AudioContent=20=EC=A1=B0=ED=9A=8C=20API?= =?UTF-8?q?=EC=97=90=EC=84=9C=20api=20=EB=A7=88=EB=8B=A4=20languageCode?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=84=EB=8F=84=EB=A1=9C=20=EB=B0=9B=EB=8D=98=20?= =?UTF-8?q?=EA=B2=83=EC=9D=84=20LangContext=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/AudioContentController.kt | 10 +-- .../sodalive/content/AudioContentService.kt | 75 ++++++++----------- .../sodalive/explorer/ExplorerService.kt | 1 - 3 files changed, 33 insertions(+), 53 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt index 9c1f24f..5cddb91 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt @@ -108,7 +108,6 @@ class AudioContentController(private val service: AudioContentService) { @RequestParam("category-id", required = false) categoryId: Long? = 0, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @RequestParam("contentType", required = false) contentType: ContentType? = null, - @RequestParam("languageCode", required = false) languageCode: String? = null, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, pageable: Pageable ) = run { @@ -121,7 +120,6 @@ class AudioContentController(private val service: AudioContentService) { categoryId = categoryId ?: 0, isAdultContentVisible = isAdultContentVisible ?: true, contentType = contentType ?: ContentType.ALL, - languageCode = languageCode, member = member, offset = pageable.offset, limit = pageable.pageSize.toLong() @@ -133,7 +131,6 @@ class AudioContentController(private val service: AudioContentService) { fun getDetail( @PathVariable id: Long, @RequestParam timezone: String, - @RequestParam(required = false) languageCode: String? = null, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? ) = run { @@ -144,8 +141,7 @@ class AudioContentController(private val service: AudioContentService) { id = id, member = member, isAdultContentVisible = isAdultContentVisible ?: true, - timezone = timezone, - languageCode = languageCode + timezone = timezone ) ) } @@ -243,7 +239,6 @@ class AudioContentController(private val service: AudioContentService) { @GetMapping("/all") fun getAllContents( - @RequestParam("languageCode", required = false) languageCode: String? = null, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @RequestParam("contentType", required = false) contentType: ContentType? = null, @RequestParam("isFree", required = false) isFree: Boolean? = null, @@ -264,8 +259,7 @@ class AudioContentController(private val service: AudioContentService) { sortType = sortType ?: SortType.NEWEST, isFree = isFree ?: false, isAdult = (isAdultContentVisible ?: true) && member.auth != null, - isPointAvailableOnly = isPointAvailableOnly ?: false, - languageCode = languageCode + isPointAvailableOnly = isPointAvailableOnly ?: false ) ) } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt index f718319..bdc6122 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt @@ -29,6 +29,7 @@ import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository import kr.co.vividnext.sodalive.extensions.convertLocalDateTime import kr.co.vividnext.sodalive.fcm.FcmEvent import kr.co.vividnext.sodalive.fcm.FcmEventType +import kr.co.vividnext.sodalive.i18n.LangContext import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationEvent import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationTargetType import kr.co.vividnext.sodalive.i18n.translation.PapagoTranslationService @@ -72,6 +73,8 @@ class AudioContentService( private val audioContentCloudFront: AudioContentCloudFront, private val applicationEventPublisher: ApplicationEventPublisher, + private val langContext: LangContext, + @Value("\${cloud.aws.s3.content-bucket}") private val audioContentBucket: String, @@ -526,8 +529,7 @@ class AudioContentService( id: Long, member: Member, isAdultContentVisible: Boolean, - timezone: String, - languageCode: String? + timezone: String ): GetAudioContentDetailResponse { val isAdult = member.auth != null && isAdultContentVisible @@ -764,13 +766,10 @@ class AudioContentService( if ( audioContent.languageCode != null && audioContent.languageCode!!.isNotBlank() && - !languageCode.isNullOrBlank() && - audioContent.languageCode != languageCode + audioContent.languageCode != langContext.lang.code ) { - val locale = languageCode.lowercase() - val existing = contentTranslationRepository - .findByContentIdAndLocale(audioContent.id!!, locale) + .findByContentIdAndLocale(audioContent.id!!, langContext.lang.code) if (existing != null) { val payload = existing.renderedPayload @@ -791,7 +790,7 @@ class AudioContentService( request = TranslateRequest( texts = texts, sourceLanguage = sourceLanguage, - targetLanguage = locale + targetLanguage = langContext.lang.code ) ) @@ -812,7 +811,7 @@ class AudioContentService( contentTranslationRepository.save( ContentTranslation( contentId = audioContent.id!!, - locale = locale, + locale = langContext.lang.code, renderedPayload = payload ) ) @@ -928,7 +927,6 @@ class AudioContentService( categoryId: Long = 0, isAdultContentVisible: Boolean, contentType: ContentType, - languageCode: String?, offset: Long, limit: Long ): GetAudioContentListResponse { @@ -982,24 +980,19 @@ class AudioContentService( it } - val translatedContentList = if (!languageCode.isNullOrBlank()) { - val contentIds = items.map { it.contentId } + val contentIds = items.map { it.contentId } + val translatedContentList = if (contentIds.isNotEmpty()) { + val translations = contentTranslationRepository + .findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code) + .associateBy { it.contentId } - if (contentIds.isNotEmpty()) { - val translations = contentTranslationRepository - .findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode) - .associateBy { it.contentId } - - items.map { item -> - val translatedTitle = translations[item.contentId]?.renderedPayload?.title - if (translatedTitle.isNullOrBlank()) { - item - } else { - item.copy(title = translatedTitle) - } + items.map { item -> + val translatedTitle = translations[item.contentId]?.renderedPayload?.title + if (translatedTitle.isNullOrBlank()) { + item + } else { + item.copy(title = translatedTitle) } - } else { - items } } else { items @@ -1145,8 +1138,7 @@ class AudioContentService( isFree: Boolean = false, isAdult: Boolean = false, orderByRandom: Boolean = false, - isPointAvailableOnly: Boolean = false, - languageCode: String? = null + isPointAvailableOnly: Boolean = false ): List { val contentList = repository.getLatestContentByTheme( theme = theme, @@ -1160,24 +1152,19 @@ class AudioContentService( isPointAvailableOnly = isPointAvailableOnly ) - return if (!languageCode.isNullOrBlank()) { - val contentIds = contentList.map { it.contentId } + val contentIds = contentList.map { it.contentId } + return if (contentIds.isNotEmpty()) { + val translations = contentTranslationRepository + .findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code) + .associateBy { 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) - } + contentList.map { item -> + val translatedTitle = translations[item.contentId]?.renderedPayload?.title + if (translatedTitle.isNullOrBlank()) { + item + } else { + item.copy(title = translatedTitle) } - } else { - contentList } } else { contentList 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 73dd9e3..083ab78 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt @@ -227,7 +227,6 @@ class ExplorerService( sortType = SortType.NEWEST, isAdultContentVisible = isAdultContentVisible, contentType = ContentType.ALL, - languageCode = null, member = member, offset = 0, limit = 3