Skip to content

Commit

Permalink
[Refactor] #163 - 카페 생성 API Consumes 설정 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
parkrootseok committed Feb 7, 2023
1 parent 4487464 commit 6f3c1c4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/main/java/shop/cazait/domain/cafe/api/CafeController.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String> addCafe(@PathVariable Long masterId,
@RequestParam String json,
@RequestPart(value = "cafeImages", required = false) List<MultipartFile> 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<MultipartFile> imageFiles) throws JsonProcessingException {
cafeService.addCafe(masterId, postCafeReq, imageFiles);
return new SuccessResponse<>("카페 등록 완료");

}

@GetMapping("/all/user/{userId}")
Expand Down

0 comments on commit 6f3c1c4

Please sign in to comment.