Skip to content
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

Merged
merged 3 commits into from
Oct 9, 2024
Merged

[fix] 메뉴 추가 API #202

merged 3 commits into from
Oct 9, 2024

Conversation

kgy1008
Copy link
Member

@kgy1008 kgy1008 commented Oct 8, 2024

Related Issue 📌

close #201

Description ✔️

  • 여러 개의 메뉴가 추가 가능하도록 수정하였습니다

To Reviewers

API 테스트 완료

@kgy1008 kgy1008 added the api label Oct 8, 2024
@kgy1008 kgy1008 self-assigned this Oct 8, 2024
@@ -33,7 +36,10 @@ public HankkiResponse<Void> updateMenu(@PathVariable("storeId") final Long store
}

@PostMapping("/{storeId}/menus")
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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());
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

List대신 복수형 컨벤션이염

Comment on lines 44 to 51
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);
})
Copy link
Contributor

@Parkjyun Parkjyun Oct 8, 2024

Choose a reason for hiding this comment

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

기획이 말한 거처럼
a 메뉴 있는 상태에서
a,b 메뉴 추가할 때 b만 적용 되는거 ㄱ ㄱ
클라랑 협의해서 알람창에 팅긴 거 표시할건지도 정해야할듯요

Comment on lines 43 to 48
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

여기서 메뉴 검증 통과한거 모아놓은 다음에 한번에 저장하는게 낫지 않을까요?

Comment on lines 55 to 56
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));
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 굳이 함수 나눠야 하나 싶네요.

@kgy1008 kgy1008 merged commit 1b7de3b into develop Oct 9, 2024
1 check passed
@kgy1008 kgy1008 deleted the fix/201 branch December 21, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[fix] 메뉴 추가 API
2 participants