test #388

Merged
klaus merged 15 commits from test into main 2026-02-13 09:14:20 +00:00
Showing only changes of commit 88612b3479 - Show all commits

View File

@@ -1385,27 +1385,13 @@ class AudioContentQueryRepositoryImpl(
where = where.and(audioContent.id.notIn(excludeContentIds)) where = where.and(audioContent.id.notIn(excludeContentIds))
} }
val titleExpression = if (locale != null) { 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
}
var select = queryFactory var select = queryFactory
.select( .select(
QAudioContentMainItem( QAudioContentMainItem(
audioContent.id, audioContent.id,
member.id, member.id,
titleExpression, audioContent.title,
audioContent.coverImage.prepend("/").prepend(imageHost), audioContent.coverImage.prepend("/").prepend(imageHost),
member.nickname, member.nickname,
audioContent.isPointAvailable audioContent.isPointAvailable
@@ -1415,11 +1401,6 @@ class AudioContentQueryRepositoryImpl(
.innerJoin(audioContent.member, member) .innerJoin(audioContent.member, member)
.innerJoin(audioContent.theme, audioContentTheme) .innerJoin(audioContent.theme, audioContentTheme)
if (locale != null) {
select = select.leftJoin(contentTranslation)
.on(contentTranslation.contentId.eq(audioContent.id).and(contentTranslation.locale.eq(locale)))
}
if (memberId != null) { if (memberId != null) {
where = where.and(blockMember.id.isNull) where = where.and(blockMember.id.isNull)
select = select.leftJoin(blockMember).on(blockMemberCondition) select = select.leftJoin(blockMember).on(blockMemberCondition)
@@ -1454,6 +1435,78 @@ class AudioContentQueryRepositoryImpl(
.fetch() .fetch()
} }
val coverImageUrl = audioContent.coverImage.prepend("/").prepend(imageHost)
var select = queryFactory
.select(
audioContent.id,
member.id,
audioContent.title,
contentTranslation.renderedPayload,
coverImageUrl,
member.nickname,
audioContent.isPointAvailable
)
.from(audioContent)
.innerJoin(audioContent.member, member)
.innerJoin(audioContent.theme, audioContentTheme)
.leftJoin(contentTranslation)
.on(contentTranslation.contentId.eq(audioContent.id).and(contentTranslation.locale.eq(locale)))
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()
}
}
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( override fun findContentByCurationId(
curationId: Long, curationId: Long,
isAdult: Boolean, isAdult: Boolean,