콘텐츠 전체보기 API - languageCode에 따라 번역 데이터 조회

This commit is contained in:
2025-12-12 05:57:04 +09:00
parent 8fec60db11
commit 7ab25470b6
4 changed files with 87 additions and 6 deletions

View File

@@ -928,6 +928,7 @@ class AudioContentService(
categoryId: Long = 0,
isAdultContentVisible: Boolean,
contentType: ContentType,
languageCode: String?,
offset: Long,
limit: Long
): GetAudioContentListResponse {
@@ -981,9 +982,32 @@ class AudioContentService(
it
}
val translatedContentList = if (!languageCode.isNullOrBlank()) {
val contentIds = items.map { 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)
}
}
} else {
items
}
} else {
items
}
return GetAudioContentListResponse(
totalCount = totalCount,
items = items
items = translatedContentList
)
}
@@ -1121,9 +1145,10 @@ class AudioContentService(
isFree: Boolean = false,
isAdult: Boolean = false,
orderByRandom: Boolean = false,
isPointAvailableOnly: Boolean = false
isPointAvailableOnly: Boolean = false,
languageCode: String? = null
): List<AudioContentMainItem> {
return repository.getLatestContentByTheme(
val contentList = repository.getLatestContentByTheme(
theme = theme,
contentType = contentType,
offset = offset,
@@ -1134,5 +1159,28 @@ class AudioContentService(
orderByRandom = orderByRandom,
isPointAvailableOnly = isPointAvailableOnly
)
return if (!languageCode.isNullOrBlank()) {
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
}
}
}