-
Notifications
You must be signed in to change notification settings - Fork 0
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
[REFACTOR] Service 계층 책임 분리 및 Validator 구현 #162
Conversation
- 점수 계산을 전담하는 ScoreCalculator 클래스 추가 - 평균 점수를 계산하는 calculateAverageScore 메서드 생성 - 최고/최저 점수를 계산하는 calculateStatistics 메서드 생성 - GradingService에 평균 점수 계산 및 최고/최저 점수 계산 부분을 ScoreCalculator 클래스를 통해 처리 - ExamResultService에서 평균 점수 계산을 ScoreCalculator 클래스를 통해 처리
- 누락된 행의 컨벤션 적용
- 병합 중 발생한 충돌 해결
- 점수 계산을 담당하는 util 서비스 ScoreCalculator 생성 - Service 계층의 메서드 내 점수 계산 로직을 ScoreCalculator로 위임
- 점수 계산을 담당하는 util 서비스 ScoreCalculator 생성 - Service 계층의 메서드 내 점수 계산 로직을 ScoreCalculator로 위임
- 강의 및 커리큘럼의 수정 메서드 구현 - 강의 상세정보 조회를 위한 DTO 클래스 추가 - AdminCourseService에서 강의 수정 관련 비즈니스 로직 구현 (이미지, 커리큘럼 포함) - Repository 계층에 필요한 쿼리 메서드 구현 - API 엔드포인트 구현 및 코드 정리
- 공지사항 init data 추가
- ExamService에서 시험 CRUD 관련 로직 전담하도록 로직 수정 - ExamStatusService에서 시험 상태 변경 로직 전담하도록 수정 - 조회 로직은 ExamService로 위임 - ExamResultService에서 시험 결과 조회 로직 전담하도록 수정 - ExamSubmissionService에서 시험 답안 제출 로직 전담하도록 수정 - 상태 변경 로직은 ExamStatusService로 위임
- GradingService에서 채점 관련 로직만 전담하도록 수정 - calculateAverageScore 및 calculateScoreStatistics 메서드를 ScoreCalculator에서 처리하도록 변경
- ExamStatistics 클래스에 생성자가 없어 발생한 오류를 해결하기 위해 생성자 추가
- ExamSubmissionController에서 중복된 엔드포인트 getStudentExamResult 삭제 - GradingController 및 ExamSubmissionController에서 Service 책임 분리에 따라 호출 클래스 수정
- 순환 참조 문제를 해결하기 위해 findExpiredExams 메서드를 ExamStatusService로 이동 - 서비스 간 의존성을 줄이고 역할을 명확히 분리
- ExamService가 시험 생성, 수정, 삭제 등 CRUD 작업만 담당하도록 역할을 제한 - ExamQuestionService가 시험 문제 관련 작업을 전담하도록 수정 - ExamResultService는 시험 결과 조회 및 통계 작업만 전담하도록 수정 - ExamStatusService는 시험 상태 변경 및 상태 관리 기능으로 역할을 한정 - ExamSubmissionService는 시험 응시 및 제출 처리만 담당하도록 수정 - GradingService → ExamGradingService로 이름 변경을 통해 시험 관련 채점 기능임을 명확히 표현 - AutoGradingScheduler → ExamScheduler 이름 변경으로 시험 스케줄링의 의도를 더 직관적으로 표현
- ExamBaseValidator로 공통 유효성 검사 진행 - ExamQuestionValidator로 문제 관련 유효성 검사 진행 - ExamGradingValidator로 채점 관련 유효성 검사 진행 - ExamStatusValidator로 시험 상태 관련 유효성 검사 - ExamSubmissionValidator로 제출 관련 검증 진행 - ExamTimeValidator로 시험 기간 및 시간 검증 진행
- checkInstructorAccess로 진행하던 권한 검증을 isInstructor로 변경 - 변경된 검증 로직을 통해 정상적인 로직 수행
- 중복된 ErrorCode를 제거하고 코드 일관성 유지 - 각 ErrorCode를 해당 카테고리에 맞게 재분류 및 수정
- 예외 처리를 세분화하여 개별 Exception 클래스로 분리 - ExamAccessDeniedException 접근 권한 예외처리 - ExamNotFoundException 시험 검증 예외 처리 - ExamPeriodException 시험 기간 예외 처리 - ExamStatusException 시험 상태 예외 처리 - InvalidScoreException 시험 점수 예외 처리
- GradingController를 ExamGradingController로 클래스명 변경 - GradingException을 ExamGradingExceprion으로 클래스명 변경 - GradingNotPossibleException을 ExamGradingNotPossibleException으로 클래스명 변경
- ExamQuestion 클래스에 코드 formatting 적용 - ScoreCalculator 클래스에 코드 formatting 적용
- CourseRepository의 사용자 권한 검증을 email에서 id로 변경 - ExamQuestionRepository에 시험 문제의 응시 및 제출 여부를 확인하는 hasSubmissions 로직 추가 - 시험 조회 시, 사용자 email을 통한 검증을 id로 변경 - ExamResultRepository에서 사용자 email을 통한 조회를 id로 변경
- 시험 결과 확인 엔드포인트를 ExamSubmissionController에서 ExamResultController로 이동
- isInstructor, isStudent에서 기존에 사용 중이던 checkInstructorAccess와 checkStudentAccess로 재변경
- CourseAccessValidator에 역할별 이메일 검증 메서드 추가
…ller 변경 - CourseAccessValidator에 역할별 이메일 검증 메서드 추가 - Service에서 파라미터를 instructorEmail에서 instructorId로 변경 - Controller에서 email 예외처리 추가 및 사용자 email을 id로 변환하는 로직 추가
- CourseSecurityChecker에 사용자 email을 id로 변환하여 검증하는 로직 추가 - SubmissionController에 권한 검증 validator 추가 - InvalidScoreException 중복 클래스 삭제
- 병합 중 발생한 충돌 해결
- 병합 중 발생한 충돌 해결
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.
계산 클래스들을 따로 만들어 계산 로직을 구현하고,
유효성 검사와 예외 처리 클래스를 각각 만들어 분리하고,
조회할 때 email이 아니라 id로 조회하도록 변경하셨군요.
복잡한 시험 로직에서 많은 분량의 코드 리팩토링 정말 고생하셨습니다..!!
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.
복잡하고 어려운 작업 마무리하시느라 고생 많으셨습니다.
몇 가지 수정하면 좋을 부분 코멘트 및 대면으로 말씀 드렸으니 참고 부탁드려요!
추후 웹소켓 연결도 응원할게요!! 화이팅!!
/** | ||
* 채점 예외 | ||
*/ | ||
public class ExamGradingException extends RuntimeException { |
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.
BusinessBaseException을 상속받는 것이 좋아보입니다!
…alidator 사용 - CourseAccessValidator 내 검증 로직 최적화 - ExamSubmissionController의 검증 로직을 Validator 클래스를 사용하여 개선
관련 이슈
변경 사항
ScoreCalculator
로 이동하여 Service 계층의 책임 분리calculateAverageScore
에서 평균 점수 계산calculateStatistics
에서 최고/최저 점수 계산체크리스트
공유사항
추후 업무