Skip to content

Commit

Permalink
[Refactor] #163 - 카페 메뉴 수정 API 로직 수정
Browse files Browse the repository at this point in the history
로직 수정 및 Swagger 설정 추가
  • Loading branch information
parkrootseok committed Feb 7, 2023
1 parent 7ca887c commit cdb0b15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ public SuccessResponse<List<GetCafeMenuRes>> getMenu(@PathVariable(name = "cafeI
}


@ApiOperation(value = "카페 메뉴 수정", notes = "카페 ID, 카페 메뉴 ID를 받아 수정한다.")
@ApiOperation(value = "카페 메뉴 수정", notes = "카페 메뉴 ID를 받아 수정한다.")
@ApiImplicitParam(name = "menuId", value = "카페 메뉴 ID")
@PatchMapping("/{menuId}/cafe/{cafeId}")
public SuccessResponse<PatchCafeMenuRes> updateMenu(@PathVariable(name = "menuId") Long menuId,
@RequestPart @Valid PatchCafeMenuReq patchCafeMenuReq,
@RequestPart MultipartFile menuImage) throws IOException {
@PatchMapping("/{menuId}")
public SuccessResponse<PatchCafeMenuRes> updateMenu(@PathVariable(name = "cafeId") Long menuId,
@Parameter(description = "수정할 메뉴 정보 : {\"name\": \"아메리카노\", \"description\": \"맛있어!\", \"price\": 4500}")
@RequestParam @Valid String menuInfo,
@Parameter(description = "수정할 메뉴 이미지") @RequestPart(required = false) MultipartFile menuImage) throws IOException {

ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
PatchCafeMenuReq patchCafeMenuReq = objectMapper.readValue(menuInfo, new TypeReference<>() {});

return new SuccessResponse<>(cafeMenuService.updateMenu(menuId, patchCafeMenuReq, menuImage));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ private Cafe getCafe(Long cafeId) throws CafeException {
/**
* 카페 메뉴 수정
*/
public PatchCafeMenuRes updateMenu(Long cafeMenuId, PatchCafeMenuReq patchCafeMenuReq, MultipartFile menuImage)
public PatchCafeMenuRes updateMenu(Long menuId, PatchCafeMenuReq patchCafeMenuReq, MultipartFile menuImage)
throws IOException {

CafeMenu findMenu = cafeMenuRepository
.findById(cafeMenuId)
.findById(menuId)
.orElseThrow(() -> new CafeMenuException(INVALID_MENU));

if (patchCafeMenuReq.getName() != NOT_UPDATE_NAME) {
Expand Down

0 comments on commit cdb0b15

Please sign in to comment.