From e1bfd944e98001381d50d239c49e7065678c46e9 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 14 Feb 2025 15:44:40 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=AC=B4=EB=A3=8C=20=ED=83=AD=20-=20=EC=83=88?= =?UTF-8?q?=EB=A1=9C=EC=9A=B4=20=EC=BD=98=ED=85=90=EC=B8=A0=20=ED=85=8C?= =?UTF-8?q?=EB=A7=88=20=EC=84=A0=ED=83=9D=20=EC=95=A1=EC=85=98=20API=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../free/AudioContentMainTabFreeController.kt | 24 +++++++++++++++++++ .../free/AudioContentMainTabFreeService.kt | 19 +++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeController.kt index d92a08a..4c8fa63 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeController.kt @@ -2,11 +2,13 @@ package kr.co.vividnext.sodalive.content.main.tab.free import kr.co.vividnext.sodalive.common.ApiResponse import kr.co.vividnext.sodalive.common.SodaException +import kr.co.vividnext.sodalive.content.ContentType import kr.co.vividnext.sodalive.member.Member import org.springframework.data.domain.Pageable import org.springframework.security.core.annotation.AuthenticationPrincipal import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController @@ -36,4 +38,26 @@ class AudioContentMainTabFreeController(private val service: AudioContentMainTab ) ) } + + @GetMapping("/new-content-by-theme") + fun getNewContentByTheme( + @RequestParam("theme") theme: String, + @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, + @RequestParam("contentType", required = false) contentType: ContentType? = null, + @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, + pageable: Pageable + ) = run { + if (member == null) throw SodaException("로그인 정보를 확인해주세요.") + + ApiResponse.ok( + service.getNewContentByTheme( + theme, + isAdultContentVisible = isAdultContentVisible ?: true, + contentType = contentType ?: ContentType.ALL, + member, + offset = pageable.offset, + limit = pageable.pageSize.toLong() + ) + ) + } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeService.kt index 49e1571..df99edc 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/main/tab/free/AudioContentMainTabFreeService.kt @@ -113,4 +113,23 @@ class AudioContentMainTabFreeService( emptyList() } } + + fun getNewContentByTheme( + theme: String, + isAdultContentVisible: Boolean, + contentType: ContentType, + member: Member, + offset: Long, + limit: Long + ): List { + return audioContentRepository.findByTheme( + memberId = member.id!!, + theme = theme, + isAdult = member.auth != null && isAdultContentVisible, + contentType = contentType, + offset = offset, + limit = limit, + isFree = true + ) + } }