61 lines
2.2 KiB
Kotlin
61 lines
2.2 KiB
Kotlin
package kr.co.vividnext.sodalive.can
|
|
|
|
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.RequestMapping
|
|
import org.springframework.web.bind.annotation.RequestParam
|
|
import org.springframework.web.bind.annotation.RestController
|
|
|
|
@RestController
|
|
@RequestMapping("/can")
|
|
class CanController(private val service: CanService) {
|
|
@GetMapping
|
|
fun getCans(): ApiResponse<List<CanResponse>> {
|
|
return ApiResponse.ok(service.getCans())
|
|
}
|
|
|
|
@GetMapping("/status")
|
|
fun getCanStatus(
|
|
@RequestParam container: String,
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
) = run {
|
|
if (member == null) {
|
|
throw SodaException("로그인 정보를 확인해주세요.")
|
|
}
|
|
|
|
ApiResponse.ok(service.getCanStatus(member, container))
|
|
}
|
|
|
|
@GetMapping("/status/use")
|
|
fun getCanUseStatus(
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
|
@RequestParam("timezone") timezone: String,
|
|
@RequestParam("container") container: String,
|
|
pageable: Pageable
|
|
) = run {
|
|
if (member == null) {
|
|
throw SodaException("로그인 정보를 확인해주세요.")
|
|
}
|
|
|
|
ApiResponse.ok(service.getCanUseStatus(member, pageable, timezone, container))
|
|
}
|
|
|
|
@GetMapping("/status/charge")
|
|
fun getCanChargeStatus(
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
|
@RequestParam("timezone") timezone: String,
|
|
@RequestParam("container") container: String,
|
|
pageable: Pageable
|
|
) = run {
|
|
if (member == null) {
|
|
throw SodaException("로그인 정보를 확인해주세요.")
|
|
}
|
|
|
|
ApiResponse.ok(service.getCanChargeStatus(member, pageable, timezone, container))
|
|
}
|
|
}
|