Skip to content

Commit

Permalink
feat: 시간표 조합이 없으면 예외 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
DWL21 committed Feb 5, 2025
1 parent 0b58afc commit 10526b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.yourssu.soongpt.domain.course.implement

import com.yourssu.soongpt.domain.course.implement.exception.InvalidTimetableRequestException
import org.springframework.stereotype.Component

@Component
Expand All @@ -13,4 +14,10 @@ class CoursesFactory {
}
}.map { Courses(it) }
}

fun validateEmpty(timetableCandidates: List<Courses>) {
if (timetableCandidates.isEmpty()) {
throw InvalidTimetableRequestException()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.yourssu.soongpt.domain.course.implement.exception

import com.yourssu.soongpt.common.handler.BadRequestException

class InvalidTimetableRequestException : BadRequestException(message = "시간표가 나올 수 있는 경우의 수가 없습니다.") {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ class TimetableService(
val majorElectiveCourses =
command.majorElectiveCourses.map { courseReader.findAllByCourseNameInMajorElective(department.id!!, it) }
val generalRequiredCourses =
command.generalRequiredCourses.map {
courseReader.findAllByCourseNameInGeneralRequired(
department.id!!,
it
)
command.generalRequiredCourses.map { courseReader.findAllByCourseNameInGeneralRequired(department.id!!, it)
}

val coursesCandidates =
coursesFactory.generateTimetableCandidates(majorRequiredCourses + majorElectiveCourses + generalRequiredCourses)
coursesFactory.validateEmpty(coursesCandidates)

val responses = ArrayList<TimetableResponse>()
for (courses in coursesCandidates) {
val timetable = timetableWriter.save(Timetable(tag = Tag.DEFAULT))
Expand Down

0 comments on commit 10526b2

Please sign in to comment.