From 1c256e910375d024a2a719aeaeaef9a5fc6d81f0 Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:31:51 +0900 Subject: [PATCH 1/9] =?UTF-8?q?fix=20:=20flyway=20116=EB=B2=88,=20117?= =?UTF-8?q?=EB=B2=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V116__add_catalog.sql | 2 +- .../db/migration/V117__add_detect_graduation_calculation.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/migration/V116__add_catalog.sql b/src/main/resources/db/migration/V116__add_catalog.sql index 82e64aa3d..7743b1205 100644 --- a/src/main/resources/db/migration/V116__add_catalog.sql +++ b/src/main/resources/db/migration/V116__add_catalog.sql @@ -11,5 +11,5 @@ CREATE TABLE if not exists `koin`.`catalog` FOREIGN KEY (`course_type_id`) REFERENCES `course_type` (`id`), FOREIGN KEY (`department_id`) REFERENCES `department` (`id`), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment '생성 일자', - updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '수정 일자', + updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '수정 일자' ); diff --git a/src/main/resources/db/migration/V117__add_detect_graduation_calculation.sql b/src/main/resources/db/migration/V117__add_detect_graduation_calculation.sql index 248909739..9a948393a 100644 --- a/src/main/resources/db/migration/V117__add_detect_graduation_calculation.sql +++ b/src/main/resources/db/migration/V117__add_detect_graduation_calculation.sql @@ -1,5 +1,5 @@ -- 졸업학점 계산 감지 테이블 -CREATE TABLE `detect_graduation_calculation` +CREATE TABLE if not exists `koin`.`detect_graduation_calculation` ( id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT comment '고유 id', user_id INT UNSIGNED NULL comment '유저 id', From 865f29953362800a483dbff20449fcee80d1d599 Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:33:58 +0900 Subject: [PATCH 2/9] =?UTF-8?q?feat=20:=20Repository=20=EC=A0=95=EB=A6=AC?= =?UTF-8?q?=20=EB=B0=8F=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graduation/repository/CatalogRepository.java | 10 +++++++++- .../graduation/repository/CourseTypeRepository.java | 5 +++++ .../DetectGraduationCalculationRepository.java | 4 ++-- .../timetableV2/repository/LectureRepositoryV2.java | 7 ++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/graduation/repository/CatalogRepository.java b/src/main/java/in/koreatech/koin/domain/graduation/repository/CatalogRepository.java index 53fa3bb52..af32f7beb 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/repository/CatalogRepository.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/repository/CatalogRepository.java @@ -13,10 +13,18 @@ public interface CatalogRepository extends Repository { Optional findByDepartmentAndCode(Department department, String code); + // 이거 오류나요.. + // List findByLectureNameAndYearAndDepartment(String lectureName, String studentYear, Department department); + + Optional> findAllByCourseTypeId(Integer courseTypeId); + default Catalog getByDepartmentAndCode(Department department, String code) { return findByDepartmentAndCode(department, code) .orElseThrow(() -> CatalogNotFoundException.withDetail("department: " + department + ", code: " + code)); } - List findByLectureNameAndYearAndDepartment(String lectureName, String studentYear, Department department); + default List getAllByCourseTypeId(Integer courseTypeId) { + return findAllByCourseTypeId(courseTypeId) + .orElseThrow(() -> CatalogNotFoundException.withDetail("course_type_id" + courseTypeId)); + } } diff --git a/src/main/java/in/koreatech/koin/domain/graduation/repository/CourseTypeRepository.java b/src/main/java/in/koreatech/koin/domain/graduation/repository/CourseTypeRepository.java index 9cfc7a369..9dbe48b1c 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/repository/CourseTypeRepository.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/repository/CourseTypeRepository.java @@ -19,4 +19,9 @@ default CourseType getCourseTypeById(Integer id) { return findById(id) .orElseThrow(() -> CourseTypeNotFoundException.withDetail("course_type_id: " + id)); } + + default CourseType getByName(String name) { + return findByName(name) + .orElseThrow(() -> CourseTypeNotFoundException.withDetail("course_type_name: " + name)); + } } diff --git a/src/main/java/in/koreatech/koin/domain/graduation/repository/DetectGraduationCalculationRepository.java b/src/main/java/in/koreatech/koin/domain/graduation/repository/DetectGraduationCalculationRepository.java index 538a72114..4fae8e833 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/repository/DetectGraduationCalculationRepository.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/repository/DetectGraduationCalculationRepository.java @@ -8,8 +8,8 @@ public interface DetectGraduationCalculationRepository extends Repository { - Optional findByUserId(Integer userId); - void save(DetectGraduationCalculation detectGraduationCalculation); + + Optional findByUserId(Integer userId); } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/repository/LectureRepositoryV2.java b/src/main/java/in/koreatech/koin/domain/timetableV2/repository/LectureRepositoryV2.java index 0bcf1fb76..817e7f8cc 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV2/repository/LectureRepositoryV2.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/repository/LectureRepositoryV2.java @@ -3,12 +3,13 @@ import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; import in.koreatech.koin.domain.timetable.exception.LectureNotFoundException; import in.koreatech.koin.domain.timetable.exception.SemesterNotFoundException; import in.koreatech.koin.domain.timetable.model.Lecture; -import in.koreatech.koin.domain.timetable.model.Semester; +import io.lettuce.core.dynamic.annotation.Param; public interface LectureRepositoryV2 extends Repository { @@ -20,6 +21,9 @@ public interface LectureRepositoryV2 extends Repository { Optional findBySemesterAndCodeAndLectureClass(String semesterDate, String code, String classLecture); + @Query("SELECT l FROM Lecture l WHERE l.code IN :codes AND l.semester = :semesterDate") + Optional> findAllByCodesAndSemester(@Param("codes") List codes, @Param("semesterDate") String semesterDate); + default Lecture getBySemesterAndCodeAndLectureClass(String semesterDate, String code, String classLecture) { return findBySemesterAndCodeAndLectureClass(semesterDate, code, classLecture) .orElseThrow(() -> SemesterNotFoundException.withDetail( @@ -30,4 +34,5 @@ default Lecture getLectureById(Integer id) { return findById(id) .orElseThrow(() -> LectureNotFoundException.withDetail("lecture_id: " + id)); } + } From b5629fce89c42c6fe33c17c8d949dcdbbac8ac8a Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:34:11 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat=20:=20Response=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/CourseTypeLectureResponse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java diff --git a/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java b/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java new file mode 100644 index 000000000..af10bee98 --- /dev/null +++ b/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java @@ -0,0 +1,18 @@ +package in.koreatech.koin.domain.graduation.dto; + +import java.util.List; + +import in.koreatech.koin.domain.timetable.model.Lecture; +import io.swagger.v3.oas.annotations.media.Schema; + +public record CourseTypeLectureResponse( + @Schema(description = "학기", example = "20192") + String semester, + + @Schema(description = "이수구분 충족강의") + List lectures +) { + public static CourseTypeLectureResponse of(String semester, List lectures) { + return new CourseTypeLectureResponse(semester, lectures); + } +} From fcfdee7d838950084c81c401fd7e41465bdcb742 Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:34:18 +0900 Subject: [PATCH 4/9] =?UTF-8?q?feat=20:=20exception=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...otFoundSemesterAndCourseTypeException.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/in/koreatech/koin/domain/timetableV2/exception/NotFoundSemesterAndCourseTypeException.java diff --git a/src/main/java/in/koreatech/koin/domain/timetableV2/exception/NotFoundSemesterAndCourseTypeException.java b/src/main/java/in/koreatech/koin/domain/timetableV2/exception/NotFoundSemesterAndCourseTypeException.java new file mode 100644 index 000000000..981f650c7 --- /dev/null +++ b/src/main/java/in/koreatech/koin/domain/timetableV2/exception/NotFoundSemesterAndCourseTypeException.java @@ -0,0 +1,19 @@ +package in.koreatech.koin.domain.timetableV2.exception; + +import in.koreatech.koin.global.exception.DataNotFoundException; + +public class NotFoundSemesterAndCourseTypeException extends DataNotFoundException { + private static final String DEFAULT_MESSAGE = "학기나 이수구분을 찾을 수 없습니다."; + + public NotFoundSemesterAndCourseTypeException(String message) { + super(message); + } + + public NotFoundSemesterAndCourseTypeException(String message, String detail) { + super(message, detail); + } + + public static NotFoundSemesterAndCourseTypeException withDetail(String detail) { + return new NotFoundSemesterAndCourseTypeException(DEFAULT_MESSAGE, detail); + } +} From 60afcd64ffa4551d1dace4b48f750ad5be0ab92c Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:34:34 +0900 Subject: [PATCH 5/9] =?UTF-8?q?chore=20:=20Repo=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/StudentCourseCalculationRepository.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/graduation/repository/StudentCourseCalculationRepository.java b/src/main/java/in/koreatech/koin/domain/graduation/repository/StudentCourseCalculationRepository.java index 875fbbf4f..353eda3b3 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/repository/StudentCourseCalculationRepository.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/repository/StudentCourseCalculationRepository.java @@ -8,13 +8,13 @@ public interface StudentCourseCalculationRepository extends Repository { - Optional findByUserId(Integer userId); - - void deleteAllByUserId(Integer userId); - void save(StudentCourseCalculation studentCourseCalculation); + Optional findByUserId(Integer userId); + StudentCourseCalculation findByUserIdAndStandardGraduationRequirementsId(Integer userId, Integer id); void delete(StudentCourseCalculation existingCalculation); + + void deleteAllByUserId(Integer userId); } From a0a2c828806007b35c513d0d2179cb7fc3f2385f Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:34:52 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat=20:=20Service=20=EB=B0=8F=20Controller?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graduation/controller/GraduationApi.java | 19 ++++++++++ .../controller/GraduationController.java | 18 ++++++++-- .../graduation/service/GraduationService.java | 35 ++++++++++++++++--- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java index 4d9068cac..9aa83a55f 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java @@ -3,10 +3,12 @@ import static in.koreatech.koin.domain.user.model.UserType.STUDENT; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; +import in.koreatech.koin.domain.graduation.dto.CourseTypeLectureResponse; import in.koreatech.koin.global.auth.Auth; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -49,4 +51,21 @@ ResponseEntity uploadStudentGradeExcelFile( @RequestParam(value = "file") MultipartFile file, @Auth(permit = {STUDENT}) Integer userId ); + + @ApiResponses( + value = { + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(hidden = true))) + } + ) + @Operation(summary = "학기에 따른 이수구분 강의 출력") + @SecurityRequirement(name = "Jwt Authentication") + @GetMapping("/graduation/course-type") + ResponseEntity getCourseTypeLecture( + @RequestParam(name = "semester") String semester, + @RequestParam(name = "name") String courseTypeName, + @Auth(permit = {STUDENT}) Integer userId + ); } diff --git a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java index ae552b4d4..ec41fcfc7 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java @@ -1,6 +1,7 @@ package in.koreatech.koin.domain.graduation.controller; import java.io.IOException; + import static in.koreatech.koin.domain.user.model.UserType.STUDENT; import org.springframework.http.ResponseEntity; @@ -10,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import in.koreatech.koin.domain.graduation.dto.GraduationCourseCalculationResponse; +import in.koreatech.koin.domain.graduation.dto.CourseTypeLectureResponse; import in.koreatech.koin.domain.graduation.service.GraduationService; import in.koreatech.koin.domain.user.model.UserType; import in.koreatech.koin.global.auth.Auth; @@ -24,8 +25,7 @@ public class GraduationController implements GraduationApi { @PostMapping("/graduation/agree") public ResponseEntity createStudentCourseCalculation( - @Auth(permit = {STUDENT}) Integer userId) - { + @Auth(permit = {STUDENT}) Integer userId) { graduationService.createStudentCourseCalculation(userId); return ResponseEntity.ok().build(); } @@ -43,10 +43,22 @@ public ResponseEntity uploadStudentGradeExcelFile( } } + @GetMapping("/graduation/course-type") + public ResponseEntity getCourseTypeLecture( + @RequestParam(name = "semester") String semester, + @RequestParam(name = "name") String courseTypeName, + @Auth(permit = {STUDENT}) Integer userId + ) { + CourseTypeLectureResponse response = graduationService.getLectureByCourseType(semester, courseTypeName); + return ResponseEntity.ok(response); + } + + /* @GetMapping("/graduation/course/calculation") public ResponseEntity getGraduationCourseCalculation( @Auth(permit = {STUDENT}) Integer userId) { GraduationCourseCalculationResponse response = graduationService.getGraduationCourseCalculationResponse(userId); return ResponseEntity.ok(response); } + */ } diff --git a/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java b/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java index a286b6dfd..fdd8dd3b0 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -16,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import in.koreatech.koin.domain.graduation.dto.CourseTypeLectureResponse; import in.koreatech.koin.domain.graduation.dto.GraduationCourseCalculationResponse; import in.koreatech.koin.domain.graduation.model.Catalog; import in.koreatech.koin.domain.graduation.model.DetectGraduationCalculation; @@ -30,7 +30,7 @@ import in.koreatech.koin.domain.student.model.Department; import in.koreatech.koin.domain.student.model.Student; import in.koreatech.koin.domain.student.repository.StudentRepository; -import in.koreatech.koin.domain.student.util.StudentUtil; +import in.koreatech.koin.domain.timetableV2.exception.NotFoundSemesterAndCourseTypeException; import in.koreatech.koin.domain.timetableV2.model.TimetableLecture; import in.koreatech.koin.domain.timetableV2.repository.TimetableFrameRepositoryV2; @@ -103,6 +103,7 @@ public void resetStudentCourseCalculation(Student student, Department newDepartm }); } + /* @Transactional public GraduationCourseCalculationResponse getGraduationCourseCalculationResponse(Integer userId) { DetectGraduationCalculation detectGraduationCalculation = detectGraduationCalculationRepository.findByUserId(userId) @@ -135,6 +136,7 @@ public GraduationCourseCalculationResponse getGraduationCourseCalculationRespons return GraduationCourseCalculationResponse.of(courseTypes); } + */ @Transactional public void readStudentGradeExcelFile(MultipartFile file, Integer userId) throws IOException { @@ -158,7 +160,7 @@ public void readStudentGradeExcelFile(MultipartFile file, Integer userId) throws } String semester = getKoinSemester(data.semester(), data.year()); - CourseType courseType = courseTypeRepository.findByName(data.courseType()).orElse(null); + CourseType courseType = mappingCourseType(data.courseType()); Lecture lecture = lectureRepositoryV2.findBySemesterAndCodeAndLectureClass(semester, data.code(), data.lectureClass()).orElse(null); @@ -229,8 +231,8 @@ private void checkFiletype(MultipartFile file) { private boolean skipRow(GradeExcelData gradeExcelData) { return gradeExcelData.classTitle().equals(MIDDLE_TOTAL) || - gradeExcelData.retakeStatus().equals(RETAKE) || - gradeExcelData.grade().equals(UNSATISFACTORY); + gradeExcelData.retakeStatus().equals(RETAKE) || + gradeExcelData.grade().equals(UNSATISFACTORY); } private String getKoinSemester(String semester, String year) { @@ -248,6 +250,16 @@ private void validateStudentField(Object field, String message) { } } + public CourseType mappingCourseType(String courseTypeName) { + if ("전필".equals(courseTypeName)) { + return courseTypeRepository.getByName("학과(전공)필수"); + } else if ("전선".equals(courseTypeName)) { + return courseTypeRepository.getByName("학과(전공)선택"); + } else { + return courseTypeRepository.findByName(courseTypeName).orElse(null); + } + } + private void initializeStudentCourseCalculation(Student student, Department department) { // 학번에 맞는 이수요건 정보 조회 List requirementsList = @@ -278,6 +290,7 @@ private Student getValidatedStudent(Integer userId) { return student; } + /* private List getCatalogListForStudent(Student student, String studentYear) { List timetableLectures = timetableFrameRepositoryV2.getAllByUserId(student.getId()).stream() .flatMap(frame -> frame.getTimetableLectures().stream()) @@ -297,6 +310,7 @@ private List getCatalogListForStudent(Student student, String studentYe }); return catalogList; } + */ private Map calculateCourseTypeCredits(List catalogList) { Map courseTypeCreditsMap = new HashMap<>(); @@ -361,4 +375,15 @@ private int updateStudentCourseCalculation(Integer userId, Student student, return completedGrades; } + + public CourseTypeLectureResponse getLectureByCourseType(String semester, String courseTypeName) { + CourseType courseType = courseTypeRepository.getByName(courseTypeName); + List catalogs = catalogRepository.getAllByCourseTypeId(courseType.getId()); + List codes = catalogs.stream().map(Catalog::getCode).toList(); + + List lectures = lectureRepositoryV2.findAllByCodesAndSemester(codes, semester) + .orElseThrow(() -> new NotFoundSemesterAndCourseTypeException("학기나 이수구분을 찾을 수 없습니다.")); + + return CourseTypeLectureResponse.of(semester, lectures); + } } From b0c7144f40909a8af5fb1c014b301aae59295227 Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:35:09 +0900 Subject: [PATCH 7/9] =?UTF-8?q?feat=20:=20graduation=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/global/config/swagger/SwaggerGroupConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/in/koreatech/koin/global/config/swagger/SwaggerGroupConfig.java b/src/main/java/in/koreatech/koin/global/config/swagger/SwaggerGroupConfig.java index 117d18626..87ad2ed55 100644 --- a/src/main/java/in/koreatech/koin/global/config/swagger/SwaggerGroupConfig.java +++ b/src/main/java/in/koreatech/koin/global/config/swagger/SwaggerGroupConfig.java @@ -61,7 +61,8 @@ public GroupedOpenApi userApi() { "in.koreatech.koin.domain.student", "in.koreatech.koin.domain.timetable", "in.koreatech.koin.domain.timetableV2", - "in.koreatech.koin.domain.timetableV3" + "in.koreatech.koin.domain.timetableV3", + "in.koreatech.koin.domain.graduation" }; return createGroupedOpenApi("4. User API", packagesPath); From 41d3a942c725baed8bf23493dd69164003dfc0ad Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Mon, 20 Jan 2025 20:12:51 +0900 Subject: [PATCH 8/9] =?UTF-8?q?feat=20:=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graduation/controller/GraduationApi.java | 3 ++- .../controller/GraduationController.java | 5 +++-- .../dto/CourseTypeLectureResponse.java | 7 ++++-- .../dto/LecturePortionResponse.java | 22 +++++++++++++++++++ .../graduation/service/GraduationService.java | 11 +++++++++- 5 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java diff --git a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java index 9aa83a55f..9adb2406d 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationApi.java @@ -64,7 +64,8 @@ ResponseEntity uploadStudentGradeExcelFile( @SecurityRequirement(name = "Jwt Authentication") @GetMapping("/graduation/course-type") ResponseEntity getCourseTypeLecture( - @RequestParam(name = "semester") String semester, + @RequestParam(name = "year") Integer year, + @RequestParam(name = "term") String term, @RequestParam(name = "name") String courseTypeName, @Auth(permit = {STUDENT}) Integer userId ); diff --git a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java index ec41fcfc7..de485f9f7 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/controller/GraduationController.java @@ -45,11 +45,12 @@ public ResponseEntity uploadStudentGradeExcelFile( @GetMapping("/graduation/course-type") public ResponseEntity getCourseTypeLecture( - @RequestParam(name = "semester") String semester, + @RequestParam(name = "year") Integer year, + @RequestParam(name = "term") String term, @RequestParam(name = "name") String courseTypeName, @Auth(permit = {STUDENT}) Integer userId ) { - CourseTypeLectureResponse response = graduationService.getLectureByCourseType(semester, courseTypeName); + CourseTypeLectureResponse response = graduationService.getLectureByCourseType(year, term, courseTypeName); return ResponseEntity.ok(response); } diff --git a/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java b/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java index af10bee98..835c21d5d 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/dto/CourseTypeLectureResponse.java @@ -10,9 +10,12 @@ public record CourseTypeLectureResponse( String semester, @Schema(description = "이수구분 충족강의") - List lectures + List lectures ) { public static CourseTypeLectureResponse of(String semester, List lectures) { - return new CourseTypeLectureResponse(semester, lectures); + List lectureList = lectures.stream() + .map(LecturePortionResponse::from) + .toList(); + return new CourseTypeLectureResponse(semester, lectureList); } } diff --git a/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java b/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java new file mode 100644 index 000000000..20ed11e30 --- /dev/null +++ b/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java @@ -0,0 +1,22 @@ +package in.koreatech.koin.domain.graduation.dto; + +import in.koreatech.koin.domain.timetable.model.Lecture; + +public record LecturePortionResponse + ( + Integer id, + String code, + String name, + String grades, + String department + ) { + public static LecturePortionResponse from(Lecture lecture) { + return new LecturePortionResponse( + lecture.getId(), + lecture.getCode(), + lecture.getName(), + lecture.getGrades(), + lecture.getDepartment() + ); + } +} diff --git a/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java b/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java index fdd8dd3b0..0f8e227df 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/service/GraduationService.java @@ -45,6 +45,9 @@ import in.koreatech.koin.domain.timetableV2.repository.LectureRepositoryV2; import in.koreatech.koin.domain.timetableV2.repository.SemesterRepositoryV2; import in.koreatech.koin.domain.timetableV2.repository.TimetableLectureRepositoryV2; +import in.koreatech.koin.domain.timetableV3.model.Term; +import in.koreatech.koin.domain.timetableV3.repository.SemesterRepositoryV3; +import in.koreatech.koin.domain.timetableV3.service.SemesterServiceV3; import in.koreatech.koin.domain.user.model.User; import in.koreatech.koin.domain.user.repository.UserRepository; import lombok.RequiredArgsConstructor; @@ -64,12 +67,14 @@ public class GraduationService { private final SemesterRepositoryV2 semesterRepositoryV2; private final LectureRepositoryV2 lectureRepositoryV2; private final TimetableLectureRepositoryV2 timetableLectureRepositoryV2; + private final SemesterRepositoryV3 semesterRepositoryV3; private final CatalogRepository catalogRepository; private static final String MIDDLE_TOTAL = "소 계"; private static final String TOTAL = "합 계"; private static final String RETAKE = "Y"; private static final String UNSATISFACTORY = "U"; + private final SemesterServiceV3 semesterServiceV3; @Transactional public void createStudentCourseCalculation(Integer userId) { @@ -376,11 +381,15 @@ private int updateStudentCourseCalculation(Integer userId, Student student, return completedGrades; } - public CourseTypeLectureResponse getLectureByCourseType(String semester, String courseTypeName) { + public CourseTypeLectureResponse getLectureByCourseType(Integer year, String term, String courseTypeName) { CourseType courseType = courseTypeRepository.getByName(courseTypeName); List catalogs = catalogRepository.getAllByCourseTypeId(courseType.getId()); List codes = catalogs.stream().map(Catalog::getCode).toList(); + Term parsedTerm = Term.fromDescription(term); + Semester foundSemester = semesterRepositoryV3.getByYearAndTerm(year, parsedTerm); + String semester = foundSemester.getSemester(); + List lectures = lectureRepositoryV2.findAllByCodesAndSemester(codes, semester) .orElseThrow(() -> new NotFoundSemesterAndCourseTypeException("학기나 이수구분을 찾을 수 없습니다.")); From 6cc3417631c40ed1aab11243a81dc6fa75c2b780 Mon Sep 17 00:00:00 2001 From: duehee <149302959+duehee@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:18:44 +0900 Subject: [PATCH 9/9] =?UTF-8?q?chore=20:=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/LecturePortionResponse.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java b/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java index 20ed11e30..c46b7e600 100644 --- a/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java +++ b/src/main/java/in/koreatech/koin/domain/graduation/dto/LecturePortionResponse.java @@ -1,15 +1,24 @@ package in.koreatech.koin.domain.graduation.dto; import in.koreatech.koin.domain.timetable.model.Lecture; +import io.swagger.v3.oas.annotations.media.Schema; -public record LecturePortionResponse - ( - Integer id, - String code, - String name, - String grades, - String department - ) { +public record LecturePortionResponse( + @Schema(description = "강의 ID", example = "1") + Integer id, + + @Schema(description = "강의 코드", example = "ABC123") + String code, + + @Schema(description = "강의 이름", example = "컴퓨터구조") + String name, + + @Schema(description = "학점", example = "3") + String grades, + + @Schema(description = "학과", example = "컴퓨터공학부") + String department +) { public static LecturePortionResponse from(Lecture lecture) { return new LecturePortionResponse( lecture.getId(),