Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
b7c9083
test: 주 생성자 사용 로직으로 수정
pawoo0211 May 23, 2024
c43e274
test: 테스트 코드를 위한 메서드 제거
pawoo0211 May 23, 2024
f2260de
test: 이름, 가격 도메인 테스트 코드 작성
pawoo0211 May 23, 2024
ab73347
refactor: To Be 메뉴 그룹 구현
pawoo0211 May 23, 2024
623bad4
refactor: To Be 메뉴 상품 구현
pawoo0211 May 27, 2024
6fd402e
refactor: To Be 메뉴 구현
pawoo0211 May 27, 2024
abd44e0
refactor: DisplayedName -> CleanName으로 네이밍 변경
pawoo0211 May 28, 2024
eafef3d
refactor: DisplayedName 제거
pawoo0211 May 28, 2024
a95b239
refactor: 메뉴 숨김 getter 로직 제거
pawoo0211 May 28, 2024
7a34cd0
test: 랜덤 객체 재사용으로 수정
pawoo0211 May 29, 2024
b0e7f58
test: 상품 생성 메서드 제거
pawoo0211 May 29, 2024
03009d2
test: 메뉴 도메인 이름 테스트 코드 추가
pawoo0211 May 29, 2024
993630b
refactor: 메뉴 -> 메뉴 그룹 id 의존으로 변경
pawoo0211 May 29, 2024
fdf5132
refactor: 메뉴 상품 -> 상품 id 의존 변경에 따른 1차 리팩터링
pawoo0211 May 29, 2024
940bbc0
refactor: 메뉴 상품 -> 상품 id 의존 변경에 따른 2차 리팩터링
pawoo0211 May 29, 2024
6a3bc8c
refactor: 메뉴 상품 -> 상품 객체 의존 제거
pawoo0211 May 29, 2024
34f17f8
chore: 메뉴 상품 리팩터링 테스트 코드 정리
pawoo0211 May 29, 2024
f718f35
refactor: 메뉴 상품 가격 반환 리팩터링
pawoo0211 May 31, 2024
b7d6076
refactor: 메뉴 상품 가격과 메뉴 가격 비교 메서드 위치 및 네이밍 변경
pawoo0211 May 31, 2024
bb80df0
test: 가격 도메인 추가 테스트 코드 작성
pawoo0211 May 31, 2024
af38e43
refactor: 두번째 미션 마지막 피드백 적용
pawoo0211 Jun 1, 2024
443acc1
feat: To Be 주문 테이블 구현
pawoo0211 Jun 1, 2024
5cd6899
feat: To Be 주문 항목 뼈대 코드 작성
pawoo0211 Jun 1, 2024
6f1d289
feat: To Be 주문 뼈대 코드 작성
pawoo0211 Jun 1, 2024
ce1c3af
refactor: To Be 패키지 구조 변경
pawoo0211 Jun 1, 2024
6d21ef3
refactor: 주문 등록 전 빈 테이블 확인 및 주문 완료 후 빈 테이블 설정 구현
pawoo0211 Jun 1, 2024
5107e75
refactor: 주문 ACL 클래스에 따른 패키지 구조 변경
pawoo0211 Jun 1, 2024
49830eb
refactor: 주문 ACL 클래스에 따른 메뉴 패키지 구조 변경
pawoo0211 Jun 1, 2024
9b09de2
feat: 주문 생성 시 메뉴 검증 구현
pawoo0211 Jun 1, 2024
3f16f60
test: 테스트 전 저장해야 하는 데이터 셋 코드 정리
pawoo0211 Jun 1, 2024
c3a161d
Merge branch 'pawoo0211' into step3
pawoo0211 Jun 1, 2024
45d26b8
refactor: 주문 완료에 따른 빈 테이블 설정 로직 리팩터링
pawoo0211 Jun 5, 2024
860bdcb
test: 스프링 통합 테스트를 위한 임시 엔티티 네이밍 수정
pawoo0211 Jun 5, 2024
e983561
refactor: 주문 완료에 따른 빈 설정 이벤트 기반으로 리팩터링
pawoo0211 Jun 5, 2024
558e2a7
refactor: 주문 생성 시 검증 로직 리팩터링
pawoo0211 Jun 5, 2024
eccbe2b
test: 생성자를 이용한 주문 상태 변경
pawoo0211 Jun 5, 2024
07ff076
test: 테스트 코드를 위한 메서드 제거
pawoo0211 May 23, 2024
a80da1b
test: 이름, 가격 도메인 테스트 코드 작성
pawoo0211 May 23, 2024
9962450
refactor: To Be 메뉴 그룹 구현
pawoo0211 May 23, 2024
b796d70
refactor: To Be 메뉴 상품 구현
pawoo0211 May 27, 2024
21b8f13
refactor: To Be 메뉴 구현
pawoo0211 May 27, 2024
babffa7
refactor: DisplayedName -> CleanName으로 네이밍 변경
pawoo0211 May 28, 2024
6986496
refactor: DisplayedName 제거
pawoo0211 May 28, 2024
5e1603f
refactor: 메뉴 숨김 getter 로직 제거
pawoo0211 May 28, 2024
f256d6a
test: 랜덤 객체 재사용으로 수정
pawoo0211 May 29, 2024
715b933
test: 상품 생성 메서드 제거
pawoo0211 May 29, 2024
cd012ad
test: 메뉴 도메인 이름 테스트 코드 추가
pawoo0211 May 29, 2024
fc1c97a
refactor: 메뉴 -> 메뉴 그룹 id 의존으로 변경
pawoo0211 May 29, 2024
8568977
refactor: 메뉴 상품 -> 상품 id 의존 변경에 따른 1차 리팩터링
pawoo0211 May 29, 2024
fce2e2e
refactor: 메뉴 상품 -> 상품 id 의존 변경에 따른 2차 리팩터링
pawoo0211 May 29, 2024
cf50ce9
refactor: 메뉴 상품 -> 상품 객체 의존 제거
pawoo0211 May 29, 2024
eeb4fce
chore: 메뉴 상품 리팩터링 테스트 코드 정리
pawoo0211 May 29, 2024
a4257d5
refactor: 메뉴 상품 가격 반환 리팩터링
pawoo0211 May 31, 2024
fe08dd9
refactor: 메뉴 상품 가격과 메뉴 가격 비교 메서드 위치 및 네이밍 변경
pawoo0211 May 31, 2024
ea91181
test: 가격 도메인 추가 테스트 코드 작성
pawoo0211 May 31, 2024
e732a74
Merge remote-tracking branch 'origin/step3' into step3
pawoo0211 Jun 6, 2024
5e84dc8
fix: 머지 충돌 해결
pawoo0211 Jun 6, 2024
3286a41
fix: 누락된 커밋 추가
pawoo0211 Jun 6, 2024
bd53968
fix: 주문 항목 메뉴 식별자 및 금액 예외 처리
pawoo0211 Jun 7, 2024
9cd603f
fix: 주문 항목 금액과 메뉴 금액 일치 여부에ㄷ 따른 수정
pawoo0211 Jun 7, 2024
2a3a17c
refactor: 메뉴 변경에 따른 주문 검증
pawoo0211 Jun 7, 2024
19c576d
refactor: 동일한 사용에 따라 OrderTableStatus 제거
pawoo0211 Jun 7, 2024
22d0891
chore: 이벤트 핸들링 시 로깅 처리
pawoo0211 Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package kitchenpos.eatinorders.tobe.domain.constant;

