diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index d0e30dc..22d289c 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -81,6 +81,12 @@ interface AudioContentQueryRepository { limit: Long = 20 ): List + fun totalAlarmCountByTheme( + memberId: Long, + theme: List, + isAdult: Boolean = false + ): Int + fun totalCountByTheme( memberId: Long, theme: String = "", @@ -486,6 +492,39 @@ class AudioContentQueryRepositoryImpl( .fetch() } + override fun totalAlarmCountByTheme(memberId: Long, theme: List, isAdult: Boolean): Int { + val blockMemberCondition = blockMember.member.id.eq(member.id) + .and(blockMember.isActive.isTrue) + .and(blockMember.blockedMember.id.eq(memberId)) + + var where = audioContent.isActive.isTrue + .and(audioContent.duration.isNotNull) + .and( + audioContent.releaseDate.isNull + .or(audioContent.releaseDate.loe(LocalDateTime.now())) + .or(audioContent.member.id.eq(memberId)) + ) + .and(blockMember.id.isNull) + + if (!isAdult) { + where = where.and(audioContent.isAdult.isFalse) + } + + if (theme.isNotEmpty()) { + where = where.and(audioContentTheme.theme.`in`(theme)) + } + + return queryFactory + .select(audioContent.id) + .from(audioContent) + .innerJoin(audioContent.member, member) + .innerJoin(audioContent.theme, audioContentTheme) + .leftJoin(blockMember).on(blockMemberCondition) + .where(where) + .fetch() + .size + } + override fun totalCountByTheme(memberId: Long, theme: String, isAdult: Boolean, contentType: ContentType): Int { var where = audioContent.isActive.isTrue .and(audioContent.duration.isNotNull) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/alarm/AudioContentMainTabAlarmService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/alarm/AudioContentMainTabAlarmService.kt index bac8749..53e9eb2 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/alarm/AudioContentMainTabAlarmService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/alarm/AudioContentMainTabAlarmService.kt @@ -1,7 +1,7 @@ package kr.co.vividnext.sodalive.content.main.tab.alarm import kr.co.vividnext.sodalive.content.AudioContentRepository -import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem +import kr.co.vividnext.sodalive.content.main.GetNewContentAllResponse import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerService import kr.co.vividnext.sodalive.content.main.curation.AudioContentCurationQueryRepository import kr.co.vividnext.sodalive.content.main.tab.GetContentCurationResponse @@ -86,7 +86,7 @@ class AudioContentMainTabAlarmService( member: Member, offset: Long, limit: Long - ): List { + ): GetNewContentAllResponse { val alarmThemeList = if (theme.isNotBlank()) { listOf(theme) } else { @@ -96,12 +96,20 @@ class AudioContentMainTabAlarmService( val memberId = member.id!! val isAdult = member.auth != null - return contentRepository.findAlarmContentByTheme( + val totalCount = contentRepository.totalAlarmCountByTheme( + memberId = memberId, + theme = alarmThemeList, + isAdult = isAdult + ) + + val items = contentRepository.findAlarmContentByTheme( memberId = memberId, theme = alarmThemeList, isAdult = isAdult, offset = offset, limit = limit ) + + return GetNewContentAllResponse(totalCount, items) } }