diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/repository/TimetableLectureRepositoryV2.java b/src/main/java/in/koreatech/koin/domain/timetableV2/repository/TimetableLectureRepositoryV2.java index 2bc845d12..60161cf51 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/repository/TimetableLectureRepositoryV2.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/repository/TimetableLectureRepositoryV2.java @@ -26,12 +26,7 @@ default TimetableLecture getById(Integer id) { TimetableLecture save(TimetableLecture timetableLecture); - Optional findByTimetableFrameIdAndLectureId(Integer frameId, Integer lectureId); - - default TimetableLecture getByFrameIdAndLectureId(Integer frameId, Integer lectureId) { - return findByTimetableFrameIdAndLectureId(frameId, lectureId) - .orElseThrow(() -> TimetableLectureNotFoundException.withDetail("frameId: " + frameId + ", lectureId: " + lectureId)); - } + List findAllByTimetableFrameIdAndLectureId(Integer frameId, Integer lectureId); @Query(value = "SELECT * FROM timetable_lecture WHERE id = :id", nativeQuery = true) Optional findByIdWithDeleted(@Param("id") Integer id); diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableLectureService.java b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableLectureService.java index b1120cc08..90773daa1 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableLectureService.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/service/TimetableLectureService.java @@ -82,8 +82,7 @@ public void deleteTimetableLectures(List request, Integer userId) { public void deleteTimetableLectureByFrameId(Integer frameId, Integer lectureId, Integer userId) { TimetableFrame frame = timetableFrameRepositoryV2.getById(frameId); validateUserAuthorization(frame.getUser().getId(), userId); - TimetableLecture timetableLecture = timetableLectureRepositoryV2.getByFrameIdAndLectureId(frameId, lectureId); - timetableLecture.delete(); + timetableLectureRepositoryV2.findAllByTimetableFrameIdAndLectureId(frameId, lectureId).forEach(TimetableLecture::delete); } @Transactional