From ea43dd9b7a806805eb5fb36deb547a861cc506a9 Mon Sep 17 00:00:00 2001 From: mummhy0811 <mummhy0811@gmail.com> Date: Tue, 30 Apr 2024 13:35:19 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=A3=BC=EB=AC=B8=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=97=B0=EA=B4=80=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EC=9D=B4=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starbucks/repository/OrderDetailRepository.java | 13 ------------- .../com/hanaro/starbucks/service/OrderService.java | 5 +---- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 src/main/java/com/hanaro/starbucks/repository/OrderDetailRepository.java 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<OrderDetail, Integer> { - List<OrderDetail> 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<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())