Skip to content
Open
Show file tree
Hide file tree
Changes from 31 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
70 changes: 35 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,47 @@ docker compose -p kitchenpos up -d

### 주문 테이블

- 주문 테이블을 등록할 수 있다.
- 주문 테이블의 이름이 올바르지 않으면 등록할 수 없다.
- 주문 테이블의 이름은 비워 둘 수 없다.
- 빈 테이블을 해지할 수 있다.
- 빈 테이블로 설정할 수 있다.
- 완료되지 않은 주문이 있는 주문 테이블은 빈 테이블로 설정할 수 없다.
- 방문한 손님 수를 변경할 수 있다.
- 방문한 손님 수가 올바르지 않으면 변경할 수 없다.
- 방문한 손님 수는 0 이상이어야 한다.
- 빈 테이블은 방문한 손님 수를 변경할 수 없다.
- 주문 테이블의 목록을 조회할 수 있다.
- [X] 주문 테이블을 등록할 수 있다.
- [X] 주문 테이블의 이름이 올바르지 않으면 등록할 수 없다.
- [X] 주문 테이블의 이름은 비워 둘 수 없다.
- [X] 빈 테이블을 해지할 수 있다.
- [X] 빈 테이블로 설정할 수 있다.
- [] 완료되지 않은 주문이 있는 주문 테이블은 빈 테이블로 설정할 수 없다.
- [X] 방문한 손님 수를 변경할 수 있다.
- [X] 방문한 손님 수가 올바르지 않으면 변경할 수 없다.
- [X] 방문한 손님 수는 0 이상이어야 한다.
- [X] 빈 테이블은 방문한 손님 수를 변경할 수 없다.
- [] 주문 테이블의 목록을 조회할 수 있다.

### 주문

- 1개 이상의 등록된 메뉴로 배달 주문을 등록할 수 있다.
- 1개 이상의 등록된 메뉴로 포장 주문을 등록할 수 있다.
- 1개 이상의 등록된 메뉴로 매장 주문을 등록할 수 있다.
- 주문 유형이 올바르지 않으면 등록할 수 없다.
- 메뉴가 없으면 등록할 수 없다.
- 매장 주문은 주문 항목의 수량이 0 미만일 수 있다.
- 매장 주문을 제외한 주문의 경우 주문 항목의 수량은 0 이상이어야 한다.
- [] 1개 이상의 등록된 메뉴로 매장 주문을 등록할 수 있다.
- [] 주문 유형이 올바르지 않으면 등록할 수 없다.
- [X] 메뉴가 없으면 등록할 수 없다.
- [X] 매장 주문은 주문 항목의 수량이 0 미만일 수 있다.
- 매장 주문을 제외한 주문의 경우 주문 항목의 수량은 0 이상이어야 한다.
- 배달 주소가 올바르지 않으면 배달 주문을 등록할 수 없다.
- 배달 주소는 비워 둘 수 없다.
- 빈 테이블에는 매장 주문을 등록할 수 없다.
- 숨겨진 메뉴는 주문할 수 없다.
- 주문한 메뉴의 가격은 실제 메뉴 가격과 일치해야 한다.
- 주문을 접수한다.
- 접수 대기 중인 주문만 접수할 수 있다.
- [X] 빈 테이블에는 매장 주문을 등록할 수 없다.
- [X] 숨겨진 메뉴는 주문할 수 없다.
- [] 주문한 메뉴의 가격은 실제 메뉴 가격과 일치해야 한다.
- [X] 주문을 접수한다.
- [X] 접수 대기 중인 주문만 접수할 수 있다.
- 배달 주문을 접수되면 배달 대행사를 호출한다.
- 주문을 서빙한다.
- 접수된 주문만 서빙할 수 있다.
- [X] 주문을 서빙한다.
- [X] 접수된 주문만 서빙할 수 있다.
- 주문을 배달한다.
- 배달 주문만 배달할 수 있다.
- 서빙된 주문만 배달할 수 있다.
- 주문을 배달 완료한다.
- 배달 중인 주문만 배달 완료할 수 있다.
- 주문을 완료한다.
- [X] 주문을 완료한다.
- 배달 주문의 경우 배달 완료된 주문만 완료할 수 있다.
- 포장 및 매장 주문의 경우 서빙된 주문만 완료할 수 있다.
- 주문 테이블의 모든 매장 주문이 완료되면 빈 테이블로 설정한다.
- 완료되지 않은 매장 주문이 있는 주문 테이블은 빈 테이블로 설정하지 않는다.
- [X] 포장 및 매장 주문의 경우 서빙된 주문만 완료할 수 있다.
- [X] 주문 테이블의 모든 매장 주문이 완료되면 빈 테이블로 설정한다.
- [X] 완료되지 않은 매장 주문이 있는 주문 테이블은 빈 테이블로 설정하지 않는다.
- 주문 목록을 조회할 수 있다.

## 용어 사전
Expand Down Expand Up @@ -176,14 +176,14 @@ docker compose -p kitchenpos up -d

