From e9efc1d44acf380eccd48fc1eb01126ee27f1c00 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sat, 29 Jul 2023 22:57:00 +0900 Subject: [PATCH 01/21] =?UTF-8?q?feat:=20Order=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/Order.java | 43 +++++++++++++++++++ .../springbootjpa/domain/OrderStatus.java | 6 +++ 2 files changed, 49 insertions(+) create mode 100644 src/main/java/com/programmers/springbootjpa/domain/Order.java create mode 100644 src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java diff --git a/src/main/java/com/programmers/springbootjpa/domain/Order.java b/src/main/java/com/programmers/springbootjpa/domain/Order.java new file mode 100644 index 000000000..b9418c188 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/domain/Order.java @@ -0,0 +1,43 @@ +package com.programmers.springbootjpa.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.NoArgsConstructor; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "orders") +public class Order { + + @Id + @Column(name = "id") + private String uuid; + + @Column(name = "order_datetime", columnDefinition = "TIMESTAMP") + private LocalDateTime orderDatetime; + + @Enumerated(EnumType.STRING) + private OrderStatus orderStatus; + + @Column(name = "memo", columnDefinition = "TEXT") + private String memo; + + @Column(name = "member_id") + private Long memberId; + + @Builder + public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, String memo, Long memberId) { + this.uuid = uuid; + this.orderDatetime = orderDatetime; + this.orderStatus = orderStatus; + this.memo = memo; + this.memberId = memberId; + } +} diff --git a/src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java b/src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java new file mode 100644 index 000000000..5e0e644b9 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java @@ -0,0 +1,6 @@ +package com.programmers.springbootjpa.domain; + +public enum OrderStatus { + OPENED, + CANCELLED +} From 25fd6b6f81c41b34957357221920b7875e9cdf6c Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sat, 29 Jul 2023 23:02:19 +0900 Subject: [PATCH 02/21] =?UTF-8?q?refactor:=20orders=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/programmers/springbootjpa/domain/Order.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/domain/Order.java b/src/main/java/com/programmers/springbootjpa/domain/Order.java index b9418c188..3b5937776 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Order.java +++ b/src/main/java/com/programmers/springbootjpa/domain/Order.java @@ -17,19 +17,20 @@ public class Order { @Id - @Column(name = "id") + @Column(name = "id", nullable = false) private String uuid; - @Column(name = "order_datetime", columnDefinition = "TIMESTAMP") + @Column(name = "order_datetime", columnDefinition = "TIMESTAMP", nullable = false) private LocalDateTime orderDatetime; @Enumerated(EnumType.STRING) + @Column(name = "order_status", nullable = false) private OrderStatus orderStatus; @Column(name = "memo", columnDefinition = "TEXT") private String memo; - @Column(name = "member_id") + @Column(name = "member_id", nullable = false) private Long memberId; @Builder From d9b65f4e585d2f12c3ce01ce43ab3cd1a47b8f78 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sat, 29 Jul 2023 23:04:42 +0900 Subject: [PATCH 03/21] =?UTF-8?q?refactor:=20Customer=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EC=BB=AC=EB=9F=BC=20=EC=86=8D=EC=84=B1=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/programmers/springbootjpa/domain/Customer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/programmers/springbootjpa/domain/Customer.java b/src/main/java/com/programmers/springbootjpa/domain/Customer.java index 9d2e9eaac..f0ee688d4 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Customer.java +++ b/src/main/java/com/programmers/springbootjpa/domain/Customer.java @@ -26,7 +26,7 @@ public class Customer { @Column(name = "age", nullable = false) private Integer age; - @Column(name = "nick_name", nullable = false) + @Column(name = "nick_name", nullable = false, unique = true, length = 20) private String nickName; @Embedded From 710b5e5c346b2cda1bef181699646b2aa49ca056 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sat, 29 Jul 2023 23:14:02 +0900 Subject: [PATCH 04/21] =?UTF-8?q?feat:=20Item=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/Item.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/programmers/springbootjpa/domain/Item.java diff --git a/src/main/java/com/programmers/springbootjpa/domain/Item.java b/src/main/java/com/programmers/springbootjpa/domain/Item.java new file mode 100644 index 000000000..7bd0c5f61 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/domain/Item.java @@ -0,0 +1,31 @@ +package com.programmers.springbootjpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "item") +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Item { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; + + private Integer price; + private Integer stockQuantity; + + @Builder + public Item(Integer price, Integer stockQuantity) { + this.price = price; + this.stockQuantity = stockQuantity; + } +} From bf236137243a95a4943f10f1d320abbdd94afc5d Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sat, 29 Jul 2023 23:25:15 +0900 Subject: [PATCH 05/21] =?UTF-8?q?feat:=20OrderItem=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/OrderItem.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/programmers/springbootjpa/domain/OrderItem.java diff --git a/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java b/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java new file mode 100644 index 000000000..ab7571503 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java @@ -0,0 +1,41 @@ +package com.programmers.springbootjpa.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@Table(name = "order_item") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class OrderItem { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; + + private Integer price; + + private Integer quantity; + + @Column(name = "order_id", nullable = false) + private String orderId; + + @Column(name = "item_id", nullable = false) + private Long itemId; + + @Builder + public OrderItem(Integer price, Integer quantity, String orderId, Long itemId) { + this.price = price; + this.quantity = quantity; + this.orderId = orderId; + this.itemId = itemId; + } +} From ae6d950b1fb9763fcea863588fd9b400c743a30f Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sat, 29 Jul 2023 23:45:04 +0900 Subject: [PATCH 06/21] =?UTF-8?q?feat:=20Customer=EC=99=80=20Order=20?= =?UTF-8?q?=EC=96=91=EB=B0=A9=ED=96=A5=20=EC=97=B0=EA=B4=80=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../programmers/springbootjpa/domain/Customer.java | 6 ++++++ .../programmers/springbootjpa/domain/Order.java | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/domain/Customer.java b/src/main/java/com/programmers/springbootjpa/domain/Customer.java index f0ee688d4..2a8353412 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Customer.java +++ b/src/main/java/com/programmers/springbootjpa/domain/Customer.java @@ -6,6 +6,9 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import java.util.ArrayList; +import java.util.List; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -32,6 +35,9 @@ public class Customer { @Embedded private Address address; + @OneToMany(mappedBy = "customer") + private List orders = new ArrayList<>(); + @Builder public Customer(String name, Integer age, String nickName, Address address) { this.name = name; diff --git a/src/main/java/com/programmers/springbootjpa/domain/Order.java b/src/main/java/com/programmers/springbootjpa/domain/Order.java index 3b5937776..9a0aaa8f5 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Order.java +++ b/src/main/java/com/programmers/springbootjpa/domain/Order.java @@ -4,7 +4,10 @@ import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import java.time.LocalDateTime; import lombok.AccessLevel; @@ -30,15 +33,16 @@ public class Order { @Column(name = "memo", columnDefinition = "TEXT") private String memo; - @Column(name = "member_id", nullable = false) - private Long memberId; - + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "customer_id", referencedColumnName = "id") + private Customer customer; + @Builder - public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, String memo, Long memberId) { + public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, String memo, Customer customer) { this.uuid = uuid; this.orderDatetime = orderDatetime; this.orderStatus = orderStatus; this.memo = memo; - this.memberId = memberId; + this.customer = customer; } } From 5af566aa4b75dc9e768b5ee653ec01d0827b07cd Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sun, 30 Jul 2023 00:25:57 +0900 Subject: [PATCH 07/21] =?UTF-8?q?feat:=20Order=EC=99=80=20OrderItem,=20Ord?= =?UTF-8?q?erItem=EA=B3=BC=20Item=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20?= =?UTF-8?q?=EB=A7=A4=ED=95=91=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/Order.java | 2 +- .../springbootjpa/domain/OrderItem.java | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/domain/Order.java b/src/main/java/com/programmers/springbootjpa/domain/Order.java index 9a0aaa8f5..35c2eea20 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Order.java +++ b/src/main/java/com/programmers/springbootjpa/domain/Order.java @@ -36,7 +36,7 @@ public class Order { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "customer_id", referencedColumnName = "id") private Customer customer; - + @Builder public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, String memo, Customer customer) { this.uuid = uuid; diff --git a/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java b/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java index ab7571503..c92e078b9 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java +++ b/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java @@ -1,10 +1,12 @@ package com.programmers.springbootjpa.domain; -import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Builder; @@ -25,17 +27,19 @@ public class OrderItem { private Integer quantity; - @Column(name = "order_id", nullable = false) - private String orderId; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "order_id", referencedColumnName = "id") + private Order order; - @Column(name = "item_id", nullable = false) - private Long itemId; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "item_id", referencedColumnName = "id") + private Item item; @Builder - public OrderItem(Integer price, Integer quantity, String orderId, Long itemId) { + public OrderItem(Integer price, Integer quantity, Order order, Item item) { this.price = price; this.quantity = quantity; - this.orderId = orderId; - this.itemId = itemId; + this.order = order; + this.item = item; } } From 9f20261d1d3ab6a8a1cf008702d2a07b1d781fa4 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sun, 30 Jul 2023 00:32:46 +0900 Subject: [PATCH 08/21] =?UTF-8?q?refactor:=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EA=B5=AC=EC=84=B1=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/{ => customer}/Address.java | 2 +- .../springbootjpa/domain/{ => customer}/Customer.java | 3 ++- .../programmers/springbootjpa/domain/{ => item}/Item.java | 2 +- .../springbootjpa/domain/{ => order}/Order.java | 3 ++- .../springbootjpa/domain/{ => order}/OrderItem.java | 3 ++- .../springbootjpa/domain/{ => order}/OrderStatus.java | 2 +- .../springbootjpa/dto/request/CustomerCreateRequest.java | 4 ++-- .../springbootjpa/dto/request/CustomerUpdateRequest.java | 2 +- .../springbootjpa/dto/response/CustomerResponse.java | 4 ++-- .../springbootjpa/repository/CustomerRepository.java | 2 +- .../springbootjpa/service/CustomerService.java | 2 +- .../programmers/springbootjpa/PersistenceContextTest.java | 8 ++++---- 12 files changed, 20 insertions(+), 17 deletions(-) rename src/main/java/com/programmers/springbootjpa/domain/{ => customer}/Address.java (92%) rename src/main/java/com/programmers/springbootjpa/domain/{ => customer}/Customer.java (92%) rename src/main/java/com/programmers/springbootjpa/domain/{ => item}/Item.java (93%) rename src/main/java/com/programmers/springbootjpa/domain/{ => order}/Order.java (92%) rename src/main/java/com/programmers/springbootjpa/domain/{ => order}/OrderItem.java (91%) rename src/main/java/com/programmers/springbootjpa/domain/{ => order}/OrderStatus.java (51%) diff --git a/src/main/java/com/programmers/springbootjpa/domain/Address.java b/src/main/java/com/programmers/springbootjpa/domain/customer/Address.java similarity index 92% rename from src/main/java/com/programmers/springbootjpa/domain/Address.java rename to src/main/java/com/programmers/springbootjpa/domain/customer/Address.java index 47b087c2b..614317061 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Address.java +++ b/src/main/java/com/programmers/springbootjpa/domain/customer/Address.java @@ -1,4 +1,4 @@ -package com.programmers.springbootjpa.domain; +package com.programmers.springbootjpa.domain.customer; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; diff --git a/src/main/java/com/programmers/springbootjpa/domain/Customer.java b/src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java similarity index 92% rename from src/main/java/com/programmers/springbootjpa/domain/Customer.java rename to src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java index 2a8353412..be57958c0 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Customer.java +++ b/src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java @@ -1,5 +1,6 @@ -package com.programmers.springbootjpa.domain; +package com.programmers.springbootjpa.domain.customer; +import com.programmers.springbootjpa.domain.order.Order; import jakarta.persistence.Column; import jakarta.persistence.Embedded; import jakarta.persistence.Entity; diff --git a/src/main/java/com/programmers/springbootjpa/domain/Item.java b/src/main/java/com/programmers/springbootjpa/domain/item/Item.java similarity index 93% rename from src/main/java/com/programmers/springbootjpa/domain/Item.java rename to src/main/java/com/programmers/springbootjpa/domain/item/Item.java index 7bd0c5f61..18149942a 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Item.java +++ b/src/main/java/com/programmers/springbootjpa/domain/item/Item.java @@ -1,4 +1,4 @@ -package com.programmers.springbootjpa.domain; +package com.programmers.springbootjpa.domain.item; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/src/main/java/com/programmers/springbootjpa/domain/Order.java b/src/main/java/com/programmers/springbootjpa/domain/order/Order.java similarity index 92% rename from src/main/java/com/programmers/springbootjpa/domain/Order.java rename to src/main/java/com/programmers/springbootjpa/domain/order/Order.java index 35c2eea20..dc4ebe197 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/Order.java +++ b/src/main/java/com/programmers/springbootjpa/domain/order/Order.java @@ -1,5 +1,6 @@ -package com.programmers.springbootjpa.domain; +package com.programmers.springbootjpa.domain.order; +import com.programmers.springbootjpa.domain.customer.Customer; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; diff --git a/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java b/src/main/java/com/programmers/springbootjpa/domain/order/OrderItem.java similarity index 91% rename from src/main/java/com/programmers/springbootjpa/domain/OrderItem.java rename to src/main/java/com/programmers/springbootjpa/domain/order/OrderItem.java index c92e078b9..dfb80d2d1 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/OrderItem.java +++ b/src/main/java/com/programmers/springbootjpa/domain/order/OrderItem.java @@ -1,5 +1,6 @@ -package com.programmers.springbootjpa.domain; +package com.programmers.springbootjpa.domain.order; +import com.programmers.springbootjpa.domain.item.Item; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; diff --git a/src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java b/src/main/java/com/programmers/springbootjpa/domain/order/OrderStatus.java similarity index 51% rename from src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java rename to src/main/java/com/programmers/springbootjpa/domain/order/OrderStatus.java index 5e0e644b9..eb6885923 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/OrderStatus.java +++ b/src/main/java/com/programmers/springbootjpa/domain/order/OrderStatus.java @@ -1,4 +1,4 @@ -package com.programmers.springbootjpa.domain; +package com.programmers.springbootjpa.domain.order; public enum OrderStatus { OPENED, diff --git a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java index 3616e09b0..8dd48b952 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java +++ b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java @@ -1,7 +1,7 @@ package com.programmers.springbootjpa.dto.request; -import com.programmers.springbootjpa.domain.Address; -import com.programmers.springbootjpa.domain.Customer; +import com.programmers.springbootjpa.domain.customer.Address; +import com.programmers.springbootjpa.domain.customer.Customer; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; diff --git a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java index db878de91..6d6c69d0d 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java +++ b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java @@ -1,6 +1,6 @@ package com.programmers.springbootjpa.dto.request; -import com.programmers.springbootjpa.domain.Address; +import com.programmers.springbootjpa.domain.customer.Address; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.PositiveOrZero; diff --git a/src/main/java/com/programmers/springbootjpa/dto/response/CustomerResponse.java b/src/main/java/com/programmers/springbootjpa/dto/response/CustomerResponse.java index 53a2914e5..78a213b5f 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/response/CustomerResponse.java +++ b/src/main/java/com/programmers/springbootjpa/dto/response/CustomerResponse.java @@ -1,7 +1,7 @@ package com.programmers.springbootjpa.dto.response; -import com.programmers.springbootjpa.domain.Address; -import com.programmers.springbootjpa.domain.Customer; +import com.programmers.springbootjpa.domain.customer.Address; +import com.programmers.springbootjpa.domain.customer.Customer; import lombok.Getter; @Getter diff --git a/src/main/java/com/programmers/springbootjpa/repository/CustomerRepository.java b/src/main/java/com/programmers/springbootjpa/repository/CustomerRepository.java index bf639bb3a..1678bc758 100644 --- a/src/main/java/com/programmers/springbootjpa/repository/CustomerRepository.java +++ b/src/main/java/com/programmers/springbootjpa/repository/CustomerRepository.java @@ -1,6 +1,6 @@ package com.programmers.springbootjpa.repository; -import com.programmers.springbootjpa.domain.Customer; +import com.programmers.springbootjpa.domain.customer.Customer; import org.springframework.data.jpa.repository.JpaRepository; public interface CustomerRepository extends JpaRepository { diff --git a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java index 954c13447..d439e0bc5 100644 --- a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java +++ b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java @@ -1,6 +1,6 @@ package com.programmers.springbootjpa.service; -import com.programmers.springbootjpa.domain.Customer; +import com.programmers.springbootjpa.domain.customer.Customer; import com.programmers.springbootjpa.dto.request.CustomerCreateRequest; import com.programmers.springbootjpa.dto.request.CustomerUpdateRequest; import com.programmers.springbootjpa.dto.response.CustomerResponse; diff --git a/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java b/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java index a0de5a140..4e895c937 100644 --- a/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java +++ b/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java @@ -2,8 +2,8 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.programmers.springbootjpa.domain.Address; -import com.programmers.springbootjpa.domain.Customer; +import com.programmers.springbootjpa.domain.customer.Address; +import com.programmers.springbootjpa.domain.customer.Customer; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.EntityTransaction; @@ -14,10 +14,10 @@ @SpringBootTest public class PersistenceContextTest { - + @Autowired EntityManagerFactory entityManagerFactory; - + @Test @DisplayName("고객을 영속 상태로 만들 수 있다.") void persistCustomer() { From 07a953ebfca631b689a4a60234c55dceaf3d1be2 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sun, 30 Jul 2023 00:35:40 +0900 Subject: [PATCH 09/21] =?UTF-8?q?feat:=20Item,=20OrderItem,=20Order=20Repo?= =?UTF-8?q?sitory=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/repository/ItemRepository.java | 8 ++++++++ .../springbootjpa/repository/OrderItemRepository.java | 8 ++++++++ .../springbootjpa/repository/OrderRepository.java | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/main/java/com/programmers/springbootjpa/repository/ItemRepository.java create mode 100644 src/main/java/com/programmers/springbootjpa/repository/OrderItemRepository.java create mode 100644 src/main/java/com/programmers/springbootjpa/repository/OrderRepository.java diff --git a/src/main/java/com/programmers/springbootjpa/repository/ItemRepository.java b/src/main/java/com/programmers/springbootjpa/repository/ItemRepository.java new file mode 100644 index 000000000..962dee840 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/repository/ItemRepository.java @@ -0,0 +1,8 @@ +package com.programmers.springbootjpa.repository; + +import com.programmers.springbootjpa.domain.item.Item; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ItemRepository extends JpaRepository { + +} diff --git a/src/main/java/com/programmers/springbootjpa/repository/OrderItemRepository.java b/src/main/java/com/programmers/springbootjpa/repository/OrderItemRepository.java new file mode 100644 index 000000000..6cf3db298 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/repository/OrderItemRepository.java @@ -0,0 +1,8 @@ +package com.programmers.springbootjpa.repository; + +import com.programmers.springbootjpa.domain.order.OrderItem; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface OrderItemRepository extends JpaRepository { + +} diff --git a/src/main/java/com/programmers/springbootjpa/repository/OrderRepository.java b/src/main/java/com/programmers/springbootjpa/repository/OrderRepository.java new file mode 100644 index 000000000..c9a95ea21 --- /dev/null +++ b/src/main/java/com/programmers/springbootjpa/repository/OrderRepository.java @@ -0,0 +1,8 @@ +package com.programmers.springbootjpa.repository; + +import com.programmers.springbootjpa.domain.order.Order; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface OrderRepository extends JpaRepository { + +} From 4b0946b09e9c774f514e7159ee66957a3009d9eb Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sun, 30 Jul 2023 01:49:02 +0900 Subject: [PATCH 10/21] =?UTF-8?q?feat:=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/item/Item.java | 4 +- .../springbootjpa/domain/order/Order.java | 13 +- .../springbootjpa/PersistenceContextTest.java | 4 +- .../repository/AssociationTest.java | 173 ++++++++++++++++++ 4 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java diff --git a/src/main/java/com/programmers/springbootjpa/domain/item/Item.java b/src/main/java/com/programmers/springbootjpa/domain/item/Item.java index 18149942a..02d92abfa 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/item/Item.java +++ b/src/main/java/com/programmers/springbootjpa/domain/item/Item.java @@ -20,11 +20,13 @@ public class Item { @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; + private String name; private Integer price; private Integer stockQuantity; @Builder - public Item(Integer price, Integer stockQuantity) { + public Item(String name, Integer price, Integer stockQuantity) { + this.name = name; this.price = price; this.stockQuantity = stockQuantity; } diff --git a/src/main/java/com/programmers/springbootjpa/domain/order/Order.java b/src/main/java/com/programmers/springbootjpa/domain/order/Order.java index dc4ebe197..6e606f513 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/order/Order.java +++ b/src/main/java/com/programmers/springbootjpa/domain/order/Order.java @@ -11,13 +11,16 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import java.time.LocalDateTime; +import java.util.Objects; import lombok.AccessLevel; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "orders") +@Getter public class Order { @Id @@ -39,11 +42,19 @@ public class Order { private Customer customer; @Builder - public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, String memo, Customer customer) { + public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, String memo) { this.uuid = uuid; this.orderDatetime = orderDatetime; this.orderStatus = orderStatus; this.memo = memo; + } + + public void setCustomer(Customer customer) { + if (Objects.nonNull(this.customer)) { + this.customer.getOrders().remove(this); + } + this.customer = customer; + customer.getOrders().add(this); } } diff --git a/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java b/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java index 4e895c937..07046a426 100644 --- a/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java +++ b/src/test/java/com/programmers/springbootjpa/PersistenceContextTest.java @@ -13,8 +13,8 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -public class PersistenceContextTest { - +class PersistenceContextTest { + @Autowired EntityManagerFactory entityManagerFactory; diff --git a/src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java b/src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java new file mode 100644 index 000000000..d3dcf0fbb --- /dev/null +++ b/src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java @@ -0,0 +1,173 @@ +package com.programmers.springbootjpa.repository; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.programmers.springbootjpa.domain.customer.Address; +import com.programmers.springbootjpa.domain.customer.Customer; +import com.programmers.springbootjpa.domain.item.Item; +import com.programmers.springbootjpa.domain.order.Order; +import com.programmers.springbootjpa.domain.order.OrderItem; +import com.programmers.springbootjpa.domain.order.OrderStatus; +import java.time.LocalDateTime; +import java.util.UUID; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest +@Transactional +class AssociationTest { + + @Autowired + CustomerRepository customerRepository; + @Autowired + ItemRepository itemRepository; + @Autowired + OrderItemRepository orderItemRepository; + @Autowired + OrderRepository orderRepository; + + @Test + @DisplayName("고객을 통해 주문 리스트를 조회할 수 있다.") + void getOrdersByCustomer() { + Customer customer = Customer.builder() + .name("hyunHo") + .nickName("changHyun") + .age(28) + .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) + .build(); + + Order order1 = Order.builder() + .uuid(UUID.randomUUID().toString()) + .orderStatus(OrderStatus.OPENED) + .orderDatetime(LocalDateTime.now()) + .memo("메모1") + .build(); + + order1.setCustomer(customer); + + Order order2 = Order.builder() + .uuid(UUID.randomUUID().toString()) + .orderStatus(OrderStatus.OPENED) + .orderDatetime(LocalDateTime.now()) + .memo("메모2") + .build(); + + order2.setCustomer(customer); + + Customer savedCustomer = customerRepository.save(customer); + Order savedOrder1 = orderRepository.save(order1); + Order savedOrder2 = orderRepository.save(order2); + + assertThat(savedOrder1.getMemo()).isEqualTo(savedCustomer.getOrders().get(0).getMemo()); + assertThat(savedOrder2.getMemo()).isEqualTo(savedCustomer.getOrders().get(1).getMemo()); + } + + @Test + @DisplayName("주문에서 고객을 조회할 수 있다.") + void getCustomerByOrder() { + Customer customer = Customer.builder() + .name("hyunHo") + .nickName("changHyun") + .age(28) + .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) + .build(); + + Order order = Order.builder() + .uuid(UUID.randomUUID().toString()) + .orderStatus(OrderStatus.OPENED) + .orderDatetime(LocalDateTime.now()) + .memo("메모1") + .build(); + + order.setCustomer(customer); + + Customer savedCustomer = customerRepository.save(customer); + Order savedOrder = orderRepository.save(order); + + assertThat(savedCustomer.getNickName()).isEqualTo(savedOrder.getCustomer().getNickName()); + } + + @Test + @DisplayName("주문 아이템에서 주문을 조회할 수 있다.") + void getOrderByOrderItem() { + Customer customer = Customer.builder() + .name("hyunHo") + .nickName("changHyun") + .age(28) + .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) + .build(); + + Order order = Order.builder() + .uuid(UUID.randomUUID().toString()) + .orderStatus(OrderStatus.OPENED) + .orderDatetime(LocalDateTime.now()) + .memo("메모1") + .build(); + + order.setCustomer(customer); + + Item item = Item.builder() + .name("매운갈비찜") + .price(3000) + .stockQuantity(10) + .build(); + + OrderItem orderItem = OrderItem.builder() + .quantity(3) + .price(9000) + .item(item) + .order(order) + .build(); + + Customer savedCustomer = customerRepository.save(customer); + Order savedOrder = orderRepository.save(order); + Item savedItem = itemRepository.save(item); + OrderItem savedOrderItem = orderItemRepository.save(orderItem); + + assertThat(savedOrder.getUuid()).isEqualTo(savedOrderItem.getOrder().getUuid()); + } + + + @Test + @DisplayName("주문 아이템에서 아이템을 조회할 수 있다.") + void getItemByOrderItem() { + Customer customer = Customer.builder() + .name("hyunHo") + .nickName("changHyun") + .age(28) + .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) + .build(); + + Order order = Order.builder() + .uuid(UUID.randomUUID().toString()) + .orderStatus(OrderStatus.OPENED) + .orderDatetime(LocalDateTime.now()) + .memo("메모1") + .build(); + + order.setCustomer(customer); + + Item item = Item.builder() + .name("매운갈비찜") + .price(3000) + .stockQuantity(10) + .build(); + + OrderItem orderItem = OrderItem.builder() + .quantity(3) + .price(9000) + .item(item) + .order(order) + .build(); + + Customer savedCustomer = customerRepository.save(customer); + Order savedOrder = orderRepository.save(order); + Item savedItem = itemRepository.save(item); + OrderItem savedOrderItem = orderItemRepository.save(orderItem); + + assertThat(savedItem.getName()).isEqualTo(savedOrderItem.getItem().getName()); + } +} From 79abaee52bdc341c2c040590a505ee33a8a01a42 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Sun, 30 Jul 2023 01:50:01 +0900 Subject: [PATCH 11/21] =?UTF-8?q?refactor:=20AssociationTest=20=EB=94=94?= =?UTF-8?q?=EB=A0=89=ED=84=B0=EB=A6=AC=20=EC=9C=84=EC=B9=98=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 --- .../springbootjpa/{repository => }/AssociationTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename src/test/java/com/programmers/springbootjpa/{repository => }/AssociationTest.java (95%) diff --git a/src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java b/src/test/java/com/programmers/springbootjpa/AssociationTest.java similarity index 95% rename from src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java rename to src/test/java/com/programmers/springbootjpa/AssociationTest.java index d3dcf0fbb..9be1cd29d 100644 --- a/src/test/java/com/programmers/springbootjpa/repository/AssociationTest.java +++ b/src/test/java/com/programmers/springbootjpa/AssociationTest.java @@ -1,4 +1,4 @@ -package com.programmers.springbootjpa.repository; +package com.programmers.springbootjpa; import static org.assertj.core.api.Assertions.assertThat; @@ -8,6 +8,10 @@ import com.programmers.springbootjpa.domain.order.Order; import com.programmers.springbootjpa.domain.order.OrderItem; import com.programmers.springbootjpa.domain.order.OrderStatus; +import com.programmers.springbootjpa.repository.CustomerRepository; +import com.programmers.springbootjpa.repository.ItemRepository; +import com.programmers.springbootjpa.repository.OrderItemRepository; +import com.programmers.springbootjpa.repository.OrderRepository; import java.time.LocalDateTime; import java.util.UUID; import org.junit.jupiter.api.DisplayName; From 358544f24a86cfbde91d7882aab5024058822f85 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 15:57:45 +0900 Subject: [PATCH 12/21] =?UTF-8?q?refactor:=20controller=EC=97=90=EC=84=9C?= =?UTF-8?q?=20ResponseStatus=EB=A5=BC=20=ED=99=9C=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerController.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java index c25708b19..bfd87b023 100644 --- a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java +++ b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java @@ -8,7 +8,6 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -16,6 +15,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; @@ -27,37 +27,32 @@ public class CustomerController { private final CustomerService customerService; @PostMapping - public ResponseEntity createCustomer(@Valid @RequestBody CustomerCreateRequest customerCreateRequest) { + @ResponseStatus(HttpStatus.CREATED) + public void createCustomer(@Valid @RequestBody CustomerCreateRequest customerCreateRequest) { customerService.createCustomer(customerCreateRequest); - - return ResponseEntity.status(HttpStatus.CREATED).body(null); } @GetMapping("/{id}") - public ResponseEntity readCustomer(@PathVariable Long id) { - CustomerResponse customerResponse = customerService.readCustomer(id); - - return ResponseEntity.ok(customerResponse); + @ResponseStatus(HttpStatus.OK) + public CustomerResponse readCustomer(@PathVariable Long id) { + return customerService.readCustomer(id); } @GetMapping - public ResponseEntity> readAllCustomer() { - List customerResponses = customerService.readAllCustomer(); - - return ResponseEntity.ok(customerResponses); + @ResponseStatus(HttpStatus.OK) + public List readAllCustomer() { + return customerService.readAllCustomer(); } @PatchMapping - public ResponseEntity updateCustomer(@Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { + @ResponseStatus(HttpStatus.OK) + public void updateCustomer(@Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { customerService.updateCustomer(customerUpdateRequest); - - return ResponseEntity.ok(null); } @DeleteMapping("/{id}") - public ResponseEntity deleteCustomer(@PathVariable Long id) { + @ResponseStatus(HttpStatus.NO_CONTENT) + public void deleteCustomer(@PathVariable Long id) { customerService.deleteCustomer(id); - - return ResponseEntity.noContent().build(); } } From a34dee84c681ead157f9423a35dc7fdefd4d9c63 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 15:58:55 +0900 Subject: [PATCH 13/21] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/controller/CustomerController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java index bfd87b023..61ac61478 100644 --- a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java +++ b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java @@ -34,7 +34,7 @@ public void createCustomer(@Valid @RequestBody CustomerCreateRequest customerCre @GetMapping("/{id}") @ResponseStatus(HttpStatus.OK) - public CustomerResponse readCustomer(@PathVariable Long id) { + public CustomerResponse readCustomerById(@PathVariable Long id) { return customerService.readCustomer(id); } @@ -46,13 +46,13 @@ public List readAllCustomer() { @PatchMapping @ResponseStatus(HttpStatus.OK) - public void updateCustomer(@Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { + public void updateCustomerById(@Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { customerService.updateCustomer(customerUpdateRequest); } @DeleteMapping("/{id}") @ResponseStatus(HttpStatus.NO_CONTENT) - public void deleteCustomer(@PathVariable Long id) { + public void deleteCustomerById(@PathVariable Long id) { customerService.deleteCustomer(id); } } From 737fa9243d76d2e8883daf4da1e28fbb3c890421 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:02:06 +0900 Subject: [PATCH 14/21] =?UTF-8?q?refactor:=20update=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20rest=20api=20=EB=A1=9C=EC=A7=81=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 --- .../springbootjpa/controller/CustomerController.java | 6 +++--- .../springbootjpa/dto/request/CustomerUpdateRequest.java | 3 --- .../programmers/springbootjpa/service/CustomerService.java | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java index 61ac61478..506c603eb 100644 --- a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java +++ b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java @@ -44,10 +44,10 @@ public List readAllCustomer() { return customerService.readAllCustomer(); } - @PatchMapping + @PatchMapping("/{id}") @ResponseStatus(HttpStatus.OK) - public void updateCustomerById(@Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { - customerService.updateCustomer(customerUpdateRequest); + public void updateCustomerById(@PathVariable Long id, @Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { + customerService.updateCustomer(id, customerUpdateRequest); } @DeleteMapping("/{id}") diff --git a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java index 6d6c69d0d..935736781 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java +++ b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java @@ -3,7 +3,6 @@ import com.programmers.springbootjpa.domain.customer.Address; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.PositiveOrZero; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,8 +11,6 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class CustomerUpdateRequest { - @PositiveOrZero(message = "id값은 0이상 이어야합니다.") - private Long id; @NotBlank(message = "닉네임은 공백이거나 값이 없으면 안됩니다.") private String nickName; @NotNull(message = "주소값은 없을 수 없습니다.") diff --git a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java index d439e0bc5..ca53dd2cf 100644 --- a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java +++ b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java @@ -46,8 +46,8 @@ public CustomerResponse readCustomer(Long id) { } @Transactional - public void updateCustomer(CustomerUpdateRequest customerUpdateRequest) { - Customer customer = customerRepository.findById(customerUpdateRequest.getId()) + public void updateCustomer(Long id, CustomerUpdateRequest customerUpdateRequest) { + Customer customer = customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("업데이트 할 사용자가 없습니다.")); customer.changeNickName(customerUpdateRequest.getNickName()); From f5c3dc7e79fcaccb8edbbb48dcf39d5a79ead321 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:03:59 +0900 Subject: [PATCH 15/21] =?UTF-8?q?refactor:=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=EC=9D=B4=EB=B6=99=EC=9D=80=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=EB=AA=85=EA=B3=BC=20=ED=95=84=EB=93=9C=EB=AA=85?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=20=EA=B0=9C=ED=96=89=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/programmers/springbootjpa/domain/customer/Address.java | 2 ++ .../java/com/programmers/springbootjpa/domain/item/Item.java | 1 - .../springbootjpa/dto/request/CustomerCreateRequest.java | 3 +++ .../springbootjpa/dto/request/CustomerUpdateRequest.java | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/programmers/springbootjpa/domain/customer/Address.java b/src/main/java/com/programmers/springbootjpa/domain/customer/Address.java index 614317061..61a7ea75b 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/customer/Address.java +++ b/src/main/java/com/programmers/springbootjpa/domain/customer/Address.java @@ -13,8 +13,10 @@ public class Address { @Column(name = "street_address", nullable = false) private String streetAddress; + @Column(name = "detailed_address", nullable = false) private String detailedAddress; + @Column(name = "zip_code", nullable = false) private Integer zipCode; diff --git a/src/main/java/com/programmers/springbootjpa/domain/item/Item.java b/src/main/java/com/programmers/springbootjpa/domain/item/Item.java index 02d92abfa..ccbbc7c29 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/item/Item.java +++ b/src/main/java/com/programmers/springbootjpa/domain/item/Item.java @@ -19,7 +19,6 @@ public class Item { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; - private String name; private Integer price; private Integer stockQuantity; diff --git a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java index 8dd48b952..2a3f0af96 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java +++ b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java @@ -16,12 +16,15 @@ public class CustomerCreateRequest { @NotBlank(message = "이름은 공백이거나 값이 없으면 안됩니다.") private String name; + @Min(value = 1, message = "나이는 한살보다 많아야합니다.") @Max(value = 100, message = "나이는 백살보다 적여야합니다.") @NotNull(message = "나이는 값이 없으면 안됩니다.") private Integer age; + @NotBlank(message = "닉네임은 공백이거나 값이 없으면 안됩니다.") private String nickName; + @NotNull(message = "주소값은 없을 수 없습니다.") private Address address; diff --git a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java index 935736781..f6e85a921 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java +++ b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerUpdateRequest.java @@ -13,6 +13,7 @@ public class CustomerUpdateRequest { @NotBlank(message = "닉네임은 공백이거나 값이 없으면 안됩니다.") private String nickName; + @NotNull(message = "주소값은 없을 수 없습니다.") private Address address; From 39c94fe07c485e9497e50df1292cfcb1f4dc6e0a Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:11:28 +0900 Subject: [PATCH 16/21] =?UTF-8?q?refactor:=20message=20=EC=98=A4=ED=83=80?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/dto/request/CustomerCreateRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java index 2a3f0af96..3b5b6f893 100644 --- a/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java +++ b/src/main/java/com/programmers/springbootjpa/dto/request/CustomerCreateRequest.java @@ -18,7 +18,7 @@ public class CustomerCreateRequest { private String name; @Min(value = 1, message = "나이는 한살보다 많아야합니다.") - @Max(value = 100, message = "나이는 백살보다 적여야합니다.") + @Max(value = 100, message = "나이는 백살보다 적어야합니다.") @NotNull(message = "나이는 값이 없으면 안됩니다.") private Integer age; From a1af086a46512fb6d1308409ca8138804224a957 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:25:53 +0900 Subject: [PATCH 17/21] =?UTF-8?q?refactor:=20service=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/controller/CustomerController.java | 6 +++--- .../programmers/springbootjpa/service/CustomerService.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java index 506c603eb..9d2b92fd5 100644 --- a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java +++ b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java @@ -35,7 +35,7 @@ public void createCustomer(@Valid @RequestBody CustomerCreateRequest customerCre @GetMapping("/{id}") @ResponseStatus(HttpStatus.OK) public CustomerResponse readCustomerById(@PathVariable Long id) { - return customerService.readCustomer(id); + return customerService.readCustomerById(id); } @GetMapping @@ -47,12 +47,12 @@ public List readAllCustomer() { @PatchMapping("/{id}") @ResponseStatus(HttpStatus.OK) public void updateCustomerById(@PathVariable Long id, @Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { - customerService.updateCustomer(id, customerUpdateRequest); + customerService.updateCustomerById(id, customerUpdateRequest); } @DeleteMapping("/{id}") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteCustomerById(@PathVariable Long id) { - customerService.deleteCustomer(id); + customerService.deleteCustomerById(id); } } diff --git a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java index ca53dd2cf..b09d65efa 100644 --- a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java +++ b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java @@ -38,7 +38,7 @@ public List readAllCustomer() { .toList(); } - public CustomerResponse readCustomer(Long id) { + public CustomerResponse readCustomerById(Long id) { Customer customer = customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("찾는 사용자가 없습니다.")); @@ -46,7 +46,7 @@ public CustomerResponse readCustomer(Long id) { } @Transactional - public void updateCustomer(Long id, CustomerUpdateRequest customerUpdateRequest) { + public void updateCustomerById(Long id, CustomerUpdateRequest customerUpdateRequest) { Customer customer = customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("업데이트 할 사용자가 없습니다.")); @@ -55,7 +55,7 @@ public void updateCustomer(Long id, CustomerUpdateRequest customerUpdateRequest) } @Transactional - public void deleteCustomer(Long id) { + public void deleteCustomerById(Long id) { customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("삭제할 사용자가 없습니다.")); From c64bb487544c98388bfc5f417a22eb76621da64d Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:31:06 +0900 Subject: [PATCH 18/21] =?UTF-8?q?refactor:=20customer=EB=A5=BC=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerController.java | 20 +++++++++---------- .../service/CustomerService.java | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java index 9d2b92fd5..35be9648a 100644 --- a/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java +++ b/src/main/java/com/programmers/springbootjpa/controller/CustomerController.java @@ -28,31 +28,31 @@ public class CustomerController { @PostMapping @ResponseStatus(HttpStatus.CREATED) - public void createCustomer(@Valid @RequestBody CustomerCreateRequest customerCreateRequest) { - customerService.createCustomer(customerCreateRequest); + public void create(@Valid @RequestBody CustomerCreateRequest customerCreateRequest) { + customerService.create(customerCreateRequest); } @GetMapping("/{id}") @ResponseStatus(HttpStatus.OK) - public CustomerResponse readCustomerById(@PathVariable Long id) { - return customerService.readCustomerById(id); + public CustomerResponse readById(@PathVariable Long id) { + return customerService.readById(id); } @GetMapping @ResponseStatus(HttpStatus.OK) - public List readAllCustomer() { - return customerService.readAllCustomer(); + public List readAll() { + return customerService.readAll(); } @PatchMapping("/{id}") @ResponseStatus(HttpStatus.OK) - public void updateCustomerById(@PathVariable Long id, @Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { - customerService.updateCustomerById(id, customerUpdateRequest); + public void updateById(@PathVariable Long id, @Valid @RequestBody CustomerUpdateRequest customerUpdateRequest) { + customerService.updateById(id, customerUpdateRequest); } @DeleteMapping("/{id}") @ResponseStatus(HttpStatus.NO_CONTENT) - public void deleteCustomerById(@PathVariable Long id) { - customerService.deleteCustomerById(id); + public void deleteById(@PathVariable Long id) { + customerService.deleteById(id); } } diff --git a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java index b09d65efa..8bc00068e 100644 --- a/src/main/java/com/programmers/springbootjpa/service/CustomerService.java +++ b/src/main/java/com/programmers/springbootjpa/service/CustomerService.java @@ -19,7 +19,7 @@ public class CustomerService { private final CustomerRepository customerRepository; @Transactional - public void createCustomer(CustomerCreateRequest customerCreateRequest) { + public void create(CustomerCreateRequest customerCreateRequest) { Customer customer = Customer.builder() .name(customerCreateRequest.getName()) .age(customerCreateRequest.getAge()) @@ -30,7 +30,7 @@ public void createCustomer(CustomerCreateRequest customerCreateRequest) { customerRepository.save(customer); } - public List readAllCustomer() { + public List readAll() { List customers = customerRepository.findAll(); return customers.stream() @@ -38,7 +38,7 @@ public List readAllCustomer() { .toList(); } - public CustomerResponse readCustomerById(Long id) { + public CustomerResponse readById(Long id) { Customer customer = customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("찾는 사용자가 없습니다.")); @@ -46,7 +46,7 @@ public CustomerResponse readCustomerById(Long id) { } @Transactional - public void updateCustomerById(Long id, CustomerUpdateRequest customerUpdateRequest) { + public void updateById(Long id, CustomerUpdateRequest customerUpdateRequest) { Customer customer = customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("업데이트 할 사용자가 없습니다.")); @@ -55,7 +55,7 @@ public void updateCustomerById(Long id, CustomerUpdateRequest customerUpdateRequ } @Transactional - public void deleteCustomerById(Long id) { + public void deleteById(Long id) { customerRepository.findById(id) .orElseThrow(() -> new NoSuchElementException("삭제할 사용자가 없습니다.")); From e3a73f60c72c82836f8243d3877fa1f399a6de2e Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:40:53 +0900 Subject: [PATCH 19/21] =?UTF-8?q?refactor:=20=EC=97=B0=EA=B4=80=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/domain/customer/Customer.java | 13 +++++++++++++ .../springbootjpa/domain/order/Order.java | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java b/src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java index be57958c0..ea3b0a59c 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java +++ b/src/main/java/com/programmers/springbootjpa/domain/customer/Customer.java @@ -9,6 +9,7 @@ import jakarta.persistence.Id; import jakarta.persistence.OneToMany; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import lombok.AccessLevel; import lombok.Builder; @@ -47,6 +48,18 @@ public Customer(String name, Integer age, String nickName, Address address) { this.address = address; } + public List getOrders() { + return Collections.unmodifiableList(orders); + } + + public void add(Order order) { + this.orders.add(order); + } + + public void remove(Order order) { + this.orders.remove(order); + } + public void changeNickName(String nickName) { this.nickName = nickName; } diff --git a/src/main/java/com/programmers/springbootjpa/domain/order/Order.java b/src/main/java/com/programmers/springbootjpa/domain/order/Order.java index 6e606f513..66a847892 100644 --- a/src/main/java/com/programmers/springbootjpa/domain/order/Order.java +++ b/src/main/java/com/programmers/springbootjpa/domain/order/Order.java @@ -51,10 +51,10 @@ public Order(String uuid, LocalDateTime orderDatetime, OrderStatus orderStatus, public void setCustomer(Customer customer) { if (Objects.nonNull(this.customer)) { - this.customer.getOrders().remove(this); + this.customer.remove(this); } this.customer = customer; - customer.getOrders().add(this); + customer.add(this); } } From c6668a71cd790d1a8d7e81d40ee449dc775c439e Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 16:50:54 +0900 Subject: [PATCH 20/21] =?UTF-8?q?refactor:=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=97=90=20=ED=95=9C=EC=B9=B8=EC=94=A9=20?= =?UTF-8?q?=EA=B0=9C=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/programmers/springbootjpa/AssociationTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/com/programmers/springbootjpa/AssociationTest.java b/src/test/java/com/programmers/springbootjpa/AssociationTest.java index 9be1cd29d..788037b60 100644 --- a/src/test/java/com/programmers/springbootjpa/AssociationTest.java +++ b/src/test/java/com/programmers/springbootjpa/AssociationTest.java @@ -26,10 +26,13 @@ class AssociationTest { @Autowired CustomerRepository customerRepository; + @Autowired ItemRepository itemRepository; + @Autowired OrderItemRepository orderItemRepository; + @Autowired OrderRepository orderRepository; From e136bc8134b3993c0e081bce3ed46ff8ab0c61c1 Mon Sep 17 00:00:00 2001 From: changhyeon Date: Fri, 4 Aug 2023 17:03:56 +0900 Subject: [PATCH 21/21] =?UTF-8?q?test:=20beforeEach=EB=A1=9C=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EA=B0=84=EA=B2=B0?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootjpa/AssociationTest.java | 79 ++++++------------- 1 file changed, 25 insertions(+), 54 deletions(-) diff --git a/src/test/java/com/programmers/springbootjpa/AssociationTest.java b/src/test/java/com/programmers/springbootjpa/AssociationTest.java index 788037b60..b931a0d44 100644 --- a/src/test/java/com/programmers/springbootjpa/AssociationTest.java +++ b/src/test/java/com/programmers/springbootjpa/AssociationTest.java @@ -14,14 +14,18 @@ import com.programmers.springbootjpa.repository.OrderRepository; import java.time.LocalDateTime; import java.util.UUID; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; @SpringBootTest @Transactional +@TestInstance(Lifecycle.PER_CLASS) class AssociationTest { @Autowired @@ -36,16 +40,31 @@ class AssociationTest { @Autowired OrderRepository orderRepository; - @Test - @DisplayName("고객을 통해 주문 리스트를 조회할 수 있다.") - void getOrdersByCustomer() { - Customer customer = Customer.builder() + private Customer customer; + private Order order; + + @BeforeEach + void beforeEach() { + customer = Customer.builder() .name("hyunHo") .nickName("changHyun") .age(28) .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) .build(); + order = Order.builder() + .uuid(UUID.randomUUID().toString()) + .orderStatus(OrderStatus.OPENED) + .orderDatetime(LocalDateTime.now()) + .memo("메모1") + .build(); + + order.setCustomer(customer); + } + + @Test + @DisplayName("고객을 통해 주문 리스트를 조회할 수 있다.") + void getOrdersByCustomer() { Order order1 = Order.builder() .uuid(UUID.randomUUID().toString()) .orderStatus(OrderStatus.OPENED) @@ -68,29 +87,13 @@ void getOrdersByCustomer() { Order savedOrder1 = orderRepository.save(order1); Order savedOrder2 = orderRepository.save(order2); - assertThat(savedOrder1.getMemo()).isEqualTo(savedCustomer.getOrders().get(0).getMemo()); - assertThat(savedOrder2.getMemo()).isEqualTo(savedCustomer.getOrders().get(1).getMemo()); + assertThat(savedOrder1.getMemo()).isEqualTo(savedCustomer.getOrders().get(1).getMemo()); + assertThat(savedOrder2.getMemo()).isEqualTo(savedCustomer.getOrders().get(2).getMemo()); } @Test @DisplayName("주문에서 고객을 조회할 수 있다.") void getCustomerByOrder() { - Customer customer = Customer.builder() - .name("hyunHo") - .nickName("changHyun") - .age(28) - .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) - .build(); - - Order order = Order.builder() - .uuid(UUID.randomUUID().toString()) - .orderStatus(OrderStatus.OPENED) - .orderDatetime(LocalDateTime.now()) - .memo("메모1") - .build(); - - order.setCustomer(customer); - Customer savedCustomer = customerRepository.save(customer); Order savedOrder = orderRepository.save(order); @@ -100,22 +103,6 @@ void getCustomerByOrder() { @Test @DisplayName("주문 아이템에서 주문을 조회할 수 있다.") void getOrderByOrderItem() { - Customer customer = Customer.builder() - .name("hyunHo") - .nickName("changHyun") - .age(28) - .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) - .build(); - - Order order = Order.builder() - .uuid(UUID.randomUUID().toString()) - .orderStatus(OrderStatus.OPENED) - .orderDatetime(LocalDateTime.now()) - .memo("메모1") - .build(); - - order.setCustomer(customer); - Item item = Item.builder() .name("매운갈비찜") .price(3000) @@ -141,22 +128,6 @@ void getOrderByOrderItem() { @Test @DisplayName("주문 아이템에서 아이템을 조회할 수 있다.") void getItemByOrderItem() { - Customer customer = Customer.builder() - .name("hyunHo") - .nickName("changHyun") - .age(28) - .address(new Address("스터릿 어드레스", "디테일 어드레스", 10000)) - .build(); - - Order order = Order.builder() - .uuid(UUID.randomUUID().toString()) - .orderStatus(OrderStatus.OPENED) - .orderDatetime(LocalDateTime.now()) - .memo("메모1") - .build(); - - order.setCustomer(customer); - Item item = Item.builder() .name("매운갈비찜") .price(3000)