Conversation
|
안녕하세요 다은님 😄
해당 질문을 제대로 이해하지 못했는데 조금더 상세히 설명 부탁드립니다 ! |
sah3122
left a comment
There was a problem hiding this comment.
메뉴 리팩터링 잘해주셨습니다 😄
몇가지 코멘트 남겨두었는데 확인 부탁드려요 🙏
| import java.math.BigDecimal; | ||
| import java.util.Objects; | ||
|
|
||
| public class MenuPrice { |
There was a problem hiding this comment.
@embeddable 어노테이션을 정의해주어야 할것 같아요 🙏
@Embeddable
public class MenuPrice {아래 문서를 참고해보세요 😄
https://velog.io/@seongwon97/Spring-Boot-JPA-Embedded-Embeddable
| columnDefinition = "binary(16)", | ||
| foreignKey = @ForeignKey(name = "fk_menu_product_to_product") | ||
| ) | ||
| private Product product; |
There was a problem hiding this comment.
Product 엔티티를 직접참조로 유지 하는것 보단 간접 참조로 변경해보는건 어떨까요 ?
강의에서 배운 Aggregate Pattern을 참고해보세요 😄
|
|
||
| List<MenuProduct> menuProducts = request.getMenuProducts().stream() | ||
| .map(menuProduct -> { | ||
| Product product = productRepository.findById(menuProduct.getProductId()) |
There was a problem hiding this comment.
Menu Service 에서 Product 도메인과의 결합을 제거해볼수 있을까요 ?
외부 도메인과 협력을 해야하는 로직들을 DomainService로 정의해볼수 있을것 같습니다 😄
| } | ||
|
|
||
| private boolean isMenuPriceGreaterThanSumOfProductPrice() { | ||
| return price.compareTo(getSumOfProductPrice()) > 0; |
There was a problem hiding this comment.
Product 엔티티를 간접 참조로 변경한다면 이와 같은 기능을 어떻게 구현할지 고민해보세요 😄
| if (Objects.isNull(price) || price.compareTo(BigDecimal.ZERO) < 0) { | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| public Menu changePrice(final UUID menuId, final MenuPriceChangeRequestDto request) { |
안녕하세요.
2단계 미션 리뷰 부탁드립니다.
몇가지 이슈가 있는데, pr 올리는 것이 너무 늦어져 우선 올리겠습니다!
감사합니다.