크리에이터 프로필 조회 API에서 languageCode를 별도로 받던 것을 LangContext를 사용하도록 리팩토링
This commit is contained in:
@@ -52,7 +52,6 @@ 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 {
|
||||
@@ -61,7 +60,6 @@ class ExplorerController(private val service: ExplorerService) {
|
||||
service.getCreatorProfile(
|
||||
creatorId = creatorId,
|
||||
timezone = timezone,
|
||||
languageCode = languageCode,
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
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.fcm.FcmEvent
|
||||
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.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
@@ -49,6 +50,8 @@ class ExplorerService(
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
private val contentTranslationRepository: ContentTranslationRepository,
|
||||
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
) {
|
||||
@@ -172,7 +175,6 @@ class ExplorerService(
|
||||
fun getCreatorProfile(
|
||||
creatorId: Long,
|
||||
timezone: String,
|
||||
languageCode: String?,
|
||||
isAdultContentVisible: Boolean,
|
||||
member: Member
|
||||
): GetCreatorProfileResponse {
|
||||
@@ -235,24 +237,19 @@ class ExplorerService(
|
||||
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()) {
|
||||
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