Skip to content

Commit

Permalink
feat: 시간표에서 채플 조회 기능 구현 / 주석 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
DWL21 committed Feb 8, 2025
1 parent 59fbefe commit 03248d1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ class CourseRepositoryImpl(
)
.fetch()
.groupBy { it.get(courseEntity)!! }
.map { (course, departmentGrades) -> course.toDomain() to departmentGrades.map { it.get(departmentGradeEntity)!!.toDomain() } }
.map { (course, departmentGrades) ->
course.toDomain() to departmentGrades.map {
it.get(
departmentGradeEntity
)!!.toDomain()
}
}
}

override fun findAllByDepartmentGradeId(departmentGradeId: Long, classification: Classification): List<Course> {
Expand Down Expand Up @@ -76,6 +82,18 @@ class CourseRepositoryImpl(
.map { it.toDomain() }
return Courses(courses)
}

override fun findChapelsByDepartmentGradeId(departmentGradeId: Long): List<Course> {
return jpaQueryFactory.selectFrom(courseEntity)
.innerJoin(targetEntity)
.on(courseEntity.id.eq(targetEntity.courseId))
.where(
targetEntity.departmentGradeId.eq(departmentGradeId),
courseEntity.classification.eq(Classification.CHAPEL)
)
.fetch()
.map { it.toDomain() }
}
}

interface CourseJpaRepository : JpaRepository<CourseEntity, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class CourseReader(
return findAllByCourseName(departmentId, courseName, Classification.GENERAL_REQUIRED)
}

fun findChapelsByDepartmentGradeId(departmentGradeId: Long): List<Course> {
return courseRepository.findChapelsByDepartmentGradeId(departmentGradeId)
}

private fun findAllByCourseName(departmentId: Long, courseName: String, classification: Classification): Courses {
val courses = courseRepository.findByDepartmentIdAndCourseName(departmentId, courseName, classification)
if (courses.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ interface CourseRepository {
fun findAllByDepartmentGradeId(departmentGradeId: Long, classification: Classification): List<Course>
fun getAll(ids: List<Long>): List<Course>
fun findByDepartmentIdAndCourseName(departmentId: Long, courseName: String, classification: Classification): Courses
fun findChapelsByDepartmentGradeId(departmentGradeId: Long): List<Course>
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ class TimeTableFactory(
command.generalRequiredCourses.map {
courseReader.findAllByCourseNameInGeneralRequired(department.id, it)
}
val chapels =
// if (command.isChapel) courseReader.findChapelsByDepartmentGradeId(departmentGrade.id!!)
// .map { Courses(listOf(it)) }
// else
emptyList<Courses>()

validateCreditRule(
majorRequiredCourses = majorRequiredCourses,
generalRequiredCourses = generalRequiredCourses,
majorElectiveCredit = command.majorElectiveCredit,
generalElectiveCredit = command.generalElectiveCredit,
)

val step1 = CoursesFactory(majorRequiredCourses + majorElectiveCourses + generalRequiredCourses)
val step1 = CoursesFactory(majorRequiredCourses + majorElectiveCourses + generalRequiredCourses + chapels)
.generateTimetableCandidates()
val step2 = timetableCandidateFactory.createTimetableCandidatesWithRule(step1)

Expand Down

0 comments on commit 03248d1

Please sign in to comment.