Compare commits

...

3 Commits

6 changed files with 61 additions and 91 deletions

View File

@@ -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
)
)
}

View File

@@ -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<AudioContentMainItem> {
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

View File

@@ -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
)

View File

@@ -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

View File

@@ -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
)

View File

@@ -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 {
@@ -227,7 +229,6 @@ class ExplorerService(
sortType = SortType.NEWEST,
isAdultContentVisible = isAdultContentVisible,
contentType = ContentType.ALL,
languageCode = null,
member = member,
offset = 0,
limit = 3
@@ -236,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