From 482241f734fc9a02364b427f3290bd9a0b4e8081 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 16 Jan 2026 11:24:48 +0900 Subject: [PATCH] =?UTF-8?q?memberId=EA=B0=80=20=ED=8A=B9=EC=A0=95=20?= =?UTF-8?q?=EB=B2=88=ED=98=B8=EC=9D=BC=20=EB=95=8C=20currency=EC=99=80=20?= =?UTF-8?q?=EA=B4=80=EA=B3=84=EC=97=86=EC=9D=B4=20=EB=AA=A8=EB=93=A0=20?= =?UTF-8?q?=EA=B5=AC=EB=A7=A4=20=EA=B0=80=EB=8A=A5=ED=95=9C=20=EC=BA=94?= =?UTF-8?q?=EC=9D=B4=20=EC=B6=9C=EB=A0=A5=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/can/CanController.kt | 7 +++++-- .../kr/co/vividnext/sodalive/can/CanRepository.kt | 15 +++++++++------ .../kr/co/vividnext/sodalive/can/CanService.kt | 12 ++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanController.kt index f97698c2..662dbe8f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanController.kt @@ -14,8 +14,11 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/can") class CanController(private val service: CanService) { @GetMapping - fun getCans(): ApiResponse> { - return ApiResponse.ok(service.getCans()) + fun getCans( + @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? + ): ApiResponse> { + val isNotSelectedCurrency = member != null && member.id == 2L + return ApiResponse.ok(service.getCans(isNotSelectedCurrency = isNotSelectedCurrency)) } @GetMapping("/status") diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanRepository.kt index fcc3f2f7..0019c22e 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanRepository.kt @@ -23,7 +23,7 @@ import org.springframework.stereotype.Repository interface CanRepository : JpaRepository, CanQueryRepository interface CanQueryRepository { - fun findAllByStatusAndCurrency(status: CanStatus, currency: String): List + fun findAllByStatusAndCurrency(status: CanStatus, currency: String?): List fun getCanUseStatus(member: Member, pageable: Pageable): List fun getCanChargeStatus(member: Member, pageable: Pageable, container: String): List fun isExistPaidLiveRoom(memberId: Long, roomId: Long): UseCan? @@ -32,7 +32,13 @@ interface CanQueryRepository { @Repository class CanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CanQueryRepository { - override fun findAllByStatusAndCurrency(status: CanStatus, currency: String): List { + override fun findAllByStatusAndCurrency(status: CanStatus, currency: String?): List { + var where = can1.status.eq(status) + + if (currency != null) { + where = where.and(can1.currency.eq(currency)) + } + return queryFactory .select( QCanResponse( @@ -46,10 +52,7 @@ class CanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CanQue ) ) .from(can1) - .where( - can1.status.eq(status), - can1.currency.eq(currency) - ) + .where(where) .orderBy(can1.can.asc()) .fetch() } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanService.kt index 24994f33..bd433c6c 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanService.kt @@ -15,10 +15,14 @@ class CanService( private val repository: CanRepository, private val countryContext: CountryContext ) { - fun getCans(): List { - val currency = when (countryContext.countryCode) { - "KR" -> "KRW" - else -> "USD" + fun getCans(isNotSelectedCurrency: Boolean): List { + val currency = if (isNotSelectedCurrency) { + null + } else { + when (countryContext.countryCode) { + "KR" -> "KRW" + else -> "USD" + } } return repository.findAllByStatusAndCurrency(status = CanStatus.SALE, currency = currency) }