콘텐츠 메인 무료 탭

- 새로운 콘텐츠 테마 선택 액션 API 추가
This commit is contained in:
Klaus 2025-02-14 15:44:40 +09:00
parent a6f8f6a4d4
commit e1bfd944e9
2 changed files with 43 additions and 0 deletions

View File

@ -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.ApiResponse
import kr.co.vividnext.sodalive.common.SodaException import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.content.ContentType
import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.Member
import org.springframework.data.domain.Pageable import org.springframework.data.domain.Pageable
import org.springframework.security.core.annotation.AuthenticationPrincipal import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController import org.springframework.web.bind.annotation.RestController
@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()
)
)
}
} }

View File

@ -113,4 +113,23 @@ class AudioContentMainTabFreeService(
emptyList() emptyList()
} }
} }
fun getNewContentByTheme(
theme: String,
isAdultContentVisible: Boolean,
contentType: ContentType,
member: Member,
offset: Long,
limit: Long
): List<GetAudioContentMainItem> {
return audioContentRepository.findByTheme(
memberId = member.id!!,
theme = theme,
isAdult = member.auth != null && isAdultContentVisible,
contentType = contentType,
offset = offset,
limit = limit,
isFree = true
)
}
} }