-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[레거시 코드 리팩터링 - 2단계] 다니(이다은) 미션 제출합니다. #193
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 다니~ 리팩터링 잘 해주셨네요! 👍🏻👍🏻👍🏻
리뷰하면서 저도 공부가 되네요!
몇 가지 궁금한 점과 제안을 코멘트로 남겼어요! 확인해보시고 반영하시거나 코멘트 달아주시면 감사하겠습니다!
step2는 머지하겠습니다! 피드백 반영은 다음 단계 때 같이 해주세요!
고생 많으셨고 진짜 얼마 안 남았는데 마지막까지 화이팅! 😄
Long quantity = menuProduct.getQuantity(); | ||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MenuProduct의 금액 계산시 MenuProduct에서 quantity를 가져와서 계산하지 않고, MenuProduct에 메세지를 보내는 건 어떻게 생각하시나요?
|
||
public Long getId() { | ||
return id; | ||
private Long numberOfGuests; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분을 Long으로 바꾸신 이유가 있을까요?? clone을 받아 실행시켜보려고 했는데 이 부분에서 문제가 있어서 실행이 안되는 것 같네요ㅠㅠ
Orders orders = ordersRepository.findById(requestDto.getOrderTableId()) | ||
.orElseThrow(IllegalArgumentException::new); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order을 조회하는데 OrderTableId를 사용해서 조회하고 있어요!
해당 Table의 모든 Order을 검증하기 위해서는 List 형태로 가져와야 할 것 같아요!
OrderTable 내부에서 List를 객체 참조해도 될 것 같고, 그게 아니라면 orderTableId로 findAllByOrderTable_Id()
로 가져와야 할 것 같아요.
String orderStatus = orders.getOrderStatus(); | ||
if (COOKING.name().equals(orderStatus) || MEAL.name().equals(orderStatus)) { | ||
throw new IllegalArgumentException(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 로직도 도메인에서 처리할 수 있지 않을까요?
|
||
return orderTableDao.save(savedOrderTable); | ||
entityManager.flush(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityManager을 주입받아서 flush 해주신 이유가 있을까요? 이 메서드 말고 전체적으로 EntityManager을 주입받아 사용하신 부분이 있던데 이유가 궁금하네요!
List<OrderTable> orderTables = tableRepository | ||
.findAllByTableGroupId(requestDto.getId()); | ||
|
||
if (ordersRepository.existsByOrderTableInAndOrderStatusIn( | ||
orderTables, | ||
Arrays.asList(COOKING.name(), MEAL.name()))) { | ||
throw new IllegalArgumentException(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TableGroup에서 List를 참조하고 있어서 TableGroup 조회시 연관된 OrderTable도 가져와질 것 같은데 따로 repository에서 가져오신 이유가 있을까요??
검증도 TableGroup 내에서 메세지를 보내는 식으로 처리할 수도 있을 것 같네요!
public TableEmptyResponseDto changeEmpty(TableEmptyRequestDto requestDto) { | ||
OrderTable orderTable = tableRepository.findById(requestDto.getOrderTableId()) | ||
.orElseThrow(IllegalArgumentException::new); | ||
if (Objects.nonNull(orderTable.getTableGroup())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OrderTable 내부에서 검증해도 되겠네요!
import kitchenpos.application.dto.response.MenuResponseDto; | ||
import kitchenpos.domain.Menu; | ||
|
||
public class MenuDtoAssembler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dto -> 도메인이나, 도메인 -> Dto 변환시 전반적으로 Assembler 클래스를 만드셔서 사용하신 걸 봤어요!
혹시 이렇게 따로 클래스를 만들어 사용하신 이유가 있을까요? 처음 보는 방식이라서 어떤 점 때문에 이 방식을 사용하게 되셨는지 궁금해요! 😄
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String orderStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 @Enumerated
를 적용해 보는 건 어떨까요??
@@ -8,7 +8,7 @@ CREATE TABLE orders ( | |||
|
|||
CREATE TABLE order_line_item ( | |||
seq BIGINT(20) NOT NULL AUTO_INCREMENT, | |||
order_id BIGINT(20) NOT NULL, | |||
orders_id BIGINT(20), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분이랑 menu_product의 menu_id 부분의 NOT NULL을 제거하신 이유가 있나요??
각각 실행했을 때(OrdersService#changeOrderStatus())전체로 실행했을 때(OrdersService#changeOrderStatus()) |
오랜만이에요 에어 ~!
좀 더 빨리 제출하고 싶었는데,, 생각보다 오래 걸렸네요 🥲
2단계는 아래와 같이 진행했습니다 !
지금 changeEmpty()와 관련된 테스트가 각각 실행하면 통과하나, 전체로 실행하면 실패해요 😥
아직 이유를 못 찾고 있는데, 먼저 제출하고 더 알아볼게요!
혹시,, 이번에도 함께 고민해줄 수 있을까요 ㅎㅎㅎㅎ
1단계에서 정성어린 리뷰들 달아줘서 정말 고마웠습니다 !!
이번에도 잘 부탁드립니다 🙇♀️✨