From 212cb394cf8c1b559fefc307278a0367b813ae3c Mon Sep 17 00:00:00 2001 From: ParkRootSeok Date: Wed, 8 Feb 2023 02:00:03 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20#163=20-=20ObjectMapper=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=EC=97=90=20=EC=83=9D=EC=84=B1=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/cafemenu/api/CafeMenuApiController.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 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 cc80f4f5..5e2cd3c9 100644 --- a/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java +++ b/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java @@ -39,6 +39,7 @@ public class CafeMenuApiController { private final CafeMenuService cafeMenuService; + private final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); /** * 카페 메뉴 등록 @@ -51,12 +52,8 @@ public SuccessResponse registerMenu(@PathVariable(name = "cafeI @RequestParam @Valid String menuInfo, @Parameter(description = "메뉴 이미지") @RequestPart(required = false) MultipartFile menuImage) throws CafeException, IOException { - - ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); PostCafeMenuReq postCafeMenuReq = objectMapper.readValue(menuInfo, new TypeReference<>() {}); - return new SuccessResponse<>(cafeMenuService.registerMenu(cafeId, postCafeMenuReq, menuImage)); - } @ApiOperation(value = "카페 메뉴 조회", notes = "카페 ID를 받아 해당 카페에 대한 모든 메뉴를 조회한다.") @@ -75,13 +72,10 @@ public SuccessResponse> getMenu(@PathVariable(name = "cafeI 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()); + @Parameter(description = "수정할 메뉴 이미지") @RequestPart(required = false) MultipartFile menuImage) + throws IOException { PatchCafeMenuReq patchCafeMenuReq = objectMapper.readValue(menuInfo, new TypeReference<>() {}); - return new SuccessResponse<>(cafeMenuService.updateMenu(menuId, patchCafeMenuReq, menuImage)); - } @ApiOperation(value = "카페 메뉴 삭제", notes = "카페 메뉴 ID를 받아 삭제한다.")