diff --git a/src/main/java/com/hanaro/starbucks/repository/OrderDetailRepository.java b/src/main/java/com/hanaro/starbucks/repository/OrderDetailRepository.java deleted file mode 100644 index 1f51b8a..0000000 --- a/src/main/java/com/hanaro/starbucks/repository/OrderDetailRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hanaro.starbucks.repository; - -import com.hanaro.starbucks.entity.OrderDetail; -import com.hanaro.starbucks.entity.Orders; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface OrderDetailRepository extends JpaRepository { - List findAllByOrders(Orders orders); -} diff --git a/src/main/java/com/hanaro/starbucks/service/OrderService.java b/src/main/java/com/hanaro/starbucks/service/OrderService.java index c1e7750..936032e 100644 --- a/src/main/java/com/hanaro/starbucks/service/OrderService.java +++ b/src/main/java/com/hanaro/starbucks/service/OrderService.java @@ -3,13 +3,11 @@ 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; @@ -17,13 +15,12 @@ @RequiredArgsConstructor public class OrderService { private final OrderRepository orderRepository; - private final OrderDetailRepository orderDetailRepository; public List getOrders() { List orders = orderRepository.findAll(); List orderResDtos = orders.stream() .map(order -> { - List orderDetails = orderDetailRepository.findAllByOrders(order); + List orderDetails = order.getOrderDetails(); int totalPrice = calculateTotalPrice(orderDetails); return OrderResDto.builder() .orderIdx(order.getOrderIdx())