-
Notifications
You must be signed in to change notification settings - Fork 1
134 feat: 복수 전공, 편입생 예외 처리 추가 #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e473e34
6667d24
2ffa569
570b80d
5737698
53fa6ea
1825451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,16 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package com.chukchuk.haksa.domain.graduation.service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.domain.department.model.Department; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.domain.graduation.dto.AreaProgressDto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.domain.graduation.dto.GraduationProgressResponse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.domain.graduation.repository.GraduationQueryRepository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.domain.student.model.Student; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.domain.student.service.StudentService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.global.exception.code.ErrorCode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.global.exception.type.CommonException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.chukchuk.haksa.infrastructure.redis.RedisCacheStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import lombok.extern.slf4j.Slf4j; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.slf4j.MDC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.transaction.annotation.Transactional; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -45,25 +47,18 @@ public GraduationProgressResponse getGraduationProgress(UUID studentId) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Student student = studentService.getStudentById(studentId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Department dept = student.getDepartment(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 전공 코드가 없는 학과도 있으므로 majorId가 없으면 departmentId를 사용 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long primaryMajorId = student.getMajor() != null ? student.getMajor().getId() : dept.getId(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| validateTransferStudent(student); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long primaryMajorId = resolvePrimaryMajorId(student); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int admissionYear = student.getAcademicInfo().getAdmissionYear(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<AreaProgressDto> areaProgress = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (student.getSecondaryMajor() != null) { // 복수전공 존재 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long secondaryMajorId = student.getSecondaryMajor().getId(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| areaProgress = graduationQueryRepository.getDualMajorAreaProgress(studentId, primaryMajorId, secondaryMajorId, admissionYear); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 졸업 요건 충족 여부 조회 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| areaProgress = graduationQueryRepository.getStudentAreaProgress(studentId, primaryMajorId, admissionYear); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<AreaProgressDto> areaProgress = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resolveAreaProgress(student, studentId, primaryMajorId, admissionYear); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GraduationProgressResponse response = new GraduationProgressResponse(areaProgress); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isDifferentGradRequirement(primaryMajorId, admissionYear)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| response.setHasDifferentGraduationRequirement(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.info("[BIZ] graduation.progress.flag.set studentId={} deptId={} year={}", studentId, primaryMajorId, admissionYear); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -75,7 +70,110 @@ public GraduationProgressResponse getGraduationProgress(UUID studentId) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 편입생인 경우 예외 처리, TODO: 편입생 졸업 요건 추가 후 삭제 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void validateTransferStudent(Student student) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (student.isTransferStudent()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new CommonException(ErrorCode.TRANSFER_STUDENT_UNSUPPORTED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private Long resolvePrimaryMajorId(Student student) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return student.getMajor() != null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? student.getMajor().getId() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : student.getDepartment().getId(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private boolean isDifferentGradRequirement(Long departmentId, int admissionYear) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return admissionYear == SPECIAL_YEAR && departmentId != null && SPECIAL_DEPTS.contains(departmentId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private List<AreaProgressDto> resolveAreaProgress( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Student student, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UUID studentId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long primaryMajorId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (student.getSecondaryMajor() != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return getDualMajorProgressOrThrow( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| student, studentId, primaryMajorId, admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return getSingleMajorProgressOrThrow( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| student, studentId, primaryMajorId, admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 단일 전공 처리 메서드 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private List<AreaProgressDto> getSingleMajorProgressOrThrow( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Student student, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UUID studentId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long departmentId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<AreaProgressDto> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| graduationQueryRepository.getStudentAreaProgress( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| studentId, departmentId, admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (result.isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throwGraduationRequirementNotFound( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| student, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| departmentId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| admissionYear); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 복수 전공 처리 메서드 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private List<AreaProgressDto> getDualMajorProgressOrThrow( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Student student, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UUID studentId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long primaryMajorId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long secondaryMajorId = student.getSecondaryMajor().getId(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return graduationQueryRepository.getDualMajorAreaProgress( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| studentId, primaryMajorId, secondaryMajorId, admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (CommonException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ErrorCode.GRADUATION_REQUIREMENTS_DATA_NOT_FOUND.code().equals(e.getCode())) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throwGraduationRequirementNotFound( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| student, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| primaryMajorId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| secondaryMajorId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+138
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
코드의 명확성을 높이기 위해 아래는
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * 졸업 요건 부재 예외 처리 메서드 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * MDC 정리는 GlobalExceptionHandler에서 수행됨 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Javadoc 주석에 "MDC 정리는 GlobalExceptionHandler에서 수행됨"이라고 명시되어 있지만, 이번 변경으로 추가된
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void throwGraduationRequirementNotFound( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Student student, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long primaryMajorId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Long secondaryMajorId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int admissionYear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("student_code", student.getStudentCode()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("admission_year", String.valueOf(admissionYear)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("primary_department_id", String.valueOf(primaryMajorId)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (secondaryMajorId == null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("major_type", "SINGLE"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("secondary_department_id", "NONE"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("major_type", "DUAL"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MDC.put("secondary_department_id", String.valueOf(secondaryMajorId)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new CommonException(ErrorCode.GRADUATION_REQUIREMENTS_DATA_NOT_FOUND); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,20 @@ | |||||
|
|
||||||
| public enum ErrorCode { | ||||||
|
|
||||||
| // 공통(Common) | ||||||
| INVALID_ARGUMENT("C01", "잘못된 요청입니다.", HttpStatus.BAD_REQUEST), | ||||||
| NOT_FOUND("C05", "요청한 API를 찾을 수 없습니다.", HttpStatus.NOT_FOUND), | ||||||
|
|
||||||
| // 인증 및 세션 관련 | ||||||
| SESSION_EXPIRED("A04", "로그인 세션이 만료되었습니다.", HttpStatus.UNAUTHORIZED), | ||||||
| // 인증 및 세션 관련 | ||||||
| AUTHENTICATION_REQUIRED("A05", "인증이 필요한 요청입니다.", HttpStatus.UNAUTHORIZED), | ||||||
|
|
||||||
| // 서버 오류 관련 | ||||||
| SCRAPING_FAILED("C02", "포털 크롤링 중 오류가 발생했습니다.", HttpStatus.INTERNAL_SERVER_ERROR), | ||||||
| REFRESH_FAILED("C03", "포털 정보 재연동 중 오류가 발생했습니다.", HttpStatus.INTERNAL_SERVER_ERROR), | ||||||
| FORBIDDEN("C04", "접근 권한이 없습니다.", HttpStatus.FORBIDDEN), | ||||||
|
|
||||||
| // Token 관련 | ||||||
| TOKEN_INVALID_FORMAT("T01", "ID 토큰 형식이 올바르지 않습니다.", HttpStatus.UNAUTHORIZED), | ||||||
| TOKEN_NO_MATCHING_KEY("T02", "일치하는 공개키가 없습니다.", HttpStatus.UNAUTHORIZED), | ||||||
|
|
@@ -23,36 +37,27 @@ public enum ErrorCode { | |||||
| STUDENT_ACADEMIC_RECORD_NOT_FOUND("U02", "해당 학생의 학적 정보가 존재하지 않습니다.", HttpStatus.NOT_FOUND), | ||||||
| USER_ALREADY_CONNECTED("U03", "이미 포털과 연동된 사용자입니다.", HttpStatus.BAD_REQUEST), | ||||||
| USER_NOT_CONNECTED("U04", "아직 포털과 연동되지 않은 사용자입니다.", HttpStatus.BAD_REQUEST), | ||||||
|
|
||||||
| // Student 관련 | ||||||
| STUDENT_NOT_FOUND("S01", "해당 학생이 존재하지 않습니다.", HttpStatus.NOT_FOUND), | ||||||
| INVALID_TARGET_GPA("S02", "유효하지 않은 목표 학점입니다.", HttpStatus.BAD_REQUEST), | ||||||
| STUDENT_ID_REQUIRED("S03", "Student ID는 필수입니다.", HttpStatus.BAD_REQUEST), | ||||||
| TRANSFER_STUDENT_UNSUPPORTED("T13", "편입생 학적 정보는 현재 지원되지 않습니다.", HttpStatus.UNPROCESSABLE_ENTITY), | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제미나이 피드백처럼
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 그 피드백을 받고 S로 두는게 더 좋을것 같긴 한데, 클라이언트에서 처리한 다음이라서 마음대로 바꿨다가 문제 생길 것 같아서 우선 건드리지는 않았어요. |
||||||
|
|
||||||
| // 학업 관련 | ||||||
| SEMESTER_RECORD_NOT_FOUND("A01", "해당 학기의 성적 데이터를 찾을 수 없습니다.", HttpStatus.NOT_FOUND), | ||||||
| SEMESTER_RECORD_EMPTY("A02", "학기 성적 데이터를 찾을 수 없습니다.", HttpStatus.NOT_FOUND), | ||||||
| FRESHMAN_NO_SEMESTER("A03", "신입생은 학기 기록이 없습니다.", HttpStatus.BAD_REQUEST), | ||||||
| GRADUATION_REQUIREMENTS_NOT_FOUND("G01", "졸업 요건 정보를 찾을 수 없습니다.", HttpStatus.NOT_FOUND), | ||||||
| // 학업 관련 | ||||||
| INVALID_GRADE_TYPE("A06", "존재하지 않는 성적 등급입니다.", HttpStatus.BAD_REQUEST), | ||||||
|
|
||||||
| // 졸업 요건 관련 | ||||||
| GRADUATION_REQUIREMENTS_NOT_FOUND("G01", "졸업 요건 정보를 찾을 수 없습니다.", HttpStatus.NOT_FOUND), | ||||||
| GRADUATION_REQUIREMENTS_DATA_NOT_FOUND("G02", "사용자에게 맞는 졸업 요건 데이터가 존재하지 않습니다.", HttpStatus.NOT_FOUND), | ||||||
|
|
||||||
|
Comment on lines
+53
to
+56
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 요거 두 개가 의미적으로 어떤 차이가 있어? 똑같아보여서 의미 크게 다르지 않으면 합치는 게 낫지 않을까 싶어. 헷갈리는 거 같아
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기존에 사용하던게 G01인데, 혹시 몰라서 유지하긴 했어요 |
||||||
| // 포털 관련 | ||||||
| PORTAL_LOGIN_FAILED("P01", "아이디나 비밀번호가 일치하지 않습니다.\n학교 홈페이지에서 확인해주세요.", HttpStatus.UNAUTHORIZED), | ||||||
| PORTAL_SCRAPE_FAILED("P02", "포털 크롤링 실패", HttpStatus.INTERNAL_SERVER_ERROR), | ||||||
| PORTAL_ACCOUNT_LOCKED("P03", "계정이 잠겼습니다. 포털사이트로 돌아가서 학번/사번 찾기 및 비밀번호 재발급을 진행해주세요", HttpStatus.LOCKED), | ||||||
|
|
||||||
| // 공통(Common) | ||||||
| INVALID_ARGUMENT("C01", "잘못된 요청입니다.", HttpStatus.BAD_REQUEST), | ||||||
| NOT_FOUND("C05", "요청한 API를 찾을 수 없습니다.", HttpStatus.NOT_FOUND), | ||||||
|
|
||||||
| // 인증 및 세션 관련 | ||||||
| SESSION_EXPIRED("A04", "로그인 세션이 만료되었습니다.", HttpStatus.UNAUTHORIZED), | ||||||
| // 인증 및 세션 관련 | ||||||
| AUTHENTICATION_REQUIRED("A05", "인증이 필요한 요청입니다.", HttpStatus.UNAUTHORIZED), | ||||||
|
|
||||||
| // 서버 오류 관련 | ||||||
| SCRAPING_FAILED("C02", "포털 크롤링 중 오류가 발생했습니다.", HttpStatus.INTERNAL_SERVER_ERROR), | ||||||
| REFRESH_FAILED("C03", "포털 정보 재연동 중 오류가 발생했습니다.", HttpStatus.INTERNAL_SERVER_ERROR), | ||||||
| FORBIDDEN("C04", "접근 권한이 없습니다.", HttpStatus.FORBIDDEN); | ||||||
| PORTAL_ACCOUNT_LOCKED("P03", "계정이 잠겼습니다. 포털사이트로 돌아가서 학번/사번 찾기 및 비밀번호 재발급을 진행해주세요", HttpStatus.LOCKED); | ||||||
|
|
||||||
| private final String code; | ||||||
| private final String message; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.chukchuk.haksa.global.logging.filter; | ||
|
|
||
| import jakarta.servlet.FilterChain; | ||
| import jakarta.servlet.ServletException; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import org.slf4j.MDC; | ||
| import org.springframework.core.Ordered; | ||
| import org.springframework.core.annotation.Order; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.filter.OncePerRequestFilter; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| @Component | ||
| @Order(Ordered.LOWEST_PRECEDENCE) | ||
| public class MdcCleanupFilter extends OncePerRequestFilter { | ||
|
|
||
| @Override | ||
| protected void doFilterInternal( | ||
| HttpServletRequest request, | ||
| HttpServletResponse response, | ||
| FilterChain filterChain | ||
| ) throws ServletException, IOException { | ||
| try { | ||
| filterChain.doFilter(request, response); | ||
| } finally { | ||
| MDC.clear(); // 요청 종료 지점 | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 주전공이랑 복수전공이랑 예외 똑같이 놔두면 이슈에서 작성해준 '복수전공 정보 누락인 422 예외'는 못 던지는거 아니야? 여기서는 다른 상황이야?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이슈에 있는 복수전공 정보 누락 422 예외는 운영 서버에만 적용되는 사항입니다.
dev에는 복수전공에 대한 처리가 되어 있기 때문에, 졸업 요건 분석 로직에서
단일 전공, 복수 전공 각각의 경우로 예외 처리를 나누지 않고, 동일한 예외 처리를 한 후
졸업 요건 부재 예외 처리 메서드인
GraduationService.throwGraduationRequirementNotFound에서 단일/복수 전공 별 분기 처리를 통해 MDC 값을 다르게 주입하여 판별 가능하도록 했습니다.