Skip to content

Commit

Permalink
Merge pull request #62 from 28th-meetup/feat/myStoreMenu
Browse files Browse the repository at this point in the history
fix: 주문내역 없을 때 빈 배열로 주는 걸로 변환
  • Loading branch information
summit45 authored Nov 21, 2023
2 parents 8334fae + 640a374 commit 0afb03c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/main/java/com/kusitms/jipbap/order/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public OrderFoodResponse orderFood(String email, OrderFoodRequest dto) {
}

@Transactional
public List<OrderDetail> saveOrderFoodDetail(Long orderId, List<OrderFoodDetailRequest> orderFoodDetailList){
public List<OrderDetail> saveOrderFoodDetail(Long orderId, List<OrderFoodDetailRequest> orderFoodDetailList) {
Order order = orderRepository.findById(orderId)
.orElseThrow(() -> new OrderNotFoundException("주문 아이디를 찾을 수 없습니다."));
return orderFoodDetailList.stream()
Expand Down Expand Up @@ -101,14 +101,13 @@ public OwnerOrderStatusResponse getStoreOrderHistoryByOrderStatus(String email,
List<Order> orderList = orderRepository.findByStore_IdAndStatus(store.getId(), status)
.orElseThrow(() -> new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다."));

if (orderList.isEmpty()) {
throw new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다.");
}

List<OrderPreviewResponse> orderPreviewResponses = orderList.stream()
.map(OrderPreviewResponse::new)
.collect(Collectors.toList());

if (orderList.isEmpty()) {
return new OwnerOrderStatusResponse(0, Collections.emptyList());
}
return new OwnerOrderStatusResponse(orderPreviewResponses.size(), orderPreviewResponses);
}

Expand Down Expand Up @@ -149,7 +148,7 @@ public List<OrderHistoryResponse> getMyOrderHistory(String email) {
return orderFoodResponseList;
}

public StoreProcessingResponse getStoreProcessingOrder(String email){
public StoreProcessingResponse getStoreProcessingOrder(String email) {
User user = userRepository.findByEmail(email)
.orElseThrow(() -> new UserNotFoundException("해당 유저를 찾을 수 없습니다."));

Expand All @@ -160,10 +159,6 @@ public StoreProcessingResponse getStoreProcessingOrder(String email){
List<Order> orderList = orderRepository.findByStore_IdAndStatus(store.getId(), OrderStatus.ACCEPTED)
.orElseThrow(() -> new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다."));

if (orderList.isEmpty()) {
throw new OrderNotExistsByOrderStatusException("해당 가게의 주문상태에 따른 주문 내역이 존재하지 않습니다.");
}

//주문내역 중에서 음식별로 묶기
List<OrderDetail> orderDetailList = orderList.stream()
.flatMap(order -> order.getOrderDetail().stream())
Expand Down Expand Up @@ -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);

}
}

0 comments on commit 0afb03c

Please sign in to comment.