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("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 {
@@ -121,7 +120,6 @@ 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()
@@ -133,7 +131,6 @@ class AudioContentController(private val service: AudioContentService) {
fun getDetail( fun getDetail(
@PathVariable id: Long, @PathVariable id: Long,
@RequestParam timezone: String, @RequestParam timezone: String,
@RequestParam(required = false) languageCode: String? = null,
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run { ) = run {
@@ -144,8 +141,7 @@ class AudioContentController(private val service: AudioContentService) {
id = id, id = id,
member = member, member = member,
isAdultContentVisible = isAdultContentVisible ?: true, isAdultContentVisible = isAdultContentVisible ?: true,
timezone = timezone, timezone = timezone
languageCode = languageCode
) )
) )
} }
@@ -243,7 +239,6 @@ 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,
@@ -264,8 +259,7 @@ 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
) )
) )
} }

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.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.fcm.FcmEvent import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType 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.LanguageTranslationEvent
import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationTargetType import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationTargetType
import kr.co.vividnext.sodalive.i18n.translation.PapagoTranslationService import kr.co.vividnext.sodalive.i18n.translation.PapagoTranslationService
@@ -72,6 +73,8 @@ class AudioContentService(
private val audioContentCloudFront: AudioContentCloudFront, private val audioContentCloudFront: AudioContentCloudFront,
private val applicationEventPublisher: ApplicationEventPublisher, private val applicationEventPublisher: ApplicationEventPublisher,
private val langContext: LangContext,
@Value("\${cloud.aws.s3.content-bucket}") @Value("\${cloud.aws.s3.content-bucket}")
private val audioContentBucket: String, private val audioContentBucket: String,
@@ -526,8 +529,7 @@ class AudioContentService(
id: Long, id: Long,
member: Member, member: Member,
isAdultContentVisible: Boolean, isAdultContentVisible: Boolean,
timezone: String, timezone: String
languageCode: String?
): GetAudioContentDetailResponse { ): GetAudioContentDetailResponse {
val isAdult = member.auth != null && isAdultContentVisible val isAdult = member.auth != null && isAdultContentVisible
@@ -764,13 +766,10 @@ class AudioContentService(
if ( if (
audioContent.languageCode != null && audioContent.languageCode != null &&
audioContent.languageCode!!.isNotBlank() && audioContent.languageCode!!.isNotBlank() &&
!languageCode.isNullOrBlank() && audioContent.languageCode != langContext.lang.code
audioContent.languageCode != languageCode
) { ) {
val locale = languageCode.lowercase()
val existing = contentTranslationRepository val existing = contentTranslationRepository
.findByContentIdAndLocale(audioContent.id!!, locale) .findByContentIdAndLocale(audioContent.id!!, langContext.lang.code)
if (existing != null) { if (existing != null) {
val payload = existing.renderedPayload val payload = existing.renderedPayload
@@ -791,7 +790,7 @@ class AudioContentService(
request = TranslateRequest( request = TranslateRequest(
texts = texts, texts = texts,
sourceLanguage = sourceLanguage, sourceLanguage = sourceLanguage,
targetLanguage = locale targetLanguage = langContext.lang.code
) )
) )
@@ -812,7 +811,7 @@ class AudioContentService(
contentTranslationRepository.save( contentTranslationRepository.save(
ContentTranslation( ContentTranslation(
contentId = audioContent.id!!, contentId = audioContent.id!!,
locale = locale, locale = langContext.lang.code,
renderedPayload = payload renderedPayload = payload
) )
) )
@@ -928,7 +927,6 @@ 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 {
@@ -982,12 +980,10 @@ class AudioContentService(
it it
} }
val translatedContentList = if (!languageCode.isNullOrBlank()) {
val contentIds = items.map { it.contentId } val contentIds = items.map { it.contentId }
val translatedContentList = if (contentIds.isNotEmpty()) {
if (contentIds.isNotEmpty()) {
val translations = contentTranslationRepository val translations = contentTranslationRepository
.findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode) .findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code)
.associateBy { it.contentId } .associateBy { it.contentId }
items.map { item -> items.map { item ->
@@ -1001,9 +997,6 @@ class AudioContentService(
} else { } else {
items items
} }
} else {
items
}
return GetAudioContentListResponse( return GetAudioContentListResponse(
totalCount = totalCount, totalCount = totalCount,
@@ -1145,8 +1138,7 @@ 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> {
val contentList = repository.getLatestContentByTheme( val contentList = repository.getLatestContentByTheme(
theme = theme, theme = theme,
@@ -1160,12 +1152,10 @@ class AudioContentService(
isPointAvailableOnly = isPointAvailableOnly isPointAvailableOnly = isPointAvailableOnly
) )
return if (!languageCode.isNullOrBlank()) {
val contentIds = contentList.map { it.contentId } val contentIds = contentList.map { it.contentId }
return if (contentIds.isNotEmpty()) {
if (contentIds.isNotEmpty()) {
val translations = contentTranslationRepository val translations = contentTranslationRepository
.findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode) .findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code)
.associateBy { it.contentId } .associateBy { it.contentId }
contentList.map { item -> contentList.map { item ->
@@ -1179,8 +1169,5 @@ class AudioContentService(
} else { } else {
contentList contentList
} }
} else {
contentList
}
} }
} }

View File

@@ -100,7 +100,6 @@ 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?,
@@ -113,7 +112,6 @@ 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
) )

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.theme.AudioContentThemeQueryRepository
import kr.co.vividnext.sodalive.content.translation.ContentTranslationRepository 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.i18n.LangContext
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
import org.springframework.beans.factory.annotation.Value import org.springframework.beans.factory.annotation.Value
@@ -24,6 +25,8 @@ class AudioContentMainService(
private val contentTranslationRepository: ContentTranslationRepository, private val contentTranslationRepository: ContentTranslationRepository,
private val langContext: LangContext,
@Value("\${cloud.aws.cloud-front.host}") @Value("\${cloud.aws.cloud-front.host}")
private val imageHost: String private val imageHost: String
) { ) {
@@ -60,7 +63,6 @@ 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 {
@@ -91,12 +93,10 @@ class AudioContentMainService(
) )
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } .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()) {
if (contentIds.isNotEmpty()) {
val translations = contentTranslationRepository val translations = contentTranslationRepository
.findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode) .findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code)
.associateBy { it.contentId } .associateBy { it.contentId }
contentList.map { item -> contentList.map { item ->
@@ -110,9 +110,6 @@ class AudioContentMainService(
} else { } else {
contentList contentList
} }
} else {
contentList
}
return GetNewContentAllResponse(totalCount, translatedContentList) return GetNewContentAllResponse(totalCount, translatedContentList)
} }

View File

@@ -52,7 +52,6 @@ class ExplorerController(private val service: ExplorerService) {
fun getCreatorProfile( fun getCreatorProfile(
@PathVariable("id") creatorId: Long, @PathVariable("id") creatorId: Long,
@RequestParam timezone: String, @RequestParam timezone: String,
@RequestParam("languageCode", required = false) languageCode: String? = null,
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run { ) = run {
@@ -61,7 +60,6 @@ class ExplorerController(private val service: ExplorerService) {
service.getCreatorProfile( service.getCreatorProfile(
creatorId = creatorId, creatorId = creatorId,
timezone = timezone, timezone = timezone,
languageCode = languageCode,
isAdultContentVisible = isAdultContentVisible ?: true, isAdultContentVisible = isAdultContentVisible ?: true,
member = member 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.explorer.profile.creatorCommunity.CreatorCommunityService
import kr.co.vividnext.sodalive.fcm.FcmEvent import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType 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.live.room.detail.GetRoomDetailUser
import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.Member
import kr.co.vividnext.sodalive.member.MemberRole import kr.co.vividnext.sodalive.member.MemberRole
@@ -49,6 +50,8 @@ class ExplorerService(
private val applicationEventPublisher: ApplicationEventPublisher, private val applicationEventPublisher: ApplicationEventPublisher,
private val contentTranslationRepository: ContentTranslationRepository, private val contentTranslationRepository: ContentTranslationRepository,
private val langContext: LangContext,
@Value("\${cloud.aws.cloud-front.host}") @Value("\${cloud.aws.cloud-front.host}")
private val cloudFrontHost: String private val cloudFrontHost: String
) { ) {
@@ -172,7 +175,6 @@ class ExplorerService(
fun getCreatorProfile( fun getCreatorProfile(
creatorId: Long, creatorId: Long,
timezone: String, timezone: String,
languageCode: String?,
isAdultContentVisible: Boolean, isAdultContentVisible: Boolean,
member: Member member: Member
): GetCreatorProfileResponse { ): GetCreatorProfileResponse {
@@ -227,7 +229,6 @@ class ExplorerService(
sortType = SortType.NEWEST, sortType = SortType.NEWEST,
isAdultContentVisible = isAdultContentVisible, isAdultContentVisible = isAdultContentVisible,
contentType = ContentType.ALL, contentType = ContentType.ALL,
languageCode = null,
member = member, member = member,
offset = 0, offset = 0,
limit = 3 limit = 3
@@ -236,12 +237,10 @@ class ExplorerService(
listOf() 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()) {
if (contentIds.isNotEmpty()) {
val translations = contentTranslationRepository val translations = contentTranslationRepository
.findByContentIdInAndLocale(contentIds = contentIds, locale = languageCode) .findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code)
.associateBy { it.contentId } .associateBy { it.contentId }
contentList.map { item -> contentList.map { item ->
@@ -255,9 +254,6 @@ class ExplorerService(
} else { } else {
contentList contentList
} }
} else {
contentList
}
// 크리에이터의 최신 오디오 콘텐츠 1개 // 크리에이터의 최신 오디오 콘텐츠 1개
val latestContent = if (isCreator) { val latestContent = if (isCreator) {