Skip to content

Commit

Permalink
Fix: 주문 상세 리스트 연관관계 이용으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
mummhy0811 committed Apr 30, 2024
1 parent 914b478 commit ea43dd9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.

This file was deleted.

5 changes: 1 addition & 4 deletions src/main/java/com/hanaro/starbucks/service/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@
import com.hanaro.starbucks.dto.orders.OrderResDto;
import com.hanaro.starbucks.entity.OrderDetail;
import com.hanaro.starbucks.entity.Orders;
import com.hanaro.starbucks.repository.OrderDetailRepository;
import com.hanaro.starbucks.repository.OrderRepository;
import com.hanaro.starbucks.util.Constant;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class OrderService {
private final OrderRepository orderRepository;
private final OrderDetailRepository orderDetailRepository;

public List<OrderResDto> getOrders() {
List<Orders> orders = orderRepository.findAll();
List<OrderResDto> orderResDtos = orders.stream()
.map(order -> {
List<OrderDetail> orderDetails = orderDetailRepository.findAllByOrders(order);
List<OrderDetail> orderDetails = order.getOrderDetails();
int totalPrice = calculateTotalPrice(orderDetails);
return OrderResDto.builder()
.orderIdx(order.getOrderIdx())
Expand Down

0 comments on commit ea43dd9

Please sign in to comment.