From 7e0a15f682b40c71779c8ee22a342dfccfc94745 Mon Sep 17 00:00:00 2001 From: Jeonghyun Lee Date: Sat, 14 Sep 2024 23:01:23 +0900 Subject: [PATCH] hotfix: order ProductOrders createdDate desc --- .../domain/product/repository/ProductOrderRepository.java | 2 +- .../repick/domain/product/service/ProductOrderService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/repick/domain/product/repository/ProductOrderRepository.java b/src/main/java/com/example/repick/domain/product/repository/ProductOrderRepository.java index 083b014..e7d4b51 100644 --- a/src/main/java/com/example/repick/domain/product/repository/ProductOrderRepository.java +++ b/src/main/java/com/example/repick/domain/product/repository/ProductOrderRepository.java @@ -17,7 +17,7 @@ public interface ProductOrderRepository extends JpaRepository findByIsConfirmedAndProductOrderStateIn(boolean isConfirmed, List productOrderStates); List findByUserId(Long userId); - Page findByUserIdAndProductOrderStateNot(Long userId, ProductOrderState productOrderState, Pageable pageable); + Page findByUserIdAndProductOrderStateNotOrderByCreatedDateDesc(Long userId, ProductOrderState productOrderState, Pageable pageable); Page findByProductOrderStateIn(List productOrderStates, Pageable pageable); diff --git a/src/main/java/com/example/repick/domain/product/service/ProductOrderService.java b/src/main/java/com/example/repick/domain/product/service/ProductOrderService.java index fbd7ba6..3fd8dc2 100644 --- a/src/main/java/com/example/repick/domain/product/service/ProductOrderService.java +++ b/src/main/java/com/example/repick/domain/product/service/ProductOrderService.java @@ -170,7 +170,7 @@ public PageResponse> getProductOrdersForUser(PageCo User user = userRepository.findByProviderId(SecurityContextHolder.getContext().getAuthentication().getName()) .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); Pageable pageable = pageCondition.toPageable(); - Page productOrderPage = productOrderRepository.findByUserIdAndProductOrderStateNot(user.getId(), ProductOrderState.DEFAULT, pageable); + Page productOrderPage = productOrderRepository.findByUserIdAndProductOrderStateNotOrderByCreatedDateDesc(user.getId(), ProductOrderState.DEFAULT, pageable); List getProductOrders = productOrderPage.stream() .map(productOrder -> { Product product = productRepository.findById(productOrder.getProductId())