From cdb0b15f73141c2ab6473868e522fa63910990a7 Mon Sep 17 00:00:00 2001 From: ParkRootSeok Date: Wed, 8 Feb 2023 01:59:05 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20#163=20-=20=EC=B9=B4=ED=8E=98=20?= =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EC=88=98=EC=A0=95=20API=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 로직 수정 및 Swagger 설정 추가 --- .../domain/cafemenu/api/CafeMenuApiController.java | 14 +++++++++----- .../domain/cafemenu/service/CafeMenuService.java | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java b/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java index 9a92d7aa..cc80f4f5 100644 --- a/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java +++ b/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java @@ -69,12 +69,16 @@ public SuccessResponse> getMenu(@PathVariable(name = "cafeI } - @ApiOperation(value = "카페 메뉴 수정", notes = "카페 ID, 카페 메뉴 ID를 받아 수정한다.") + @ApiOperation(value = "카페 메뉴 수정", notes = "카페 메뉴 ID를 받아 수정한다.") @ApiImplicitParam(name = "menuId", value = "카페 메뉴 ID") - @PatchMapping("/{menuId}/cafe/{cafeId}") - public SuccessResponse updateMenu(@PathVariable(name = "menuId") Long menuId, - @RequestPart @Valid PatchCafeMenuReq patchCafeMenuReq, - @RequestPart MultipartFile menuImage) throws IOException { + @PatchMapping("/{menuId}") + public SuccessResponse updateMenu(@PathVariable(name = "cafeId") Long menuId, + @Parameter(description = "수정할 메뉴 정보 : {\"name\": \"아메리카노\", \"description\": \"맛있어!\", \"price\": 4500}") + @RequestParam @Valid String menuInfo, + @Parameter(description = "수정할 메뉴 이미지") @RequestPart(required = false) MultipartFile menuImage) throws IOException { + + ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); + PatchCafeMenuReq patchCafeMenuReq = objectMapper.readValue(menuInfo, new TypeReference<>() {}); return new SuccessResponse<>(cafeMenuService.updateMenu(menuId, patchCafeMenuReq, menuImage)); diff --git a/src/main/java/shop/cazait/domain/cafemenu/service/CafeMenuService.java b/src/main/java/shop/cazait/domain/cafemenu/service/CafeMenuService.java index fe42107a..89d7535c 100644 --- a/src/main/java/shop/cazait/domain/cafemenu/service/CafeMenuService.java +++ b/src/main/java/shop/cazait/domain/cafemenu/service/CafeMenuService.java @@ -74,11 +74,11 @@ private Cafe getCafe(Long cafeId) throws CafeException { /** * 카페 메뉴 수정 */ - public PatchCafeMenuRes updateMenu(Long cafeMenuId, PatchCafeMenuReq patchCafeMenuReq, MultipartFile menuImage) + public PatchCafeMenuRes updateMenu(Long menuId, PatchCafeMenuReq patchCafeMenuReq, MultipartFile menuImage) throws IOException { CafeMenu findMenu = cafeMenuRepository - .findById(cafeMenuId) + .findById(menuId) .orElseThrow(() -> new CafeMenuException(INVALID_MENU)); if (patchCafeMenuReq.getName() != NOT_UPDATE_NAME) {