From d16034dd02b76fb4f9aaf39b96af4b8a0ab861e3 Mon Sep 17 00:00:00 2001 From: Nhat-Original Date: Thu, 23 May 2024 01:01:13 +0700 Subject: [PATCH] chore: uncomment get menu item detail mapping in MenuItemController.java --- .../spring/controller/MenuItemController.java | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java b/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java index 54acf15..a3ba0b7 100644 --- a/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java +++ b/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java @@ -14,36 +14,43 @@ @RequestMapping(Endpoint.MenuItem.BASE) public class MenuItemController { private final MenuItemService menuItemService; + public MenuItemController(MenuItemService menuItemService) { this.menuItemService = menuItemService; } + @GetMapping(Endpoint.MenuItem.GET_ALL) public List findAll(@RequestParam(name = "name", required = false) String name) { return menuItemService.findAll(name); } + @PostMapping(Endpoint.MenuItem.CREATE) - public MenuItemDetailDto create(@RequestBody MenuItemDetailDto menuItemDto) { - - return menuItemService.create(menuItemDto); - } - @GetMapping(Endpoint.MenuItem.GET_ALL_BY_MENU_ID) - public List findAllByMenuId(@PathVariable UUID menuId) { - return menuItemService.findAllByMenuId(menuId); - } - @PatchMapping(Endpoint.MenuItem.UPDATE) - public MenuItemDetailDto update(@PathVariable UUID id, @RequestBody MenuItemDetailDto menuItemDto) { - return menuItemService.update(id, menuItemDto); - } - @DeleteMapping(Endpoint.MenuItem.DELETE) - public ResponseEntity delete(@PathVariable UUID id) { - return ResponseEntity.ok(menuItemService.delete(id)); - } -// @GetMapping(Endpoint.MenuItem.GET_ONE) -// public MenuItemDetailDto findById(@PathVariable UUID id) { -// return menuItemService.findById(id); -// } -// @GetMapping("") -// public List findAllByOwner() { -// return menuItemService.findAll(null); -// } + public MenuItemDetailDto create(@RequestBody MenuItemDetailDto menuItemDto) { + + return menuItemService.create(menuItemDto); + } + + @GetMapping(Endpoint.MenuItem.GET_ALL_BY_MENU_ID) + public List findAllByMenuId(@PathVariable UUID menuId) { + return menuItemService.findAllByMenuId(menuId); + } + + @PatchMapping(Endpoint.MenuItem.UPDATE) + public MenuItemDetailDto update(@PathVariable UUID id, @RequestBody MenuItemDetailDto menuItemDto) { + return menuItemService.update(id, menuItemDto); + } + + @DeleteMapping(Endpoint.MenuItem.DELETE) + public ResponseEntity delete(@PathVariable UUID id) { + return ResponseEntity.ok(menuItemService.delete(id)); + } + + @GetMapping(Endpoint.MenuItem.GET_ONE) + public MenuItemDetailDto findById(@PathVariable UUID id) { + return menuItemService.findById(id); + } + + // public List findAllByOwner() { + // return menuItemService.findAll(null); + // } }