Skip to content

Commit 781e93a

Browse files
committed
feat: schedule ID 유효 여부 검사
1 parent 7bdf45c commit 781e93a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

aics-domain/src/main/java/kgu/developers/domain/schedule/application/query/ScheduleQueryService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ public Schedule getBySubmissionType(SubmissionType submissionType) {
2727
return scheduleRepository.findBySubmissionType(submissionType)
2828
.orElseThrow(ScheduleNotFoundException::new);
2929
}
30+
31+
public void checkExistsOrThrow(Long id) {
32+
if (!scheduleRepository.existsById(id)) {
33+
throw new ScheduleNotFoundException();
34+
}
35+
}
3036
}

aics-domain/src/main/java/kgu/developers/domain/schedule/domain/ScheduleRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public interface ScheduleRepository {
99
Optional<Schedule> findById(Long id);
1010
List<Schedule> findAll();
1111
Optional<Schedule> findBySubmissionType(SubmissionType submissionType);
12+
boolean existsById(Long id);
1213
}

aics-domain/src/main/java/kgu/developers/domain/schedule/infrastructure/repository/ScheduleRepositoryImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ public Optional<Schedule> findBySubmissionType(SubmissionType submissionType) {
4646
.map(ScheduleJpaEntity::toDomain);
4747
}
4848

49+
@Override
50+
public boolean existsById(Long id) {
51+
return jpaScheduleRepository.existsById(id);
52+
}
4953
}

0 commit comments

Comments
 (0)