Skip to content

Commit 379558e

Browse files
committed
feat: 선착순 레슨 신청시 openTime 비교 예외처리
1 parent c429a3c commit 379558e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/main/java/com/threestar/trainus/domain/lesson/student/service/StudentLessonService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,14 @@ public LessonApplicationResponseDto applyToLesson(Long lessonId, Long userId) {
172172
throw new BusinessException(ErrorCode.LESSON_NOT_AVAILABLE);
173173
}
174174

175+
176+
175177
// 선착순 여부에 따라 저장 처리 분기
176178
if (lesson.getOpenRun()) {
179+
// 신청 시간 체크
180+
if (java.time.LocalDateTime.now().isBefore(lesson.getOpenTime())) {
181+
throw new BusinessException(ErrorCode.LESSON_NOT_YET_OPEN);
182+
}
177183
// 바로 참가자 등록, 인원수 증가
178184
LessonParticipant participant = LessonParticipant.builder()
179185
.lesson(lesson)

src/main/java/com/threestar/trainus/global/exception/domain/ErrorCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public enum ErrorCode {
9292
DUPLICATE_LESSON(HttpStatus.CONFLICT, "동일한 이름과 시간으로 이미 생성된 레슨이 있습니다."),
9393
LESSON_TIME_OVERLAP(HttpStatus.CONFLICT, "해당 시간대에 이미 다른 레슨이 예정되어 있습니다."),
9494
LESSON_NOT_AVAILABLE(HttpStatus.BAD_REQUEST, "신청 불가능한 상태의 레슨입니다."),
95+
LESSON_NOT_YET_OPEN(HttpStatus.BAD_REQUEST, "아직 신청 가능한 시간이 아닙니다."),
9596

9697
// 409
9798
ALREADY_APPLIED(HttpStatus.CONFLICT, "이미 신청한 레슨입니다."),

0 commit comments

Comments
 (0)