public enum EatInOrderStatus {
WAITING, ACCEPTED, SERVED, COMPLETED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package kitchenpos.eatinorders.tobe.domain.constant;

public enum EatInOrderType {
EAT_IN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kitchenpos.eatinorders.tobe.domain.constant;

public enum OrderTableStatus {
EMPTY_TABLE,
SIT_TABLE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package kitchenpos.eatinorders.tobe.domain.entity;

import java.util.UUID;

public class CompletedOrderEvent {
private UUID orderTableId;

public CompletedOrderEvent(UUID orderTableId) {
this.orderTableId = orderTableId;
}

public UUID getOrderTableId() {
return orderTableId;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package kitchenpos.eatinorders.tobe.domain.entity;

import jakarta.persistence.*;
import kitchenpos.eatinorders.tobe.domain.constant.EatInOrderStatus;
import kitchenpos.eatinorders.tobe.domain.constant.EatInOrderType;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Set;
import java.util.UUID;

@Table(name = "orders2")
@Entity(name = "EatInOrder")
public class EatInOrder {
@Column(name = "id", columnDefinition = "binary(16)")
@Id
private UUID id;

@Column(name = "type", nullable = false, columnDefinition = "varchar(255)")
@Enumerated(EnumType.STRING)
private EatInOrderType type;

@Column(name = "status", nullable = false, columnDefinition = "varchar(255)")
@Enumerated(EnumType.STRING)
private EatInOrderStatus status;

@Column(name = "order_date_time", nullable = false)
private LocalDateTime orderDateTime;

@Embedded
private OrderLineItems orderLineItems;

private UUID orderTableId;

protected EatInOrder() {}

public EatInOrder(UUID id, EatInOrderType type, EatInOrderStatus status, LocalDateTime orderDateTime,
OrderLineItems orderLineItems, UUID orderTableId) {
this.id = id;
this.type = type;
this.status = status;
this.orderDateTime = orderDateTime;
this.orderLineItems = orderLineItems;
this.orderTableId = orderTableId;
}

public void accept() {
if (status != EatInOrderStatus.WAITING) {
throw new IllegalStateException();
}
status = EatInOrderStatus.ACCEPTED;
}

public void serve() {
if (status != EatInOrderStatus.ACCEPTED) {
throw new IllegalStateException();
}
status = EatInOrderStatus.SERVED;
}

public void complete() {
if (status != EatInOrderStatus.SERVED) {
throw new IllegalStateException();
}
status = EatInOrderStatus.COMPLETED;
}

public boolean isComplete() {
return status == EatInOrderStatus.COMPLETED;
}

public void updateMenuInOrders(UUID menuId, BigDecimal price, boolean displayed) {
orderLineItems.updateMenuInOrders(menuId, price, displayed);
}

public Set<UUID> allMenuId() {
return orderLineItems.allMenuId();
}

public boolean hasMenuId(UUID inputMenuId) {
boolean hasMenuId = orderLineItems.allMenuId()
.stream()
.anyMatch(thisMenuId -> thisMenuId.equals(inputMenuId));

return hasMenuId;
}

public UUID getId() {
return id;
}

public EatInOrderType getType() {
return type;
}

public EatInOrderStatus getStatus() {
return status;
}

public UUID getOrderTableId() {
return orderTableId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package kitchenpos.eatinorders.tobe.domain.entity;

import jakarta.persistence.*;
import kitchenpos.eatinorders.tobe.domain.vo.MenuInEatInOrders;
import kitchenpos.eatinorders.tobe.domain.vo.Price;

import java.math.BigDecimal;
import java.util.UUID;

@Table(name = "order_line_item2")
@Entity(name = "OrderLineItem2")
public class OrderLineItem {
@Column(name = "seq")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
private Long seq;

@Column(name = "quantity", nullable = false)
private long quantity;

@Embedded
private Price price;

@Embedded
private MenuInEatInOrders menuInOrders;
Comment on lines +18 to +25

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

궁금해서 그러는데 price는 MenuInEatInOrders.price와 동일한가요? 그렇다면 중복인 것 같은데요.
quantity * MenuInEatInOrders.price 라면 직접 계산할 수 도 있을 것 같아서요.


protected OrderLineItem() {}

public OrderLineItem(Long seq, long quantity, BigDecimal price,
UUID menuId, BigDecimal menuPrice) {
this(seq, quantity, price, menuId, false, menuPrice);
}

public OrderLineItem(Long seq, long quantity, BigDecimal price,
UUID menuId, boolean isDisplayedMenu, BigDecimal menuPrice) {
this.seq = seq;
this.quantity = quantity;
this.price = new Price(price);
menuInOrders = new MenuInEatInOrders(menuId, isDisplayedMenu, menuPrice);
checkIsEqualPrice();
}

private void checkIsEqualPrice() {
if (this.price.isNotSamePrice(menuInOrders.getPrice())) {
throw new IllegalArgumentException("주문 항목 금액과 메뉴 금액이 서로 다릅니다.");
}
}

public void updateMenuInOrders(UUID menuId, BigDecimal price, boolean displayed) {
if (menuInOrders.isSameId(menuId)) {
menuInOrders.update(price, displayed);
checkIsEqualPrice();
}
}

public Long getSeq() {
return seq;
}

public long getQuantity() {
return quantity;
}

public Price getPrice() {
return price;
}

public UUID getMenuId() {
return menuInOrders.getMenuId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package kitchenpos.eatinorders.tobe.domain.entity;

import jakarta.persistence.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

@Embeddable
public class OrderLineItems {
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(
name = "order_id",
nullable = false,
columnDefinition = "binary(16)",
foreignKey = @ForeignKey(name = "fk_order_line_item_to_orders")
)
private List<OrderLineItem> orderLineItems;

protected OrderLineItems() {}

public OrderLineItems(List<OrderLineItem> orderLineItems) {
this.orderLineItems = orderLineItems;
}

public void updateMenuInOrders(UUID menuId, BigDecimal price, boolean displayed) {
for (OrderLineItem orderLineItem : orderLineItems) {
orderLineItem.updateMenuInOrders(menuId, price, displayed);
}
}

public Set<UUID> allMenuId() {
return orderLineItems.stream()
.map(orderLineItem -> orderLineItem.getMenuId())
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package kitchenpos.eatinorders.tobe.domain.entity;

import jakarta.persistence.*;
import kitchenpos.eatinorders.tobe.domain.vo.NumberOfGuests;
import kitchenpos.eatinorders.tobe.domain.vo.OrderTableName;

import java.util.UUID;

@Table(name = "order_table2")
@Entity(name = "OrderTable2")
public class OrderTable {
@Column(name = "id", columnDefinition = "binary(16)")
@Id
private UUID id;

@Embedded
private OrderTableName name;

@Embedded
private NumberOfGuests numberOfGuests;

@Column(name = "occupied", nullable = false)
private boolean occupied;

protected OrderTable() {}

public OrderTable(UUID id, String name, int numberOfGuests, boolean occupied) {
checkNumberOfGuests(numberOfGuests);
checkOccupied(occupied);
this.id = id;
this.name = new OrderTableName(name);
this.numberOfGuests = new NumberOfGuests(numberOfGuests);
this.occupied = occupied;
}

private void checkNumberOfGuests(int numberOfGuests) {
if (numberOfGuests != 0) {
throw new IllegalArgumentException();
}
}

private void checkOccupied(boolean occupied) {
if (occupied) {
throw new IllegalArgumentException();
}
}

public void sit() {
occupied = true;
}

public void clear() {
numberOfGuests = NumberOfGuests.zero();
occupied = false;
}

public void changeNumberOfGuests(int numberOfGuests) {
NumberOfGuests inputNumberOfGuests = new NumberOfGuests(numberOfGuests);
if (isNotOccupied()) {
throw new IllegalStateException();
}
this.numberOfGuests = inputNumberOfGuests;
}

public boolean isNotOccupied() {
return !occupied;
}

public boolean isOccupied() {
return occupied;
}

public UUID getId() {
return id;
}

public int getNumberOfGuests() {
return numberOfGuests.getNumberOfGuests();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kitchenpos.eatinorders.tobe.domain.repository;

import kitchenpos.eatinorders.tobe.domain.entity.EatInOrder;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface EatInOrderRepository {

EatInOrder save(EatInOrder order);

Optional<EatInOrder> findById(UUID id);

List<EatInOrder> findAllByOrderTableId(UUID id);

List<EatInOrder> findAllByMenuId(UUID menuId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package kitchenpos.eatinorders.tobe.domain.repository;

import kitchenpos.eatinorders.tobe.domain.entity.OrderTable;
import java.util.Optional;
import java.util.UUID;

public interface OrderTableRepository {

OrderTable save(OrderTable orderTable);

Optional<OrderTable> findById(UUID id);
}
Loading