-
Notifications
You must be signed in to change notification settings - Fork 1
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
[fix] 메뉴 추가 API #202
[fix] 메뉴 추가 API #202
Conversation
@@ -33,7 +36,10 @@ public HankkiResponse<Void> updateMenu(@PathVariable("storeId") final Long store | |||
} | |||
|
|||
@PostMapping("/{storeId}/menus") |
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.
단건 추가가 아니라 여러건을 한번에 입력받게 되는데 /menus만으로 충분할까요?
menuUpdater.save(menu); | ||
updateLowestPriceInStore(findStore, menu); | ||
return MenuPostResponse.of(menu); | ||
public MenuListPostResponse createMenus(final MenusPostCommand commands) { |
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.
사소하지만 commands 굳이 복수? 앞에 이미 내포 돼 있는듯요
long storeId, | ||
List<MenuPostCommand> menu | ||
){ | ||
public static MenusPostCommand of (final long storeId, final List<MenuPostCommand> menu) { |
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 변수명 컨벤션 지켜주센~
Store findStore = storeFinder.findByIdWhereDeletedIsFalse(commands.storeId()); | ||
List<MenuPostResponse> menus = commands.menu().stream() | ||
.map(command -> { | ||
validateMenuNotConflict(findStore, command.name()); |
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.
하나하나 하는것도 나쁘지 않은데 여러 메뉴 들어왔을 때 쿼리에서 count, in 써서 한번에 검증하는 것도 고민해보시길
}) | ||
.toList(); | ||
updateLowestPriceInStore(findStore); | ||
return MenuListPostResponse.of(menus); |
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.
List대신 복수형 컨벤션이염
Store findStore = storeFinder.findByIdWhereDeletedIsFalse(commands.storeId()); | ||
List<MenuPostResponse> menus = commands.menu().stream() | ||
.map(command -> { | ||
validateMenuNotConflict(findStore, command.name()); | ||
Menu menu = Menu.create(findStore, command.name(), command.price()); | ||
menuUpdater.save(menu); | ||
return MenuPostResponse.of(menu); | ||
}) |
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.
기획이 말한 거처럼
a 메뉴 있는 상태에서
a,b 메뉴 추가할 때 b만 적용 되는거 ㄱ ㄱ
클라랑 협의해서 알람창에 팅긴 거 표시할건지도 정해야할듯요
src/main/java/org/hankki/hankkiserver/api/menu/service/MenuCommandService.java
Show resolved
Hide resolved
List<MenuPostResponse> menus = command.menu().stream() | ||
.filter(c -> !validateMenuConflict(findStore, c.name())) | ||
.map(c -> { | ||
Menu menu = Menu.create(findStore, c.name(), c.price()); | ||
menuUpdater.save(menu); | ||
return MenuPostResponse.of(menu); |
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.
여기서 메뉴 검증 통과한거 모아놓은 다음에 한번에 저장하는게 낫지 않을까요?
private void updateLowestPriceInStore(final Store findStore) { | ||
int lowestPrice = menuFinder.findAllByStore(findStore).stream() | ||
.mapToInt(Menu::getPrice) | ||
.min() | ||
.orElse(0); | ||
findStore.updateLowestPrice(lowestPrice); | ||
findStore.updateLowestPrice(menuFinder.findLowestPriceByStore(findStore)); |
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.
이거 굳이 함수 나눠야 하나 싶네요.
Related Issue 📌
close #201
Description ✔️
To Reviewers
API 테스트 완료