콘텐츠 전체보기 API - languageCode에 따라 번역 데이터 조회
This commit is contained in:
@@ -108,6 +108,7 @@ class AudioContentController(private val service: AudioContentService) {
|
|||||||
@RequestParam("category-id", required = false) categoryId: Long? = 0,
|
@RequestParam("category-id", required = false) categoryId: Long? = 0,
|
||||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@RequestParam("languageCode", required = false) languageCode: String? = null,
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
pageable: Pageable
|
pageable: Pageable
|
||||||
) = run {
|
) = run {
|
||||||
@@ -120,6 +121,7 @@ class AudioContentController(private val service: AudioContentService) {
|
|||||||
categoryId = categoryId ?: 0,
|
categoryId = categoryId ?: 0,
|
||||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
contentType = contentType ?: ContentType.ALL,
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
languageCode = languageCode,
|
||||||
member = member,
|
member = member,
|
||||||
offset = pageable.offset,
|
offset = pageable.offset,
|
||||||
limit = pageable.pageSize.toLong()
|
limit = pageable.pageSize.toLong()
|
||||||
@@ -241,6 +243,7 @@ class AudioContentController(private val service: AudioContentService) {
|
|||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
fun getAllContents(
|
fun getAllContents(
|
||||||
|
@RequestParam("languageCode", required = false) languageCode: String? = null,
|
||||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||||
@@ -261,7 +264,8 @@ class AudioContentController(private val service: AudioContentService) {
|
|||||||
sortType = sortType ?: SortType.NEWEST,
|
sortType = sortType ?: SortType.NEWEST,
|
||||||
isFree = isFree ?: false,
|
isFree = isFree ?: false,
|
||||||
isAdult = (isAdultContentVisible ?: true) && member.auth != null,
|
isAdult = (isAdultContentVisible ?: true) && member.auth != null,
|
||||||
isPointAvailableOnly = isPointAvailableOnly ?: false
|
isPointAvailableOnly = isPointAvailableOnly ?: false,
|
||||||
|
languageCode = languageCode
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -928,6 +928,7 @@ class AudioContentService(
|
|||||||
categoryId: Long = 0,
|
categoryId: Long = 0,
|
||||||
isAdultContentVisible: Boolean,
|
isAdultContentVisible: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
|
languageCode: String?,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): GetAudioContentListResponse {
|
): GetAudioContentListResponse {
|
||||||
@@ -981,9 +982,32 @@ class AudioContentService(
|
|||||||
it
|
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(
|
return GetAudioContentListResponse(
|
||||||
totalCount = totalCount,
|
totalCount = totalCount,
|
||||||
items = items
|
items = translatedContentList
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1121,9 +1145,10 @@ class AudioContentService(
|
|||||||
isFree: Boolean = false,
|
isFree: Boolean = false,
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
orderByRandom: Boolean = false,
|
orderByRandom: Boolean = false,
|
||||||
isPointAvailableOnly: Boolean = false
|
isPointAvailableOnly: Boolean = false,
|
||||||
|
languageCode: String? = null
|
||||||
): List<AudioContentMainItem> {
|
): List<AudioContentMainItem> {
|
||||||
return repository.getLatestContentByTheme(
|
val contentList = repository.getLatestContentByTheme(
|
||||||
theme = theme,
|
theme = theme,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
offset = offset,
|
offset = offset,
|
||||||
@@ -1134,5 +1159,28 @@ class AudioContentService(
|
|||||||
orderByRandom = orderByRandom,
|
orderByRandom = orderByRandom,
|
||||||
isPointAvailableOnly = isPointAvailableOnly
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ class AudioContentMainController(
|
|||||||
@GetMapping("/new/all")
|
@GetMapping("/new/all")
|
||||||
fun getNewContentAllByTheme(
|
fun getNewContentAllByTheme(
|
||||||
@RequestParam("theme") theme: String,
|
@RequestParam("theme") theme: String,
|
||||||
|
@RequestParam("languageCode", required = false) languageCode: String? = null,
|
||||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
@@ -112,6 +113,7 @@ class AudioContentMainController(
|
|||||||
theme = theme,
|
theme = theme,
|
||||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||||
contentType = contentType ?: ContentType.ALL,
|
contentType = contentType ?: ContentType.ALL,
|
||||||
|
languageCode = languageCode,
|
||||||
member = member,
|
member = member,
|
||||||
pageable = pageable
|
pageable = pageable
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerType
|
|||||||
import kr.co.vividnext.sodalive.content.main.banner.GetAudioContentBannerResponse
|
import kr.co.vividnext.sodalive.content.main.banner.GetAudioContentBannerResponse
|
||||||
import kr.co.vividnext.sodalive.content.main.curation.GetAudioContentCurationResponse
|
import kr.co.vividnext.sodalive.content.main.curation.GetAudioContentCurationResponse
|
||||||
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeQueryRepository
|
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.event.EventItem
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||||
@@ -21,6 +22,8 @@ class AudioContentMainService(
|
|||||||
private val blockMemberRepository: BlockMemberRepository,
|
private val blockMemberRepository: BlockMemberRepository,
|
||||||
private val audioContentThemeRepository: AudioContentThemeQueryRepository,
|
private val audioContentThemeRepository: AudioContentThemeQueryRepository,
|
||||||
|
|
||||||
|
private val contentTranslationRepository: ContentTranslationRepository,
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val imageHost: String
|
private val imageHost: String
|
||||||
) {
|
) {
|
||||||
@@ -57,6 +60,7 @@ class AudioContentMainService(
|
|||||||
theme: String,
|
theme: String,
|
||||||
isAdultContentVisible: Boolean,
|
isAdultContentVisible: Boolean,
|
||||||
contentType: ContentType,
|
contentType: ContentType,
|
||||||
|
languageCode: String?,
|
||||||
member: Member,
|
member: Member,
|
||||||
pageable: Pageable
|
pageable: Pageable
|
||||||
): GetNewContentAllResponse {
|
): GetNewContentAllResponse {
|
||||||
@@ -76,7 +80,7 @@ class AudioContentMainService(
|
|||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
contentType = contentType
|
contentType = contentType
|
||||||
)
|
)
|
||||||
val items = repository.findByThemeFor2Weeks(
|
val contentList = repository.findByThemeFor2Weeks(
|
||||||
cloudfrontHost = imageHost,
|
cloudfrontHost = imageHost,
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
theme = themeList,
|
theme = themeList,
|
||||||
@@ -87,7 +91,30 @@ class AudioContentMainService(
|
|||||||
)
|
)
|
||||||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||||
|
|
||||||
return GetNewContentAllResponse(totalCount, items)
|
val translatedContentList = 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
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetNewContentAllResponse(totalCount, translatedContentList)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
|
|||||||
Reference in New Issue
Block a user