Skip to content

Commit

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

[FIX] 소원 조회 시 문구 수정
  • Loading branch information
wlwpfh authored Jan 24, 2025
2 parents 8356936 + 998fe63 commit d6b12de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum ErrorMessage {
EXPIRED_BIRTHDAY_WISH("현재 생일 주간이 아닙니다."),
PAST_WISH("소원 링크 주간은 과거로 설정할 수 없습니다."),
INVALID_TERM("시작 일자는 종료 일자보다 미래일 수 없습니다."),
ACCESS_END_WISH("이미 종료된 소원이에요!"),

/** user **/
INVALID_USER("인증되지 않은 회원입니다."),
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/sopterm/makeawish/domain/wish/Wish.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.val;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -110,4 +111,9 @@ public void updateTerm(LocalDateTime startAt, LocalDateTime endAt) {
this.endAt = endAt;
}
}

public int getRestStartDayFromNow() {
val now = LocalDateTime.now().toLocalDate().atStartOfDay();
return (int) ChronoUnit.DAYS.between(now, this.startAt);
}
}
7 changes: 5 additions & 2 deletions src/main/java/com/sopterm/makeawish/service/WishService.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ public Long createWish(Long userId, WishRequestDTO requestDTO) {

public WishResponseDTO findWish(Long wishId) throws AccessDeniedException {
val wish = getWish(wishId);
if (!wish.getStatus(0).equals(WHILE)) {
throw new AccessDeniedException(INVALID_WISH.getMessage());
if (wish.getStatus(0).equals(BEFORE)) {
throw new AccessDeniedException("해당 소원은 " + wish.getRestStartDayFromNow() +"일 뒤부터 활성화돼요!");
}
if(wish.getStatus(0).equals(END)) {
throw new AccessDeniedException(ACCESS_END_WISH.getMessage());
}
return WishResponseDTO.from(wish);
}
Expand Down

0 comments on commit d6b12de

Please sign in to comment.