Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

메뉴 등록 API 수정 #269

Merged
merged 2 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.error.status.SuccessStatus;

Expand All @@ -59,8 +60,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