Files
sodalive-backend-spring-boot/src/main/kotlin/kr/co/vividnext/sodalive/can/CanController.kt
T
klaus b98cc4b018 fix(can): 특정 회원(2, 4, 44144) 접속 시 getCans 통화를 JPY로 강제
- CanService.getCans 시그니처를 isNotSelectedCurrency(Boolean) → forcedCurrency(String?)로 변경해 의도 명확화
- 통화 결정 로직을 forcedCurrency 우선 적용 후, 국가 코드(KR=KRW, 그 외=USD)로 fallback
- CanController에서 회원 ID가 2, 4, 44144인 경우 forcedCurrency="JPY"로 설정하여 서비스 호출
2026-05-01 14:38:24 +09:00

68 lines
2.5 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(
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
): ApiResponse<List<CanResponse>> {
val forcedCurrency = if (member != null && (member.id == 2L || member.id == 4L || member.id == 44144L)) {
"JPY"
} else {
null
}
return ApiResponse.ok(service.getCans(forcedCurrency = forcedCurrency))
}
@GetMapping("/status")
fun getCanStatus(
@RequestParam container: String,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
if (member == null) {
throw SodaException(messageKey = "common.error.bad_credentials")
}
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(messageKey = "common.error.bad_credentials")
}
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(messageKey = "common.error.bad_credentials")
}
ApiResponse.ok(service.getCanChargeStatus(member, pageable, timezone, container))
}
}