Skip to content

Commit

Permalink
style: reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
DWL21 committed Feb 7, 2025
1 parent bbf0714 commit 76f2af5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ class CourseService(
val courses = courseReader.findAllByDepartmentGradeIdInMajorRequired(departmentGrade.id!!)
return courses.map {
val courseTimes = courseTimeReader.findAllByCourseId(it.id!!)
CourseResponse.from(course = it, target = listOf(targetReader.formatTargetDisplayName(department, departmentGrade)), courseTimes = courseTimes)
CourseResponse.from(
course = it,
target = listOf(targetReader.formatTargetDisplayName(department, departmentGrade)),
courseTimes = courseTimes
)
}
}

Expand All @@ -55,17 +59,23 @@ class CourseService(
val courses = courseReader.findAllByDepartmentGradeIdInGeneralRequired(departmentGrade.id!!)
return courses.map {
val courseTimes = courseTimeReader.findAllByCourseId(it.id!!)
CourseResponse.from(course = it, target = listOf(targetReader.formatTargetDisplayName(department, departmentGrade)), courseTimes = courseTimes)
CourseResponse.from(
course = it,
target = listOf(targetReader.formatTargetDisplayName(department, departmentGrade)),
courseTimes = courseTimes
)
}
}

@Transactional
fun createCourses(courses: List<CreateCourseRequest>) {
courses.forEach { course ->
try {
val classification = course.category?.let { targetMapper.getMappedClassification(it) } ?: throw
IllegalArgumentException("변환한 이수구분" +
"이 null임, 원본 이수구분 : ${course.category.orEmpty()}")
val classification =
course.category?.let { targetMapper.getMappedClassification(it) } ?: throw IllegalArgumentException(
"변환한 이수구분" +
"이 null임, 원본 이수구분 : ${course.category.orEmpty()}"
)
val parsedClassifications = courseParser.parseClassifications(classification)
if (parsedClassifications.isEmpty()) {
println("허용되지 않는 이수구분 : ${course.category.orEmpty()}")
Expand Down Expand Up @@ -96,9 +106,10 @@ class CourseService(
}
}

val target = course.target?.let { targetMapper.getMappedTarget(it) } ?: throw
IllegalArgumentException("변환한 타겟" +
"이 null임, 원본 타겟 : ${course.target.orEmpty()}")
val target = course.target?.let { targetMapper.getMappedTarget(it) } ?: throw IllegalArgumentException(
"변환한 타겟" +
"이 null임, 원본 타겟 : ${course.target.orEmpty()}"
)
val parsedTargets = courseParser.parseTarget(target)
parsedTargets.forEach { parsedTarget ->
val deptGrades = departmentGradeReader.getByDepartmentIdsAndGrades(parsedTarget)
Expand All @@ -109,11 +120,13 @@ class CourseService(
} else {
parsedClassifications.entries.find { (_, deptIds) ->
if (deptIds.isEmpty()) true else deptIds.contains(deptId)
}?.key ?: throw IllegalArgumentException("이수구분 매칭이 되지 않은 타겟 : 이수구분 - ${course.category.orEmpty()}, 타겟 학과 ID -" +
" ${deptId}")
}?.key ?: throw IllegalArgumentException(
"이수구분 매칭이 되지 않은 타겟 : 이수구분 - ${course.category.orEmpty()}, 타겟 학과 ID -" +
" ${deptId}"
)
}
val assignedCourseId = classificationToCourse[matchedClassification]?.id ?:
throw IllegalStateException("매칭된 이수구분-${matchedClassification}에 해당하는 과목이 존재하지 않음")
val assignedCourseId = classificationToCourse[matchedClassification]?.id
?: throw IllegalStateException("매칭된 이수구분-${matchedClassification}에 해당하는 과목이 존재하지 않음")
val targetDomain = Target(
departmentGradeId = deptGrade.id!!,
courseId = assignedCourseId
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/http/timetable.http
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Content-Type: application/json
{
"schoolId": 21,
"department": "소프트웨어학부",
"grade": 1,
"grade": 3,
"is_chapel": false,
"majorRequiredCourses": ["리눅스시스템관리"],
"majorElectiveCourses": ["(공통)물리1및실험"],
"generalRequiredCourses": ["[비판적사고와표현]비판적사고와학술적글쓰기"],
"majorElectiveCredit": 3,
"majorElectiveCredit": 9,
"generalElectiveCredit": 5
}

Expand Down

0 comments on commit 76f2af5

Please sign in to comment.