From 5d1e53b07ccbb542b5e28e453b1cd43213478243 Mon Sep 17 00:00:00 2001 From: seunghaen Date: Fri, 3 Jan 2025 06:54:58 +0900 Subject: [PATCH] =?UTF-8?q?Order=20DTO=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?Entity=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/payment/PaymentController.java | 10 +++--- .../terte/dto/order/CreateOrderReqDTO.java | 3 +- .../terte/dto/order/OrderDetailResDTO.java | 2 +- .../com/terte/dto/order/OrderItemDTO.java | 18 ++++++++++ .../java/com/terte/dto/order/OrderResDTO.java | 2 +- .../terte/dto/order/SelectedOptionDTO.java | 15 ++++++++ .../terte/dto/order/UpdateOrderReqDTO.java | 3 +- .../java/com/terte/entity/order/Order.java | 24 +++++++++++++ .../com/terte/entity/order/OrderItem.java | 20 +++++++++++ .../terte/entity/order/SelectedOption.java | 19 +++++++++++ .../repository/order/OrderRepository.java | 34 +++++++++++++++++++ 11 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 application/src/main/java/com/terte/dto/order/OrderItemDTO.java create mode 100644 application/src/main/java/com/terte/dto/order/SelectedOptionDTO.java create mode 100644 application/src/main/java/com/terte/entity/order/Order.java create mode 100644 application/src/main/java/com/terte/entity/order/OrderItem.java create mode 100644 application/src/main/java/com/terte/entity/order/SelectedOption.java create mode 100644 application/src/main/java/com/terte/repository/order/OrderRepository.java diff --git a/application/src/main/java/com/terte/controller/payment/PaymentController.java b/application/src/main/java/com/terte/controller/payment/PaymentController.java index 488e781..cd72abf 100644 --- a/application/src/main/java/com/terte/controller/payment/PaymentController.java +++ b/application/src/main/java/com/terte/controller/payment/PaymentController.java @@ -9,13 +9,15 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -/** - * GET /payments - * 결제 조회 - */ + @RestController @RequestMapping("/payments") public class PaymentController { + + /** + * GET /payments + * 결제 조회 + */ @GetMapping public ResponseEntity> getPayment() { PaymentResDTO payment = new PaymentResDTO(1L, 1L, PaymentMethod.CASH, PaymentStatus.PAYMENT_COMPLETED); diff --git a/application/src/main/java/com/terte/dto/order/CreateOrderReqDTO.java b/application/src/main/java/com/terte/dto/order/CreateOrderReqDTO.java index e6fb08a..7d6ddde 100644 --- a/application/src/main/java/com/terte/dto/order/CreateOrderReqDTO.java +++ b/application/src/main/java/com/terte/dto/order/CreateOrderReqDTO.java @@ -1,7 +1,6 @@ package com.terte.dto.order; import com.terte.common.enums.OrderType; -import com.terte.dto.menu.MenuResDTO; import lombok.*; import java.util.List; @@ -11,7 +10,7 @@ @AllArgsConstructor @Builder public class CreateOrderReqDTO { - private List menuList; + private List orderItemList; private OrderType orderType; private String phoneNumber; private Integer tableNumber; diff --git a/application/src/main/java/com/terte/dto/order/OrderDetailResDTO.java b/application/src/main/java/com/terte/dto/order/OrderDetailResDTO.java index 0e096b5..7cf2f65 100644 --- a/application/src/main/java/com/terte/dto/order/OrderDetailResDTO.java +++ b/application/src/main/java/com/terte/dto/order/OrderDetailResDTO.java @@ -12,7 +12,7 @@ @AllArgsConstructor public class OrderDetailResDTO { private Long orderId; - private List menuList; + private List orderItemList; private OrderType orderType; private OrderStatus status; private String orderTime; diff --git a/application/src/main/java/com/terte/dto/order/OrderItemDTO.java b/application/src/main/java/com/terte/dto/order/OrderItemDTO.java new file mode 100644 index 0000000..a91b862 --- /dev/null +++ b/application/src/main/java/com/terte/dto/order/OrderItemDTO.java @@ -0,0 +1,18 @@ +package com.terte.dto.order; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class OrderItemDTO { + private Long menuId; + private Integer quantity; + private List selectedOptions; +} \ No newline at end of file diff --git a/application/src/main/java/com/terte/dto/order/OrderResDTO.java b/application/src/main/java/com/terte/dto/order/OrderResDTO.java index eb726eb..b4a1352 100644 --- a/application/src/main/java/com/terte/dto/order/OrderResDTO.java +++ b/application/src/main/java/com/terte/dto/order/OrderResDTO.java @@ -12,7 +12,7 @@ @AllArgsConstructor public class OrderResDTO { private Long id; - private List menuList; + private List orderItemList; private OrderType orderType; private OrderStatus status; private String orderTime; diff --git a/application/src/main/java/com/terte/dto/order/SelectedOptionDTO.java b/application/src/main/java/com/terte/dto/order/SelectedOptionDTO.java new file mode 100644 index 0000000..e7edb57 --- /dev/null +++ b/application/src/main/java/com/terte/dto/order/SelectedOptionDTO.java @@ -0,0 +1,15 @@ +package com.terte.dto.order; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class SelectedOptionDTO { + private Long optionId; + private List selectedChoiceIds; +} diff --git a/application/src/main/java/com/terte/dto/order/UpdateOrderReqDTO.java b/application/src/main/java/com/terte/dto/order/UpdateOrderReqDTO.java index 701b7b2..686d0c3 100644 --- a/application/src/main/java/com/terte/dto/order/UpdateOrderReqDTO.java +++ b/application/src/main/java/com/terte/dto/order/UpdateOrderReqDTO.java @@ -2,7 +2,6 @@ import com.terte.common.enums.OrderStatus; import com.terte.common.enums.OrderType; -import com.terte.dto.menu.MenuResDTO; import jakarta.validation.constraints.NotNull; import lombok.*; @@ -16,7 +15,7 @@ public class UpdateOrderReqDTO{ @NotNull private Long id; private OrderStatus status; - private List menuList; + private List orderItemList; private OrderType orderType; private String phoneNumber; private Integer tableNumber; diff --git a/application/src/main/java/com/terte/entity/order/Order.java b/application/src/main/java/com/terte/entity/order/Order.java new file mode 100644 index 0000000..d627f1f --- /dev/null +++ b/application/src/main/java/com/terte/entity/order/Order.java @@ -0,0 +1,24 @@ +package com.terte.entity.order; + +import com.terte.common.enums.OrderStatus; +import com.terte.common.enums.OrderType; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +public class Order { + private Long id; + private Long storeId; + private OrderStatus status; + private List orderItemList; + private OrderType orderType; + private String phoneNumber; + private Integer tableNumber; +} diff --git a/application/src/main/java/com/terte/entity/order/OrderItem.java b/application/src/main/java/com/terte/entity/order/OrderItem.java new file mode 100644 index 0000000..b47d699 --- /dev/null +++ b/application/src/main/java/com/terte/entity/order/OrderItem.java @@ -0,0 +1,20 @@ +package com.terte.entity.order; + +import com.terte.entity.menu.Menu; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class OrderItem { + private Long id; + private Menu menu; + private Integer quantity; + private List selectedOptions; +} diff --git a/application/src/main/java/com/terte/entity/order/SelectedOption.java b/application/src/main/java/com/terte/entity/order/SelectedOption.java new file mode 100644 index 0000000..2dd930c --- /dev/null +++ b/application/src/main/java/com/terte/entity/order/SelectedOption.java @@ -0,0 +1,19 @@ +package com.terte.entity.order; + +import com.terte.entity.menu.Choice; +import com.terte.entity.menu.Option; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class SelectedOption { + private Long id; + private Option option; + private List selectedChoices; +} diff --git a/application/src/main/java/com/terte/repository/order/OrderRepository.java b/application/src/main/java/com/terte/repository/order/OrderRepository.java new file mode 100644 index 0000000..3f66cec --- /dev/null +++ b/application/src/main/java/com/terte/repository/order/OrderRepository.java @@ -0,0 +1,34 @@ +package com.terte.repository.order; + +import com.terte.entity.order.Order; +import org.springframework.stereotype.Repository; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Repository +public class OrderRepository { + private final Map orderStorage = new ConcurrentHashMap<>(); + + OrderRepository() { + + } + + public Order findById(Long id) { + return orderStorage.get(id); + } + + public Order save(Order order) { + if(order.getId() == null) { + order.setId(orderStorage.size() + 1L); + orderStorage.put(order.getId(), order); + } else { + orderStorage.put(order.getId(), order); + } + return order; + } + + public void deleteById(Long id) { + orderStorage.remove(id); + } +}