-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #21 다음 사항 구현했습니다. - 전공 필수, 교양 필수(채플 포함), 전공 선택(사용자가 선택한 것만) 이름으로 조회하기 - 3가지 분야의 과목들을 가지고, 시간표가 성립 가능한 모든 경우의 수 생성(성립이 되는 경우가 하나도 없다면 오류 반환)
- Loading branch information
Showing
26 changed files
with
423 additions
and
22 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...gpt/domain/course/storage/CourseEntity.kt → ...ssu/soongpt/domain/course/CourseEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/yourssu/soongpt/domain/course/implement/Courses.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.yourssu.soongpt.domain.course.implement | ||
|
||
class Courses( | ||
val courses: List<Course>, | ||
) { | ||
fun isEmpty(): Boolean { | ||
return courses.isEmpty() | ||
} | ||
|
||
fun unpackNameAndProfessor(): List<Pair<String, String>> { | ||
return courses.map { it.courseName to it.professorName!! } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/com/yourssu/soongpt/domain/course/implement/CoursesFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.yourssu.soongpt.domain.course.implement | ||
|
||
import com.yourssu.soongpt.domain.course.implement.exception.InvalidTimetableRequestException | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class CoursesFactory { | ||
fun generateTimetableCandidates( | ||
coursesCandidates: List<Courses> | ||
): List<Courses> { | ||
return coursesCandidates.fold(listOf(emptyList<Course>())) { acc, courses -> | ||
acc.flatMap { currentCombination -> | ||
courses.courses.map { course -> currentCombination + course } | ||
} | ||
}.map { Courses(it) } | ||
} | ||
|
||
fun validateEmpty(timetableCandidates: List<Courses>) { | ||
if (timetableCandidates.isEmpty()) { | ||
throw InvalidTimetableRequestException() | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...n/kotlin/com/yourssu/soongpt/domain/course/implement/exception/CourseNotFoundException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.yourssu.soongpt.domain.course.implement.exception | ||
|
||
import com.yourssu.soongpt.common.handler.NotFoundException | ||
|
||
class CourseNotFoundException( | ||
val courseName: String = "", | ||
) : NotFoundException(message = "해당하는 과목이 없습니다. 과목 이름: {$courseName}") { | ||
} |
3 changes: 3 additions & 0 deletions
3
...n/kotlin/com/yourssu/soongpt/domain/course/implement/exception/InvalidCoursesException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.yourssu.soongpt.domain.course.implement.exception | ||
|
||
class InvalidCoursesException : RuntimeException() |
7 changes: 7 additions & 0 deletions
7
...com/yourssu/soongpt/domain/course/implement/exception/InvalidTimetableRequestException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "시간표가 나올 수 있는 경우의 수가 없습니다.") { | ||
|
||
} |
6 changes: 0 additions & 6 deletions
6
...ain/kotlin/com/yourssu/soongpt/domain/course/storage/exception/CourseNotFoundException.kt
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/yourssu/soongpt/domain/rating/application/dto/RatingCreatedRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.yourssu.soongpt.domain.rating.application.dto | ||
|
||
import com.yourssu.soongpt.domain.rating.business.RatingCreatedCommand | ||
|
||
data class RatingCreatedRequest( | ||
val course: String, | ||
val professor: String, | ||
val star: Double, | ||
val point: Double | ||
) { | ||
fun toCommand(): RatingCreatedCommand { | ||
return RatingCreatedCommand( | ||
course = course, | ||
professor = professor, | ||
star = star, | ||
point = point | ||
) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/yourssu/soongpt/domain/rating/business/RatingCreatedCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.yourssu.soongpt.domain.rating.business | ||
|
||
import com.yourssu.soongpt.domain.rating.implement.Rating | ||
|
||
class RatingCreatedCommand( | ||
val course: String, | ||
val professor: String, | ||
val star: Double, | ||
val point: Double, | ||
) { | ||
fun toRating(): Rating { | ||
return Rating( | ||
courseName = course, | ||
professorName = professor, | ||
star = star, | ||
point = point, | ||
) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/yourssu/soongpt/domain/rating/business/dto/RatingResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.yourssu.soongpt.domain.rating.business.dto | ||
|
||
import com.yourssu.soongpt.domain.rating.implement.Rating | ||
|
||
data class RatingResponse( | ||
val course: String, | ||
val professor: String, | ||
val star: Double, | ||
val point: Double, | ||
) { | ||
companion object { | ||
fun from(rating: Rating): RatingResponse { | ||
return RatingResponse( | ||
course = rating.courseName, | ||
professor = rating.professorName, | ||
star = rating.star, | ||
point = rating.point, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/yourssu/soongpt/domain/rating/implement/RatingReader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.yourssu.soongpt.domain.rating.implement | ||
|
||
import com.yourssu.soongpt.domain.course.implement.Courses | ||
import com.yourssu.soongpt.domain.rating.implement.exception.RatingNotFoundByCourseNameException | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class RatingReader( | ||
private val ratingRepository: RatingRepository, | ||
) { | ||
fun findAllBy(courses: Courses): List<Rating> { | ||
return courses.unpackNameAndProfessor().mapNotNull { (courseName, professorName) -> | ||
ratingRepository.findByCourseNameAndProfessorName(courseName, professorName) | ||
} | ||
} | ||
|
||
|
||
fun findBy(courseName: String, professorName: String): Rating { | ||
return ratingRepository.findByCourseNameAndProfessorName(courseName, professorName) | ||
?: throw RatingNotFoundByCourseNameException() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
src/main/kotlin/com/yourssu/soongpt/domain/timetable/application/TimetableController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...in/kotlin/com/yourssu/soongpt/domain/timetable/application/dto/TimetableCreatedRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.yourssu.soongpt.domain.timetable.application.dto | ||
|
||
import com.yourssu.soongpt.domain.timetable.business.dto.TimetableCreatedCommand | ||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.NotNull | ||
import org.hibernate.validator.constraints.Range | ||
|
||
data class TimetableCreatedRequest( | ||
@field:Range(min = 15, max = 25, message = "학번은 15부터 25까지 가능합니다.") | ||
val schoolId: Int, | ||
|
||
@field:NotBlank(message = "학과는 필수 입력값입니다.") | ||
val department: String, | ||
|
||
@field:Range(min = 1, max = 5, message = "학년은 1부터 5까지 가능합니다.") | ||
val grade: Int, | ||
|
||
val isChapel: Boolean = false, | ||
|
||
@field:NotNull | ||
val majorRequiredCourses: List<String>, | ||
|
||
@field:NotNull | ||
val majorElectiveCourses: List<String>, | ||
|
||
@field:NotNull | ||
val generalRequiredCourses: List<String>, | ||
) { | ||
fun toCommand(): TimetableCreatedCommand { | ||
return TimetableCreatedCommand( | ||
departmentName = department, | ||
grade = grade, | ||
isChapel = isChapel, | ||
majorRequiredCourses = majorRequiredCourses, | ||
majorElectiveCourses = majorElectiveCourses, | ||
generalRequiredCourses = generalRequiredCourses, | ||
) | ||
} | ||
} |
Oops, something went wrong.