42 lines
1.5 KiB
Kotlin
42 lines
1.5 KiB
Kotlin
package kr.co.vividnext.sodalive.audition
|
|
|
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
|
import kr.co.vividnext.sodalive.common.SodaException
|
|
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.PathVariable
|
|
import org.springframework.web.bind.annotation.RequestMapping
|
|
import org.springframework.web.bind.annotation.RestController
|
|
|
|
@RestController
|
|
@RequestMapping("/audition")
|
|
class AuditionController(private val service: AuditionService) {
|
|
@GetMapping
|
|
fun getAuditionList(
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
|
pageable: Pageable
|
|
) = run {
|
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
|
|
ApiResponse.ok(
|
|
service.getAuditionList(
|
|
offset = pageable.offset,
|
|
limit = pageable.pageSize.toLong(),
|
|
isAdult = member.auth != null
|
|
)
|
|
)
|
|
}
|
|
|
|
@GetMapping("/{id}")
|
|
fun getAuditionDetail(
|
|
@PathVariable id: Long,
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
) = run {
|
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
|
|
ApiResponse.ok(service.getAuditionDetail(auditionId = id))
|
|
}
|
|
}
|