test #420
@@ -17,8 +17,12 @@ class CanController(private val service: CanService) {
|
|||||||
fun getCans(
|
fun getCans(
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
): ApiResponse<List<CanResponse>> {
|
): ApiResponse<List<CanResponse>> {
|
||||||
val isNotSelectedCurrency = member != null && member.id == 2L
|
val forcedCurrency = if (member != null && (member.id == 2L || member.id == 4L || member.id == 44144L)) {
|
||||||
return ApiResponse.ok(service.getCans(isNotSelectedCurrency = isNotSelectedCurrency))
|
"JPY"
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
return ApiResponse.ok(service.getCans(forcedCurrency = forcedCurrency))
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/status")
|
@GetMapping("/status")
|
||||||
|
|||||||
@@ -14,15 +14,11 @@ class CanService(
|
|||||||
private val repository: CanRepository,
|
private val repository: CanRepository,
|
||||||
private val countryContext: CountryContext
|
private val countryContext: CountryContext
|
||||||
) {
|
) {
|
||||||
fun getCans(isNotSelectedCurrency: Boolean): List<CanResponse> {
|
fun getCans(forcedCurrency: String? = null): List<CanResponse> {
|
||||||
val currency = if (isNotSelectedCurrency) {
|
val currency = forcedCurrency ?: when (countryContext.countryCode) {
|
||||||
null
|
|
||||||
} else {
|
|
||||||
when (countryContext.countryCode) {
|
|
||||||
"KR" -> "KRW"
|
"KR" -> "KRW"
|
||||||
else -> "USD"
|
else -> "USD"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return repository.findAllByStatusAndCurrency(status = CanStatus.SALE, currency = currency)
|
return repository.findAllByStatusAndCurrency(status = CanStatus.SALE, currency = currency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user