구매목록

- orderType 파라미터 제거
This commit is contained in:
Klaus 2024-12-18 03:22:13 +09:00
parent a1f9b676b5
commit 00e4fefc8f
3 changed files with 20 additions and 62 deletions

View File

@ -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()

View File

@ -20,7 +20,6 @@ interface OrderQueryRepository {
fun isExistOrderedAndOrderType(memberId: Long, contentId: Long): Pair<Boolean, OrderType?>
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<GetAudioContentOrderListItem>
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<GetAudioContentOrderListItem> {
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)

View File

@ -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!!,