Skip to content

Commit

Permalink
feat: 메뉴 삭제 기능 구현 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
djdongjae committed Jun 11, 2024
1 parent e5b572c commit 95f4311
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ public BaseResponse<?> updateMenu(
menuService.updateMenu(id, image, requestDto);
return BaseResponse.success(SuccessCode.MENU_PATCH_SUCCESS);
}

@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public BaseResponse<?> deleteMenu(@PathVariable Long id) {
menuService.deleteMenu(id);
return BaseResponse.success(SuccessCode.MENU_DELETE_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum SuccessCode {
INVENTORY_DELETE_SUCCESS(HttpStatus.OK, "재고 삭제에 성공했습니다."),
INVENTORY_PATCH_SUCCESS(HttpStatus.OK, "재고 수정이 완료되었습니다."),
MENU_PATCH_SUCCESS(HttpStatus.OK, "메뉴 수정이 완료되었습니다."),
MENU_DELETE_SUCCESS(HttpStatus.OK, "메뉴 삭제에 성공했습니다."),

/**
* 201 CREATED
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/skhu/tastyinventory_be/service/MenuService.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,16 @@ public void updateMenu(Long id, MultipartFile image, MenuRequestDto requestDto)
).forEach(recipeRepository::save);
}

@Transactional
public void deleteMenu(Long id) {
Menu menu = menuRepository.findById(id).orElseThrow(
() -> new NotFoundException(
ErrorCode.NOT_FOUND_MENU_EXCEPTION,
ErrorCode.NOT_FOUND_MENU_EXCEPTION.getMessage()
)
);

menuRepository.delete(menu);
}

}

0 comments on commit 95f4311

Please sign in to comment.