Skip to content

Commit

Permalink
Merge pull request #199 from Make-A-Wish-Sopt/feature/jyoung-#198-dev…
Browse files Browse the repository at this point in the history
…elop

[FEAT] 편지만 원하는 소원일 때 편지가 아닌 경우 예외처리
  • Loading branch information
wlwpfh authored Sep 12, 2024
2 parents 54f49b8 + 0d99007 commit 68c7055
Show file tree
Hide file tree
Showing 4 changed files with 12 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());
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/db/migration/V3.5__wish.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table wish drop column present_price;
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private Wish createWish(User user){
.title("소원 제목")
.startAt(Util.convertToDate(getLocalDateTime(0)))
.endAt(Util.convertToDate(getLocalDateTime(7)))
.wantsGift(true)
.build();
}
}

0 comments on commit 68c7055

Please sign in to comment.