From b9834ce9fcccb68cc5707833e14bf3e6f754a51a Mon Sep 17 00:00:00 2001 From: jang-yujin Date: Thu, 26 Jan 2023 19:08:37 +0900 Subject: [PATCH] =?UTF-8?q?feat[#1]=20:=20order=20domain=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/noriton/team9/domain/Order.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/com/noriton/team9/domain/Order.java diff --git a/src/main/java/com/noriton/team9/domain/Order.java b/src/main/java/com/noriton/team9/domain/Order.java new file mode 100644 index 0000000..1894aa4 --- /dev/null +++ b/src/main/java/com/noriton/team9/domain/Order.java @@ -0,0 +1,46 @@ +package com.noriton.team9.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.time.LocalDateTime; + +@Entity +@Getter @Setter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Order { + + @Id @GeneratedValue + @Column(name = "order_id") + private Long id; + + private int count; + + private String address; + + private String size; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "item_id") + private Item item; + private LocalDateTime orderDate; + + private int totalPrice; + + //==생성 메서드==// + public static Order createOrder(int count, String address, String size, Item item){ + Order order = new Order(); + order.setCount(count); + order.setAddress(address); + order.setSize(size); + order.setItem(item); + order.setOrderDate(LocalDateTime.now()); + order.setTotalPrice(count * item.getPrice()); + return order; + } + + +}