### 매장 주문

- `OrderTable`은 식별자와 이름, `NumberOfGuests`를 가진다.
- `OrderTable`의 추가 `Order`는 `OrderTable`에 계속 쌓이며 모든 `Order`가 완료되면 `EmptyTable`이 된다.
- `EmptyTable`인 경우 `NumberOfGuests`는 0이며 변경할 수 없다.
- `Order`는 식별자와 `OrderStatus`, 주문 시간, `OrderLineItems`를 가진다.
- 메뉴가 노출되고 있으며 판매되는 메뉴 가격과 일치하면 `Order`가 생성된다.
- `Order`는 접수 대기 ➜ 접수 ➜ 서빙 ➜ 계산 완료 순서로 진행된다.
- `OrderLineItem`는 가격과 수량을 가진다.
- `OrderLineItem`의 수량은 기존 `Order`를 취소하거나 변경해도 수정되지 않기 때문에 0보다 적을 수 있다.
- [X] `OrderTable`은 식별자와 이름, `NumberOfGuests`를 가진다.
- [] `OrderTable`의 추가 `Order`는 `OrderTable`에 계속 쌓이며 모든 `Order`가 완료되면 `EmptyTable`이 된다.
- [X] `EmptyTable`인 경우 `NumberOfGuests`는 0이며 변경할 수 없다.
- [X] `Order`는 식별자와 `OrderStatus`, 주문 시간, `OrderLineItems`를 가진다.
- [] 메뉴가 노출되고 있으며 판매되는 메뉴 가격과 일치하면 `Order`가 생성된다.
- [X] `Order`는 접수 대기 ➜ 접수 ➜ 서빙 ➜ 계산 완료 순서로 진행된다.
- [] `OrderLineItem`는 가격과 수량을 가진다.
- [] `OrderLineItem`의 수량은 기존 `Order`를 취소하거나 변경해도 수정되지 않기 때문에 0보다 적을 수 있다.

### 배달 주문

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package kitchenpos.eatinorders.tobe.application.acl;

import kitchenpos.eatinorders.tobe.domain.entity.EatInOrder;
import kitchenpos.eatinorders.tobe.domain.entity.OrderTable;
import kitchenpos.eatinorders.tobe.domain.repository.EatInOrderRepository;
import kitchenpos.eatinorders.tobe.domain.repository.OrderTableRepository;
import kitchenpos.menus.tobe.domain.entity.Menu;
import kitchenpos.menus.tobe.domain.repository.MenuRepository;

import java.util.NoSuchElementException;
import java.util.UUID;

public class EatInOrderServiceAdapter {
private final EatInOrderRepository orderRepository;
private final OrderTableRepository orderTableRepository;
private final MenuRepository menuRepository;

public EatInOrderServiceAdapter(EatInOrderRepository orderRepository,
OrderTableRepository orderTableRepository,
MenuRepository menuRepository
) {
this.orderRepository = orderRepository;
this.orderTableRepository = orderTableRepository;
this.menuRepository = menuRepository;
}

public boolean existHideMenu(UUID menuId) {
Menu menu = findMenuById(menuId);
if (menu.isNotDisplayed()) {
return true;
}
return false;
}

private Menu findMenuById(UUID menuId) {
return menuRepository.findById(menuId)
.orElseThrow(() -> new NoSuchElementException());
}

public boolean existIsNotOccupiedOrderTable(EatInOrder order) {
OrderTable orderTable = findOrderTableBy(order.getOrderTableId());
return orderTable.isNotOccupied();
}

public void clearOrderTable(EatInOrder order) {
OrderTable orderTable = findOrderTableBy(order.getOrderTableId());
if (orderRepository.isAllCompleteByOrderTable(orderTable)) {
orderTable.clear();
}
}

Choose a reason for hiding this comment

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

orderRepository 에서는 orderTable를 직접 의존하고 있네요. 이 부분도 id 변경해야 하지 않을까요?


private OrderTable findOrderTableBy(UUID id) {
return orderTableRepository.findBy(id)
.orElseThrow(() -> new NoSuchElementException());
}
}
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,102 @@
package kitchenpos.eatinorders.tobe.domain.entity;

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

Choose a reason for hiding this comment

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

EatInOrderServiceAdapter는 application layer에 속하는데 domain model인 EatInOrder가 의존하고 있네요. 이 부분은 의존성 관점에서 괜찮은가요?

Copy link
Author

Choose a reason for hiding this comment

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

제가 ACL에 대한 개념 자체를 잘못 잡은 상태로 구현했네요....

피드백 감사합니다!

import java.time.LocalDateTime;
import java.util.UUID;

@Table(name = "orders")
@Entity
public class EatInOrder {

Choose a reason for hiding this comment

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

디폴트 생성자가 필요해 보이네요.

@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;

@Transient
private UUID orderTableId;

public EatInOrder(UUID id, EatInOrderType type, EatInOrderStatus status, LocalDateTime orderDateTime,
OrderLineItems orderLineItems, UUID orderTableId,
EatInOrderServiceAdapter orderDomainService) {
this(id, type, status, orderDateTime, orderLineItems, orderTableId);
checkOrderTableOccupied(orderDomainService);
checkAllMenuIsDisplayed(orderDomainService);
}

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;
}

