From 6f3c1c49396365b2c7a665f501e9092175facb2f Mon Sep 17 00:00:00 2001 From: ParkRootSeok Date: Wed, 8 Feb 2023 00:00:35 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20#163=20-=20=EC=B9=B4=ED=8E=98=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20API=20Consumes=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cazait/domain/cafe/api/CafeController.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/shop/cazait/domain/cafe/api/CafeController.java b/src/main/java/shop/cazait/domain/cafe/api/CafeController.java index 2d2fb093..21a02950 100644 --- a/src/main/java/shop/cazait/domain/cafe/api/CafeController.java +++ b/src/main/java/shop/cazait/domain/cafe/api/CafeController.java @@ -1,9 +1,6 @@ package shop.cazait.domain.cafe.api; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -34,18 +31,14 @@ public class CafeController { private final CafeService cafeService; - @PostMapping(value = "/add/master/{masterId}", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) + @PostMapping(value = "/add/master/{masterId}", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) @ApiOperation(value = "카페 등록", notes = "master가 카페를 등록한다.") @ApiImplicitParam(name = "masterId", value = "마스터 ID") public SuccessResponse addCafe(@PathVariable Long masterId, - @RequestParam String json, - @RequestPart(value = "cafeImages", required = false) List cafeImage) throws JsonProcessingException { - - ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); - PostCafeReq postCafeReq = objectMapper.readValue(json, new TypeReference<>() {}); - cafeService.addCafe(masterId, postCafeReq, cafeImage); + @RequestPart @Valid PostCafeReq postCafeReq, + @RequestPart(required = false) List imageFiles) throws JsonProcessingException { + cafeService.addCafe(masterId, postCafeReq, imageFiles); return new SuccessResponse<>("카페 등록 완료"); - } @GetMapping("/all/user/{userId}")