-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat] 식당 Id로 메뉴 목록 불러오기 #218
Conversation
public MenusGetResponse getMenus(final long storeId) { | ||
Store findStore = storeFinder.findByIdWhereDeletedIsFalse(storeId); | ||
List<Menu> findmenus = menuFinder.findAllByStore(findStore); | ||
List<MenuGetResponse> menus = findmenus.stream() |
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.
Entity -> DTO 변환로직이니 DTO에 있어도 되지 않을까 생각을 해봅니다.. 👀
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.
옮기겠슴돠
@@ -42,4 +43,9 @@ public HankkiResponse<MenusPostResponse> createMenu(@PathVariable final Long sto | |||
.toList(); | |||
return HankkiResponse.success(CommonSuccessCode.CREATED, menuCommandService.createMenus(MenusPostCommand.of(storeId, command))); | |||
} | |||
|
|||
@GetMapping("{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.
혹시 맨앞에 /를 생략하신 이유가 있으실까요? 제가 모르는 부분이 있나 싶어서 여쭤보아요
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.
까먹었어여
@Valid @RequestBody final List<MenuPostRequest> request) { | ||
@PostMapping("/{storeId}/menus/bulk") | ||
public HankkiResponse<MenusPostResponse> createMenu(@PathVariable @Min(value = 1L) final long storeId, | ||
@Valid @RequestBody final List<MenuPostRequest> request) { | ||
List<MenuPostCommand> command = request.stream() |
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에 있어도 될 것 같아여
List<MenuGetResponse> findmenus = menus.stream() | ||
.map(MenuGetResponse::of) | ||
.toList(); | ||
return new MenusGetResponse(findmenus); |
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.
매개변수에 바로 안넣고 변수 따로 생성해서 넣는 이유가 궁금해여
|
||
import org.hankki.hankkiserver.domain.menu.model.Menu; | ||
|
||
public record MenuGetResponse ( |
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는 지금 MenusGetResponse에서만 사용하고 있는 것 같은데 접근제어자 public말고 default로 해줘도 될 것 같슴둥
int price, | ||
String name | ||
){ | ||
public static MenuGetResponse of(final Menu 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.
얘도 default여도 될 것 같아유
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.
바뀐 부분 표시
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "deleted_menu") | ||
public class DeletedMenu extends BaseCreatedAtEntity { |
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 checkNoMenuInStore(final Store store, final long userId, final Menu menu) { | ||
if (!menuFinder.existsByStoreId(store.getId())) { | ||
storeUpdater.deleteStore(store.getId()); | ||
DeletedMenu deletedMenu = convertToDeletedMenu(menu, store.getId()); | ||
deletedMenuUpdater.save(deletedMenu); | ||
publisher.publish(DeleteStoreEvent.of(store.getName(), userId)); | ||
} | ||
} | ||
|
||
private DeletedMenu convertToDeletedMenu(final Menu menu, final long storeId) { | ||
return DeletedMenu.create(menu.getName(), menu.getPrice(), storeId); |
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.
이 부분 추가 된 곳 -> 메뉴 없을 때, 식당 삭제하고 삭제된 메뉴 deletedMenu 형태로 바꾼 후, 해당 테이블에 저장
Related Issue 📌
close #217
Description ✔️
To Reviewers
API 테스트 완료