번역 제목 조회 방식 수정

This commit is contained in:
2026-02-13 16:37:13 +09:00
parent ec077d23f0
commit 88612b3479

View File

@@ -1385,40 +1385,73 @@ class AudioContentQueryRepositoryImpl(
where = where.and(audioContent.id.notIn(excludeContentIds))
}
val titleExpression = if (locale != null) {
val translatedTitle = Expressions.stringTemplate(
"JSON_EXTRACT({0}, '$.title')",
contentTranslation.renderedPayload
)
val coalesceTitle = Expressions.stringTemplate(
"COALESCE(NULLIF({0}, ''), {1})",
translatedTitle,
audioContent.title
)
coalesceTitle
} else {
audioContent.title
if (locale == null) {
var select = queryFactory
.select(
QAudioContentMainItem(
audioContent.id,
member.id,
audioContent.title,
audioContent.coverImage.prepend("/").prepend(imageHost),
member.nickname,
audioContent.isPointAvailable
)
)
.from(audioContent)
.innerJoin(audioContent.member, member)
.innerJoin(audioContent.theme, audioContentTheme)
if (memberId != null) {
where = where.and(blockMember.id.isNull)
select = select.leftJoin(blockMember).on(blockMemberCondition)
}
val orderBy = if (orderByRandom) {
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
} else {
when (sortType) {
SortType.NEWEST -> audioContent.releaseDate.desc()
SortType.PRICE_HIGH -> if (isFree) {
audioContent.releaseDate.desc()
} else {
audioContent.price.desc()
}
SortType.PRICE_LOW -> if (isFree) {
audioContent.releaseDate.asc()
} else {
audioContent.price.desc()
}
SortType.POPULARITY -> audioContent.playCount.desc()
}
}
return select
.where(where)
.offset(offset)
.limit(limit)
.orderBy(orderBy)
.fetch()
}
val coverImageUrl = audioContent.coverImage.prepend("/").prepend(imageHost)
var select = queryFactory
.select(
QAudioContentMainItem(
audioContent.id,
member.id,
titleExpression,
audioContent.coverImage.prepend("/").prepend(imageHost),
member.nickname,
audioContent.isPointAvailable
)
audioContent.id,
member.id,
audioContent.title,
contentTranslation.renderedPayload,
coverImageUrl,
member.nickname,
audioContent.isPointAvailable
)
.from(audioContent)
.innerJoin(audioContent.member, member)
.innerJoin(audioContent.theme, audioContentTheme)
if (locale != null) {
select = select.leftJoin(contentTranslation)
.on(contentTranslation.contentId.eq(audioContent.id).and(contentTranslation.locale.eq(locale)))
}
.leftJoin(contentTranslation)
.on(contentTranslation.contentId.eq(audioContent.id).and(contentTranslation.locale.eq(locale)))
if (memberId != null) {
where = where.and(blockMember.id.isNull)
@@ -1446,12 +1479,32 @@ class AudioContentQueryRepositoryImpl(
}
}
return select
val results = select
.where(where)
.offset(offset)
.limit(limit)
.orderBy(orderBy)
.fetch()
return results.map { row ->
val contentId = row.get(audioContent.id)!!
val creatorId = row.get(member.id)!!
val originTitle = row.get(audioContent.title)!!
val payload = row.get(contentTranslation.renderedPayload)
val translatedTitle = payload?.title
val imageUrl = row.get(coverImageUrl)!!
val creatorNickname = row.get(member.nickname)!!
val isPointAvailableValue = row.get(audioContent.isPointAvailable) ?: false
AudioContentMainItem(
contentId = contentId,
creatorId = creatorId,
title = if (translatedTitle.isNullOrBlank()) originTitle else translatedTitle,
coverImageUrl = imageUrl,
creatorNickname = creatorNickname,
isPointAvailable = isPointAvailableValue
)
}
}
override fun findContentByCurationId(