Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/innovationacademy-kr/Cabi in…
Browse files Browse the repository at this point in the history
…to fe/dev/prevent_extension_use_when_overdue/#1661
  • Loading branch information
jnkeniaem committed Jul 17, 2024
2 parents bd69a17 + c5ea607 commit fb4d223
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public enum ExceptionStatus {
CLUB_HAS_LENT_CABINET(HttpStatus.NOT_ACCEPTABLE, "대여 중인 사물함을 반납 후 삭제할 수 있습니다."),
HANEAPI_ERROR(HttpStatus.BAD_GATEWAY, "24HANE API 통신에 에러가 있습니다."),
EXTENSION_NOT_FOUND(HttpStatus.BAD_REQUEST, "연장권이 존재하지 않습니다."),
EXTENSION_LENT_DELAYED(HttpStatus.FORBIDDEN, "연장권은 연체된 사물함에 사용할 수 없습니다."),
EXTENSION_SOLO_IN_SHARE_NOT_ALLOWED(HttpStatus.UNAUTHORIZED, "연장권은 1명일 때 사용할 수 없습니다."),
EXTENSION_LENT_DELAYED(HttpStatus.UNAUTHORIZED, "연장권은 연체된 사물함에 사용할 수 없습니다."),
MAIL_BAD_GATEWAY(HttpStatus.BAD_GATEWAY, "메일 전송 중 에러가 발생했습니다"),
SLACK_REQUEST_BAD_GATEWAY(HttpStatus.BAD_GATEWAY, "슬랙 인증 중 에러가 발생했습니다."),
SLACK_MESSAGE_SEND_BAD_GATEWAY(HttpStatus.BAD_GATEWAY, "슬랙 메세지 전송 중 에러가 발생했습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public enum LentPolicyStatus {
INVALID_LENT_TYPE,
INVALID_ARGUMENT,
INVALID_EXPIREDAT, SWAP_SAME_CABINET, LENT_NOT_CLUB,

SWAP_LIMIT_EXCEEDED
SWAP_LIMIT_EXCEEDED,
OVERDUE_CABINET_EXTEND

}
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ public void plusExtensionDays(Long userId, Integer days) {
userId, LentExtensionType.ALL, days);
List<LentHistory> lentHistories = lentQueryService.findCabinetActiveLentHistories(
cabinet.getId());
lentHistories.forEach(
lentHistory -> lentPolicyService.verifyExtendable(lentHistory.getExpiredAt())
);
lentExtensionCommandService.useLentExtension(lentExtensionByItem, lentHistories);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ private void handlePolicyStatus(LentPolicyStatus status, LocalDateTime policyDat
throw ExceptionStatus.LENT_FULL.asServiceException();
case OVERDUE_CABINET:
throw ExceptionStatus.LENT_EXPIRED.asServiceException();
case OVERDUE_CABINET_EXTEND:
throw ExceptionStatus.EXTENSION_LENT_DELAYED.asServiceException();
case LENT_CLUB:
throw ExceptionStatus.LENT_CLUB.asServiceException();
case LENT_NOT_CLUB:
Expand Down Expand Up @@ -307,4 +309,17 @@ public void verifySwappable(boolean existSwapRecord, LocalDateTime swapExpiredAt
handlePolicyStatus(LentPolicyStatus.SWAP_LIMIT_EXCEEDED, swapExpiredAt);
}
}

/**
* 연장권 사용 시, 연체된 사물함에 사용하는지 확인합니다
*
* @param expiredAt 대여만료 날짜
*/
public void verifyExtendable(LocalDateTime expiredAt) {
LentPolicyStatus status = LentPolicyStatus.FINE;
if (expiredAt.isBefore(LocalDateTime.now())) {
status = LentPolicyStatus.OVERDUE_CABINET_EXTEND;
}
handlePolicyStatus(status, null);
}
}

0 comments on commit fb4d223

Please sign in to comment.