Skip to content

Commit

Permalink
[FEAT] 예외 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wlwpfh committed Sep 12, 2024
1 parent fceb0bf commit ffb2fd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum ErrorMessage {

/** gift menu **/
INVALID_GIFT_MENU("존재하지 않는 선물 종류입니다."),
WRONG_GIFT("잘못된 선물입니다."),
;

private final String message;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/sopterm/makeawish/service/CakeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public CakeCreateResponseDTO createPresent(CakeCreateRequest request) {
val cake = getCake(request.cakeId());
val wish = wishService.getWish(request.wishId());
val giftMenu = getGiftMenuInfo(request.giftMenuId());

checkGiftMenu(wish, giftMenu);

val present = Present.builder()
.name(request.name())
.message(request.message())
Expand All @@ -174,4 +177,10 @@ public List<GiftMenuResponseDTO> getAllGiftMenu() {
.map(GiftMenuResponseDTO::from)
.collect(Collectors.toList());
}

private void checkGiftMenu(Wish wish, GiftMenu giftMenu){
if(!wish.isWantsGift() && !giftMenu.getId().equals(0L)){
throw new IllegalArgumentException(WRONG_GIFT.getMessage());
}
}
}

0 comments on commit ffb2fd2

Please sign in to comment.