50 lines
1.8 KiB
Kotlin
50 lines
1.8 KiB
Kotlin
package kr.co.vividnext.sodalive.point
|
|
|
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
|
import kr.co.vividnext.sodalive.common.SodaException
|
|
import kr.co.vividnext.sodalive.member.Member
|
|
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("/point")
|
|
class PointController(private val service: PointService) {
|
|
@GetMapping("/status")
|
|
fun getPointStatus(
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
) = run {
|
|
if (member == null) {
|
|
throw SodaException(messageKey = "common.error.bad_credentials")
|
|
}
|
|
|
|
ApiResponse.ok(service.getPointStatus(member))
|
|
}
|
|
|
|
@GetMapping("/status/use")
|
|
fun getPointUseStatus(
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
|
@RequestParam("timezone") timezone: String
|
|
) = run {
|
|
if (member == null) {
|
|
throw SodaException(messageKey = "common.error.bad_credentials")
|
|
}
|
|
|
|
ApiResponse.ok(service.getPointUseStatus(member, timezone))
|
|
}
|
|
|
|
@GetMapping("/status/reward")
|
|
fun getPointRewardStatus(
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
|
@RequestParam("timezone") timezone: String
|
|
) = run {
|
|
if (member == null) {
|
|
throw SodaException(messageKey = "common.error.bad_credentials")
|
|
}
|
|
|
|
ApiResponse.ok(service.getPointRewardStatus(member, timezone))
|
|
}
|
|
}
|