Skip to content

Commit 0881001

Browse files
authored
feat: 선착순 레슨 신청시 openTime 비교 예외처리 (#164)
* feat: 레슨 신청 결제 대기 상태 도입 * feat: 선착순 레슨 신청시 openTime 비교 예외처리 * fix: 불필요한 쿼리 검색 조건 삭제
1 parent da722b1 commit 0881001

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
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/domain/lesson/teacher/repository/LessonRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ int countCreatedLessons(
218218
AND (:district IS NULL OR l.district = :district)
219219
AND (:dong IS NULL OR l.dong = :dong)
220220
AND (:ri IS NULL OR l.ri = :ri)
221-
AND MATCH(l.lesson_name, l.description) AGAINST(:search IN BOOLEAN MODE)
221+
AND MATCH(l.lesson_name) AGAINST(:search IN BOOLEAN MODE)
222222
ORDER BY
223223
CASE WHEN :sort = 'LATEST' THEN l.created_at END DESC,
224224
CASE WHEN :sort = 'OLDEST' THEN l.created_at END ASC,
@@ -248,7 +248,7 @@ SELECT COUNT(*) FROM (
248248
AND (:district IS NULL OR l.district = :district)
249249
AND (:dong IS NULL OR l.dong = :dong)
250250
AND (:ri IS NULL OR l.ri = :ri)
251-
AND MATCH(l.lesson_name, l.description) AGAINST(:search IN BOOLEAN MODE)
251+
AND MATCH(l.lesson_name) AGAINST(:search IN BOOLEAN MODE)
252252
LIMIT :limit
253253
) t
254254
""", nativeQuery = true)

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)