diff --git a/src/main/java/com/kusitms/jipbap/order/OrderService.java b/src/main/java/com/kusitms/jipbap/order/OrderService.java index d357456..03e7f3b 100644 --- a/src/main/java/com/kusitms/jipbap/order/OrderService.java +++ b/src/main/java/com/kusitms/jipbap/order/OrderService.java @@ -61,7 +61,7 @@ public OrderFoodResponse orderFood(String email, OrderFoodRequest dto) { } @Transactional - public List saveOrderFoodDetail(Long orderId, List orderFoodDetailList){ + public List saveOrderFoodDetail(Long orderId, List orderFoodDetailList) { Order order = orderRepository.findById(orderId) .orElseThrow(() -> new OrderNotFoundException("주문 아이디를 찾을 수 없습니다.")); return orderFoodDetailList.stream() @@ -101,14 +101,13 @@ public OwnerOrderStatusResponse getStoreOrderHistoryByOrderStatus(String email, List orderList = orderRepository.findByStore_IdAndStatus(store.getId(), status) .orElseThrow(() -> new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다.")); - if (orderList.isEmpty()) { - throw new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다."); - } - List orderPreviewResponses = orderList.stream() .map(OrderPreviewResponse::new) .collect(Collectors.toList()); + if (orderList.isEmpty()) { + return new OwnerOrderStatusResponse(0, Collections.emptyList()); + } return new OwnerOrderStatusResponse(orderPreviewResponses.size(), orderPreviewResponses); } @@ -149,7 +148,7 @@ public List getMyOrderHistory(String email) { return orderFoodResponseList; } - public StoreProcessingResponse getStoreProcessingOrder(String email){ + public StoreProcessingResponse getStoreProcessingOrder(String email) { User user = userRepository.findByEmail(email) .orElseThrow(() -> new UserNotFoundException("해당 유저를 찾을 수 없습니다.")); @@ -160,10 +159,6 @@ public StoreProcessingResponse getStoreProcessingOrder(String email){ List orderList = orderRepository.findByStore_IdAndStatus(store.getId(), OrderStatus.ACCEPTED) .orElseThrow(() -> new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다.")); - if (orderList.isEmpty()) { - throw new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다."); - } - //주문내역 중에서 음식별로 묶기 List orderDetailList = orderList.stream() .flatMap(order -> order.getOrderDetail().stream()) @@ -191,7 +186,9 @@ public StoreProcessingResponse getStoreProcessingOrder(String email){ }) .collect(Collectors.toList()); + if (orderList.isEmpty()) { + return new StoreProcessingResponse(0, Collections.emptyList()); + } return new StoreProcessingResponse(orderList.size(), processingFoodResponseList); - } }