diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderController.kt index 889e6ed..89c1e08 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderController.kt @@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController @@ -34,7 +33,6 @@ class OrderController(private val service: OrderService) { @GetMapping("/audio-content") fun getAudioContentOrderList( - @RequestParam(value = "orderType", required = false) orderType: OrderType? = null, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, pageable: Pageable ) = run { @@ -42,7 +40,6 @@ class OrderController(private val service: OrderService) { ApiResponse.ok( service.getAudioContentOrderList( - orderType = orderType, member = member, offset = pageable.offset, limit = pageable.pageSize.toLong() diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt index 4c7887b..6b31b77 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt @@ -20,7 +20,6 @@ interface OrderQueryRepository { fun isExistOrderedAndOrderType(memberId: Long, contentId: Long): Pair fun getAudioContentRemainingTime(memberId: Long, contentId: Long, timezone: String): String fun getAudioContentOrderList( - orderType: OrderType?, dateTime: LocalDateTime, coverImageHost: String, memberId: Long, @@ -28,7 +27,7 @@ interface OrderQueryRepository { limit: Long = 10 ): List - fun totalAudioContentOrderListCount(orderType: OrderType?, memberId: Long, dateTime: LocalDateTime): Int + fun totalAudioContentOrderListCount(memberId: Long, dateTime: LocalDateTime): Int fun getAudioContentMainOrderList( dateTime: LocalDateTime, coverImageHost: String, @@ -118,40 +117,22 @@ class OrderQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Orde } override fun getAudioContentOrderList( - orderType: OrderType?, dateTime: LocalDateTime, coverImageHost: String, memberId: Long, offset: Long, limit: Long ): List { - var where = order.member.id.eq(memberId) + val where = order.member.id.eq(memberId) .and(order.isActive.isTrue) - - when (orderType) { - OrderType.RENTAL -> { - where = where.and( - order.type.eq(OrderType.RENTAL) - .and(order.startDate.before(dateTime)) - .and(order.endDate.after(dateTime)) - ) - } - - OrderType.KEEP -> { - where = where.and(order.type.eq(OrderType.KEEP)) - } - - null -> { - where = where.and( - order.type.eq(OrderType.KEEP) - .or( - order.type.eq(OrderType.RENTAL) - .and(order.startDate.before(dateTime)) - .and(order.endDate.after(dateTime)) - ) - ) - } - } + .and( + order.type.eq(OrderType.KEEP) + .or( + order.type.eq(OrderType.RENTAL) + .and(order.startDate.before(dateTime)) + .and(order.endDate.after(dateTime)) + ) + ) return queryFactory .select( @@ -178,34 +159,17 @@ class OrderQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Orde .fetch() } - override fun totalAudioContentOrderListCount(orderType: OrderType?, memberId: Long, dateTime: LocalDateTime): Int { - var where = order.member.id.eq(memberId) + override fun totalAudioContentOrderListCount(memberId: Long, dateTime: LocalDateTime): Int { + val where = order.member.id.eq(memberId) .and(order.isActive.isTrue) - - when (orderType) { - OrderType.RENTAL -> { - where = where.and( - order.type.eq(OrderType.RENTAL) - .and(order.startDate.before(dateTime)) - .and(order.endDate.after(dateTime)) - ) - } - - OrderType.KEEP -> { - where = where.and(order.type.eq(OrderType.KEEP)) - } - - null -> { - where = where.and( - order.type.eq(OrderType.KEEP) - .or( - order.type.eq(OrderType.RENTAL) - .and(order.startDate.before(dateTime)) - .and(order.endDate.after(dateTime)) - ) - ) - } - } + .and( + order.type.eq(OrderType.KEEP) + .or( + order.type.eq(OrderType.RENTAL) + .and(order.startDate.before(dateTime)) + .and(order.endDate.after(dateTime)) + ) + ) return queryFactory.select(order.id) .from(order) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderService.kt index 620aaaa..630b22a 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderService.kt @@ -90,18 +90,15 @@ class OrderService( } fun getAudioContentOrderList( - orderType: OrderType? = null, member: Member, offset: Long, limit: Long ): GetAudioContentOrderListResponse { val totalCount = repository.totalAudioContentOrderListCount( - orderType = orderType, memberId = member.id!!, dateTime = LocalDateTime.now() ) val orderItems = repository.getAudioContentOrderList( - orderType = orderType, dateTime = LocalDateTime.now(), coverImageHost = audioContentCoverImageHost, memberId = member.id!!,