Skip to content

Commit

Permalink
Merge pull request #269 from CaZaIt/refactor/menu
Browse files Browse the repository at this point in the history
메뉴 등록 API 수정
  • Loading branch information
parkrootseok authored May 10, 2023
2 parents add7b51 + 05ef5b0 commit 717f010
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<PostCafeMenuRes> registerMenu(@PathVariable Long cafeId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ public List<GetCafeMenuRes> 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 {
Expand Down

0 comments on commit 717f010

Please sign in to comment.