Skip to content

Commit

Permalink
Order DTO 수정 및 Entity 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghaen committed Jan 2, 2025
1 parent bd8b13a commit 5d1e53b
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiResDTO<PaymentResDTO>> getPayment() {
PaymentResDTO payment = new PaymentResDTO(1L, 1L, PaymentMethod.CASH, PaymentStatus.PAYMENT_COMPLETED);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,7 +10,7 @@
@AllArgsConstructor
@Builder
public class CreateOrderReqDTO {
private List<MenuResDTO> menuList;
private List<OrderItemDTO> orderItemList;
private OrderType orderType;
private String phoneNumber;
private Integer tableNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@AllArgsConstructor
public class OrderDetailResDTO {
private Long orderId;
private List<MenuResDTO> menuList;
private List<OrderItemDTO> orderItemList;
private OrderType orderType;
private OrderStatus status;
private String orderTime;
Expand Down
18 changes: 18 additions & 0 deletions application/src/main/java/com/terte/dto/order/OrderItemDTO.java
Original file line number Diff line number Diff line change
@@ -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<SelectedOptionDTO> selectedOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@AllArgsConstructor
public class OrderResDTO {
private Long id;
private List<MenuResDTO> menuList;
private List<OrderItemDTO> orderItemList;
private OrderType orderType;
private OrderStatus status;
private String orderTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Long> selectedChoiceIds;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -16,7 +15,7 @@ public class UpdateOrderReqDTO{
@NotNull
private Long id;
private OrderStatus status;
private List<MenuResDTO> menuList;
private List<OrderItemDTO> orderItemList;
private OrderType orderType;
private String phoneNumber;
private Integer tableNumber;
Expand Down
24 changes: 24 additions & 0 deletions application/src/main/java/com/terte/entity/order/Order.java
Original file line number Diff line number Diff line change
@@ -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<OrderItem> orderItemList;
private OrderType orderType;
private String phoneNumber;
private Integer tableNumber;
}
20 changes: 20 additions & 0 deletions application/src/main/java/com/terte/entity/order/OrderItem.java
Original file line number Diff line number Diff line change
@@ -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<SelectedOption> selectedOptions;
}
Original file line number Diff line number Diff line change
@@ -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<Choice> selectedChoices;
}
Original file line number Diff line number Diff line change
@@ -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<Long, Order> 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);
}
}

0 comments on commit 5d1e53b

Please sign in to comment.