private void checkAllMenuIsDisplayed(EatInOrderServiceAdapter orderDomainService) {
if (orderLineItems.hasDisplayedMenu(orderDomainService)) {
throw new IllegalStateException();
}
}

private void checkOrderTableOccupied(EatInOrderServiceAdapter orderDomainService) {
if (orderDomainService.existIsNotOccupiedOrderTable(this)) {
throw new IllegalStateException();
}
}

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(EatInOrderServiceAdapter eatInOrderServiceAdapter) {
if (status != EatInOrderStatus.SERVED) {
throw new IllegalStateException();
}
status = EatInOrderStatus.COMPLETED;
eatInOrderServiceAdapter.clearOrderTable(this);
}

Choose a reason for hiding this comment

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

도메인 서비스를 사용할 수 있지만 이벤트를 사용하는 것도 괜찮아 보이네요. 이 부분은 선택인 것 같습니다. :)

sequenceDiagram
    actor User as 사장님
    participant EatInOrder 
    participant OrderTable

    User ->> EatInOrder: 매장 주문 완료 요청
    EatInOrder ->> EatInOrder: 매장 주문 상태 검증
    alt 매장 주문 상태 SERVED
      EatInOrder ->> User: 매장 주문 완료
      EatInOrder -->> OrderTable: 매장 주문 완료됨
    else
      EatInOrder ->> User: 매장 주문 완료 실패
    end
    
Loading


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,53 @@
package kitchenpos.eatinorders.tobe.domain.entity;

import jakarta.persistence.*;

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

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

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

@Transient
private BigDecimal price;

Choose a reason for hiding this comment

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

@Transient
private UUID menuId;

Choose a reason for hiding this comment

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

고민해 볼만한 포인트인 것 같습니다. menu는 id로 참조하고 있는데요.
그렇다면 보통 주문한 시점의 menu가 필요합니다. (스냅샷) 하지만 간접 참조로 인해서 주문한 시점의 정보를 불러 오기 힘들 것 같은데요. 이 부분은 어떻게 해결할 수 있을까요?

Choose a reason for hiding this comment

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

이 경우 메뉴 MC 에서 menu name이 변경되는 경우 어떻게 처리 될까요?

얼마 전에 저희 DM 으로 Menu BC에서의 menu와 Order BC에서 Menu는 의미하는 바가 다름을 도출했는데요. 이를 코드로 녹여보는 것은 어떨까요? Order에 Menu 모델이 만들어 질 수도 있지 않을까요?

Choose a reason for hiding this comment

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

price와 menuId는 Transient 로 선언되어도 괜찮나요?


protected OrderLineItem() {}

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

public OrderLineItem(Long seq, long quantity, BigDecimal price) {
this.seq = seq;
this.quantity = quantity;
this.price = price;
}

Choose a reason for hiding this comment

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

Suggested change
public OrderLineItem(Long seq, long quantity, BigDecimal price, UUID menuId) {
this(seq, quantity, price);
this.menuId = menuId;
}
public OrderLineItem(Long seq, long quantity, BigDecimal price) {
this.seq = seq;
this.quantity = quantity;
this.price = price;
}
public OrderLineItem(Long seq, long quantity, BigDecimal price, UUID menuId) {
this.seq = seq;
this.quantity = quantity;
this.price = price;
this.menuId = menuId;
}
public OrderLineItem(Long seq, long quantity, BigDecimal price) {
this(seq, quantity, price, null);
}


public Long getSeq() {
return seq;
}

public long getQuantity() {
return quantity;
}

public BigDecimal getPrice() {
return price;
}

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

import jakarta.persistence.*;
import kitchenpos.eatinorders.tobe.application.acl.EatInOrderServiceAdapter;

import java.util.List;

@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 boolean hasDisplayedMenu(EatInOrderServiceAdapter orderDomainService) {
return orderLineItems.stream()
.map(orderLineItem -> orderLineItem.getMenuId())
.anyMatch(menuId -> orderDomainService.existHideMenu(menuId));
}

Choose a reason for hiding this comment

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

orderDomainService EatInOrderServiceAdapter 이름 모두 어색하게 느껴지는데요.
도메인 서비스의 이름은 도메인 용어(용어 사전, 모델링..) 을 그대로 사용해 보면 어떨까요? 예를 들면 DisplayNamePolicy 라는 도메인 용어를 사용하고 DefaultPurgomalumClient이 구현하면 되는 것 처럼요.

// domain
interface DisplayNamePolicy {

  boolean containsProfanity(final String text);

}

// infra 
@Component
public class DefaultPurgomalumClient implements DisPlayNamePolicy {
  // 구현
}

그리고 패키지 상 EatInOrderServiceAdapter 는 application layer로 보이네요. 🤔


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