parent
664677a005
commit
ecddf9975f
|
@ -2,10 +2,13 @@ package kr.co.vividnext.sodalive.content.main.tab.content
|
|||
|
||||
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
|
||||
|
@ -13,10 +16,38 @@ import org.springframework.web.bind.annotation.RestController
|
|||
class AudioContentMainTabContentController(private val service: AudioContentMainTabContentService) {
|
||||
@GetMapping
|
||||
fun fetchContentMainTabContent(
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.fetchData(member))
|
||||
ApiResponse.ok(
|
||||
service.fetchData(
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
member
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.main.tab.content
|
|||
|
||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
||||
import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerService
|
||||
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeQueryRepository
|
||||
import kr.co.vividnext.sodalive.event.EventService
|
||||
|
@ -18,7 +19,11 @@ class AudioContentMainTabContentService(
|
|||
private val rankingService: RankingService,
|
||||
private val eventService: EventService
|
||||
) {
|
||||
fun fetchData(member: Member): GetContentMainTabContentResponse {
|
||||
fun fetchData(
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member
|
||||
): GetContentMainTabContentResponse {
|
||||
val memberId = member.id!!
|
||||
val isAdult = member.auth != null
|
||||
|
||||
|
@ -98,4 +103,20 @@ class AudioContentMainTabContentService(
|
|||
eventBannerList = eventBannerList
|
||||
)
|
||||
}
|
||||
|
||||
fun getNewContentByTheme(
|
||||
theme: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member
|
||||
): List<GetAudioContentMainItem> {
|
||||
return audioContentRepository.findByTheme(
|
||||
memberId = member.id!!,
|
||||
theme = theme,
|
||||
isAdult = member.auth != null && isAdultContentVisible,
|
||||
contentType = contentType,
|
||||
offset = 0,
|
||||
limit = 10
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue