Skip to content

Commit

Permalink
feat: 조회 API 수강 시간 없는 과목 제외
Browse files Browse the repository at this point in the history
  • Loading branch information
DWL21 committed Feb 9, 2025
1 parent 7feb275 commit 93b1bb0
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,44 @@ class CourseService(
val department = departmentReader.getByName(command.departmentName)
val departmentGrade = departmentGradeReader.getByDepartmentIdAndGrade(department.id!!, command.grade)
val courses = courseReader.findAllByDepartmentGradeIdInMajorRequired(departmentGrade.id!!)
return courses.map {
return filterNotEmptyCourseTimes(courses.map {
val courseTimes = courseTimeReader.findAllByCourseId(it.id!!)
CourseResponse.from(
course = it,
target = listOf(targetReader.formatTargetDisplayName(department, departmentGrade)),
courseTimes = courseTimes
)
}
})
}

fun findByDepartmentNameInMajorElective(command: FoundDepartmentCommand): List<CourseResponse> {
val department = departmentReader.getByName(command.departmentName)
val courses = courseReader.findAllByDepartmentIdInMajorElective(department.id!!)
return courses.map {(course, departmentGrades) ->
return filterNotEmptyCourseTimes(courses.map { (course, departmentGrades) ->
val courseTimes = courseTimeReader.findAllByCourseId(course.id!!)
CourseResponse.from(course = course, target = departmentGrades.map { targetReader.formatTargetDisplayName(department, it) } , courseTimes = courseTimes)
}
CourseResponse.from(
course = course,
target = departmentGrades.map { targetReader.formatTargetDisplayName(department, it) },
courseTimes = courseTimes)
})
}

fun findByDepartmentNameInGeneralRequired(command: FoundDepartmentCommand): List<CourseResponse> {
val department = departmentReader.getByName(command.departmentName)
val departmentGrade = departmentGradeReader.getByDepartmentIdAndGrade(department.id!!, command.grade)
val courses = courseReader.findAllByDepartmentGradeIdInGeneralRequired(departmentGrade.id!!)
return courses.map {
return filterNotEmptyCourseTimes(courses.map {
val courseTimes = courseTimeReader.findAllByCourseId(it.id!!)
CourseResponse.from(
course = it,
target = listOf(targetReader.formatTargetDisplayName(department, departmentGrade)),
courseTimes = courseTimes
)
}
})
}

private fun filterNotEmptyCourseTimes(courses: List<CourseResponse>): List<CourseResponse> {
return courses.filter { it.courseTime.isNotEmpty() }
}

@Transactional
Expand Down

0 comments on commit 93b1bb0

Please sign in to comment.