신규 콘텐츠 조회 API에서 languageCode를 별도로 받던 것을 LangContext를 사용하도록 리팩토링
This commit is contained in:
@@ -100,7 +100,6 @@ class AudioContentMainController(
|
||||
@GetMapping("/new/all")
|
||||
fun getNewContentAllByTheme(
|
||||
@RequestParam("theme") theme: String,
|
||||
@RequestParam("languageCode", required = false) languageCode: String? = null,
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@@ -113,7 +112,6 @@ class AudioContentMainController(
|
||||
theme = theme,
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
languageCode = languageCode,
|
||||
member = member,
|
||||
pageable = pageable
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@ import kr.co.vividnext.sodalive.content.main.curation.GetAudioContentCurationRes
|
||||
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeQueryRepository
|
||||
import kr.co.vividnext.sodalive.content.translation.ContentTranslationRepository
|
||||
import kr.co.vividnext.sodalive.event.EventItem
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
@@ -24,6 +25,8 @@ class AudioContentMainService(
|
||||
|
||||
private val contentTranslationRepository: ContentTranslationRepository,
|
||||
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val imageHost: String
|
||||
) {
|
||||
@@ -60,7 +63,6 @@ class AudioContentMainService(
|
||||
theme: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
languageCode: String?,
|
||||
member: Member,
|
||||
pageable: Pageable
|
||||
): GetNewContentAllResponse {
|
||||
@@ -91,24 +93,19 @@ class AudioContentMainService(
|
||||
)
|
||||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||
|
||||
val translatedContentList = if (!languageCode.isNullOrBlank()) {
|
||||
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()) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user