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 2e1f6591..bd62830e 100644 --- a/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java +++ b/src/main/java/shop/cazait/domain/cafemenu/api/CafeMenuApiController.java @@ -36,6 +36,7 @@ import shop.cazait.domain.cafemenu.dto.PostCafeMenuReq; import shop.cazait.domain.cafemenu.dto.PostCafeMenuRes; import shop.cazait.domain.cafemenu.service.CafeMenuService; +import shop.cazait.global.common.dto.response.FailResponse; import shop.cazait.global.common.dto.response.SuccessResponse; import shop.cazait.global.config.encrypt.NoAuth; import shop.cazait.global.error.status.SuccessStatus; @@ -60,8 +61,16 @@ public class CafeMenuApiController { description = "메뉴 등록 성공", content = @Content(schema = @Schema(implementation = PostCafeMenuRes.class)) ), - @ApiResponse(responseCode = "400", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "404", description = "존재하지 않는 카페"), + @ApiResponse( + responseCode = "400", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailResponse.class)) + ), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 카페", + content = @Content(schema = @Schema(implementation = FailResponse.class)) + ), }) @PostMapping(value ="/cafe/{cafeId}", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) public SuccessResponse registerMenu(@PathVariable Long cafeId, 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 712b20af..079d3088 100644 --- a/src/main/java/shop/cazait/domain/cafemenu/service/CafeMenuService.java +++ b/src/main/java/shop/cazait/domain/cafemenu/service/CafeMenuService.java @@ -54,13 +54,16 @@ public List getMenu(Long cafeId) { public PostCafeMenuRes registerMenu(Long cafeId, PostCafeMenuReq postCafeMenuReq, MultipartFile menuImage) throws CafeException, IOException { + String uploadFileName = null; Cafe findCafe = getCafe(cafeId); - // todo: image가 없을 떄는 업로드 하지 않도록 수정 - String uploadFileName = awsS3Servicel.uploadImage(menuImage); + + if (menuImage != null) { + uploadFileName = awsS3Servicel.uploadImage(menuImage); + } + CafeMenu menu = PostCafeMenuReq.toEntity(findCafe, postCafeMenuReq, uploadFileName); CafeMenu addMenu = cafeMenuRepository.save(menu); return PostCafeMenuRes.of(addMenu); - } private Cafe getCafe(Long cafeId) throws CafeException {