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 6451801..eacea2a 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,7 @@ interface AudioContentQueryRepository { ): Int fun findByThemeFor2Weeks( + isFree: Boolean = false, cloudfrontHost: String, memberId: Long, theme: String = "", @@ -91,6 +92,7 @@ interface AudioContentQueryRepository { ): List fun totalCountNewContentFor2Weeks( + isFree: Boolean = false, theme: String, memberId: Long, isAdult: Boolean, @@ -456,6 +458,7 @@ class AudioContentQueryRepositoryImpl( } override fun totalCountNewContentFor2Weeks( + isFree: Boolean, theme: String, memberId: Long, isAdult: Boolean, @@ -484,6 +487,10 @@ class AudioContentQueryRepositoryImpl( where = where.and(audioContentTheme.theme.eq(theme)) } + if (isFree) { + where = where.and(audioContent.price.loe(0)) + } + return queryFactory .select(audioContent.id) .from(audioContent) @@ -495,6 +502,7 @@ class AudioContentQueryRepositoryImpl( } override fun findByThemeFor2Weeks( + isFree: Boolean, cloudfrontHost: String, memberId: Long, theme: String, @@ -526,6 +534,10 @@ class AudioContentQueryRepositoryImpl( where = where.and(audioContentTheme.theme.eq(theme)) } + if (isFree) { + where = where.and(audioContent.price.loe(0)) + } + return queryFactory .select( QGetAudioContentMainItem( diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainController.kt index c1fc22d..de06c18 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainController.kt @@ -92,6 +92,7 @@ class AudioContentMainController( @GetMapping("/new/all") fun getNewContentAllByTheme( + @RequestParam("isFree", required = false) isFree: Boolean? = null, @RequestParam("theme") theme: String, @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, @RequestParam("contentType", required = false) contentType: ContentType? = null, @@ -102,6 +103,7 @@ class AudioContentMainController( ApiResponse.ok( service.getNewContentFor2WeeksByTheme( + isFree = isFree ?: false, theme = theme, isAdultContentVisible = isAdultContentVisible ?: true, contentType = contentType ?: ContentType.ALL, diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainService.kt index b72b829..faabf41 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/AudioContentMainService.kt @@ -50,6 +50,7 @@ class AudioContentMainService( @Transactional(readOnly = true) fun getNewContentFor2WeeksByTheme( + isFree: Boolean, theme: String, isAdultContentVisible: Boolean, contentType: ContentType, @@ -57,12 +58,14 @@ class AudioContentMainService( pageable: Pageable ): GetNewContentAllResponse { val totalCount = repository.totalCountNewContentFor2Weeks( + isFree, theme, memberId = member.id!!, isAdult = member.auth != null && isAdultContentVisible, contentType = contentType ) val items = repository.findByThemeFor2Weeks( + isFree, cloudfrontHost = imageHost, memberId = member.id!!, theme = theme,