parent
88d326023b
commit
5890f9932b
|
@ -68,6 +68,12 @@ interface AudioContentQueryRepository {
|
||||||
limit: Long = 20
|
limit: Long = 20
|
||||||
): List<GetAudioContentMainItem>
|
): List<GetAudioContentMainItem>
|
||||||
|
|
||||||
|
fun totalCountByTheme(
|
||||||
|
memberId: Long,
|
||||||
|
theme: String = "",
|
||||||
|
isAdult: Boolean = false
|
||||||
|
): Int
|
||||||
|
|
||||||
fun findByThemeFor2Weeks(
|
fun findByThemeFor2Weeks(
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
|
@ -367,6 +373,32 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun totalCountByTheme(memberId: Long, theme: String, isAdult: Boolean): Int {
|
||||||
|
var where = audioContent.isActive.isTrue
|
||||||
|
.and(
|
||||||
|
audioContent.releaseDate.isNull
|
||||||
|
.or(audioContent.releaseDate.loe(LocalDateTime.now()))
|
||||||
|
.or(audioContent.member.id.eq(memberId))
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!isAdult) {
|
||||||
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theme.isNotBlank()) {
|
||||||
|
where = where.and(audioContentTheme.theme.eq(theme))
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(audioContent.id)
|
||||||
|
.from(audioContent)
|
||||||
|
.innerJoin(audioContent.member, member)
|
||||||
|
.innerJoin(audioContent.theme, audioContentTheme)
|
||||||
|
.where(where)
|
||||||
|
.fetch()
|
||||||
|
.size
|
||||||
|
}
|
||||||
|
|
||||||
override fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int {
|
override fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
.and(audioContent.releaseDate.goe(LocalDateTime.now().minusWeeks(2)))
|
.and(audioContent.releaseDate.goe(LocalDateTime.now().minusWeeks(2)))
|
||||||
|
|
|
@ -35,6 +35,12 @@ class AudioContentThemeService(
|
||||||
val theme = queryRepository.findThemeByIdAndActive(themeId)
|
val theme = queryRepository.findThemeByIdAndActive(themeId)
|
||||||
?: throw SodaException("잘못된 요청입니다.")
|
?: throw SodaException("잘못된 요청입니다.")
|
||||||
|
|
||||||
|
val totalCount = contentRepository.totalCountByTheme(
|
||||||
|
memberId = member.id!!,
|
||||||
|
theme = theme.theme,
|
||||||
|
isAdult = member.auth != null
|
||||||
|
)
|
||||||
|
|
||||||
val items = contentRepository.findByTheme(
|
val items = contentRepository.findByTheme(
|
||||||
cloudfrontHost = imageHost,
|
cloudfrontHost = imageHost,
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
|
@ -50,6 +56,7 @@ class AudioContentThemeService(
|
||||||
|
|
||||||
return GetContentByThemeResponse(
|
return GetContentByThemeResponse(
|
||||||
theme = theme.theme,
|
theme = theme.theme,
|
||||||
|
totalCount = totalCount,
|
||||||
items = items
|
items = items
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,6 @@ import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||||
|
|
||||||
data class GetContentByThemeResponse(
|
data class GetContentByThemeResponse(
|
||||||
val theme: String,
|
val theme: String,
|
||||||
|
val totalCount: Int,
|
||||||
val items: List<GetAudioContentMainItem>
|
val items: List<GetAudioContentMainItem>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue