memberId가 특정 번호일 때 currency와 관계없이 모든 구매 가능한 캔이 출력되도록 수정
This commit is contained in:
@@ -14,8 +14,11 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RequestMapping("/can")
|
@RequestMapping("/can")
|
||||||
class CanController(private val service: CanService) {
|
class CanController(private val service: CanService) {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
fun getCans(): ApiResponse<List<CanResponse>> {
|
fun getCans(
|
||||||
return ApiResponse.ok(service.getCans())
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
): ApiResponse<List<CanResponse>> {
|
||||||
|
val isNotSelectedCurrency = member != null && member.id == 2L
|
||||||
|
return ApiResponse.ok(service.getCans(isNotSelectedCurrency = isNotSelectedCurrency))
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/status")
|
@GetMapping("/status")
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Repository
|
|||||||
interface CanRepository : JpaRepository<Can, Long>, CanQueryRepository
|
interface CanRepository : JpaRepository<Can, Long>, CanQueryRepository
|
||||||
|
|
||||||
interface CanQueryRepository {
|
interface CanQueryRepository {
|
||||||
fun findAllByStatusAndCurrency(status: CanStatus, currency: String): List<CanResponse>
|
fun findAllByStatusAndCurrency(status: CanStatus, currency: String?): List<CanResponse>
|
||||||
fun getCanUseStatus(member: Member, pageable: Pageable): List<UseCan>
|
fun getCanUseStatus(member: Member, pageable: Pageable): List<UseCan>
|
||||||
fun getCanChargeStatus(member: Member, pageable: Pageable, container: String): List<Charge>
|
fun getCanChargeStatus(member: Member, pageable: Pageable, container: String): List<Charge>
|
||||||
fun isExistPaidLiveRoom(memberId: Long, roomId: Long): UseCan?
|
fun isExistPaidLiveRoom(memberId: Long, roomId: Long): UseCan?
|
||||||
@@ -32,7 +32,13 @@ interface CanQueryRepository {
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class CanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CanQueryRepository {
|
class CanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CanQueryRepository {
|
||||||
override fun findAllByStatusAndCurrency(status: CanStatus, currency: String): List<CanResponse> {
|
override fun findAllByStatusAndCurrency(status: CanStatus, currency: String?): List<CanResponse> {
|
||||||
|
var where = can1.status.eq(status)
|
||||||
|
|
||||||
|
if (currency != null) {
|
||||||
|
where = where.and(can1.currency.eq(currency))
|
||||||
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QCanResponse(
|
QCanResponse(
|
||||||
@@ -46,10 +52,7 @@ class CanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CanQue
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(can1)
|
.from(can1)
|
||||||
.where(
|
.where(where)
|
||||||
can1.status.eq(status),
|
|
||||||
can1.currency.eq(currency)
|
|
||||||
)
|
|
||||||
.orderBy(can1.can.asc())
|
.orderBy(can1.can.asc())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,14 @@ class CanService(
|
|||||||
private val repository: CanRepository,
|
private val repository: CanRepository,
|
||||||
private val countryContext: CountryContext
|
private val countryContext: CountryContext
|
||||||
) {
|
) {
|
||||||
fun getCans(): List<CanResponse> {
|
fun getCans(isNotSelectedCurrency: Boolean): List<CanResponse> {
|
||||||
val currency = when (countryContext.countryCode) {
|
val currency = if (isNotSelectedCurrency) {
|
||||||
"KR" -> "KRW"
|
null
|
||||||
else -> "USD"
|
} else {
|
||||||
|
when (countryContext.countryCode) {
|
||||||
|
"KR" -> "KRW"
|
||||||
|
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