-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: MajorGraduationCategory -> MajorType 변경 * feat: User도메인 MajorType 별 전공과목 반환 메서드 구현 * feat: GraduationRequirement도메인 MajorType별 졸업요견 반환 메서드 구현 * feat: GraduationCategory 도메인 전공필수, 선택 확인하는 메서드 추가 * refactor: 학문기초교양 졸업 계산 Service 리팩토링 * refactor: 전공 졸업 계산 Service 리팩토링 * refactor: UseCaseResolver 삭제 및 하위 메서드 통합 * refactor: CalculateGraduationService 책임 분리 리팩토링 * refactor: CalculateDetailGraduationUsecase 인터페이스 수정 * test: 리팩토링 이후 테스트코드 작성 * refactor: 리팩토링 이후 불필요한 클래스 삭제 * test: 리팩토링 이후 테스트 코드 수정 * fix: DetailCategoryResult categoryName 필드 기본할당 문제 수정 * refactor: code smell 수정 * refactor: code smell 수정 * refactor: 수강 과목 동기화 메서드 네이밍 수정 * refactor: 코드 포맷 수정 * refactor: 코드 오류 수정 --------- Co-authored-by: 5uhwann <[email protected]>
- Loading branch information
Showing
74 changed files
with
1,043 additions
and
1,462 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...tebe/graduation/application/service/CalculateBasicAcademicalCultureGraduationService.java
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,102 @@ | ||
package com.plzgraduate.myongjigraduatebe.graduation.application.service; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.DUAL_BASIC_ACADEMICAL_CULTURE; | ||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.PRIMARY_BASIC_ACADEMICAL_CULTURE; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.plzgraduate.myongjigraduatebe.core.meta.UseCase; | ||
import com.plzgraduate.myongjigraduatebe.graduation.application.usecase.CalculateDetailGraduationUseCase; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailGraduationResult; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationRequirement; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.MajorType; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.GraduationManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture.BasicAcademicalGraduationManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture.DefaultBasicAcademicalGraduationManager; | ||
import com.plzgraduate.myongjigraduatebe.lecture.application.port.FindBasicAcademicalCulturePort; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.BasicAcademicalCultureLecture; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; | ||
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.User; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class CalculateBasicAcademicalCultureGraduationService implements CalculateDetailGraduationUseCase { | ||
|
||
private final FindBasicAcademicalCulturePort findBasicAcademicalCulturePort; | ||
private final List<BasicAcademicalGraduationManager> basicAcademicalGraduationManagers; | ||
|
||
@Override | ||
public boolean supports(GraduationCategory graduationCategory) { | ||
return graduationCategory == PRIMARY_BASIC_ACADEMICAL_CULTURE | ||
|| graduationCategory == DUAL_BASIC_ACADEMICAL_CULTURE; | ||
} | ||
|
||
@Override | ||
public DetailGraduationResult calculateSingleDetailGraduation(User user, GraduationCategory graduationCategory, | ||
TakenLectureInventory takenLectureInventory, GraduationRequirement graduationRequirement) { | ||
MajorType majorType = MajorType.from(graduationCategory); | ||
String userMajor = user.getMajorByMajorType(majorType); | ||
Set<BasicAcademicalCultureLecture> graduationBasicAcademicalCultureLectures = | ||
findBasicAcademicalCulturePort.findBasicAcademicalCulture(userMajor); | ||
GraduationManager<BasicAcademicalCultureLecture> basicAcademicalCultureGraduationManager = | ||
determineBasicAcademicalCultureGraduationManager(userMajor); | ||
DetailGraduationResult detailGraduationResult = basicAcademicalCultureGraduationManager.createDetailGraduationResult( | ||
user, takenLectureInventory, graduationBasicAcademicalCultureLectures, | ||
graduationRequirement.getBasicCreditByMajorType(majorType)); | ||
detailGraduationResult.assignGraduationCategory(graduationCategory); | ||
return detailGraduationResult; | ||
} | ||
|
||
public List<DetailGraduationResult> calculateAllDetailGraduation(User user, | ||
TakenLectureInventory takenLectureInventory, GraduationRequirement graduationRequirement) { | ||
if (user.getStudentCategory() == StudentCategory.DUAL_MAJOR) { | ||
TakenLectureInventory copiedTakenLectureForPrimaryBasicAcademicalCulture = takenLectureInventory.copy(); | ||
TakenLectureInventory copiedTakenLectureForDualBasicAcademicalCulture = takenLectureInventory.copy(); | ||
DetailGraduationResult primaryBasicAcademicalCultureDetailGraduationResult = calculateSingleDetailGraduation( | ||
user, PRIMARY_BASIC_ACADEMICAL_CULTURE, copiedTakenLectureForPrimaryBasicAcademicalCulture, | ||
graduationRequirement); | ||
DetailGraduationResult dualBasicAcademicalCultureDetailGraduationResult = calculateSingleDetailGraduation( | ||
user, DUAL_BASIC_ACADEMICAL_CULTURE, copiedTakenLectureForDualBasicAcademicalCulture, | ||
graduationRequirement); | ||
syncOriginalTakenLectureInventory(takenLectureInventory, | ||
primaryBasicAcademicalCultureDetailGraduationResult, dualBasicAcademicalCultureDetailGraduationResult); | ||
return List.of(primaryBasicAcademicalCultureDetailGraduationResult, | ||
dualBasicAcademicalCultureDetailGraduationResult); | ||
} | ||
DetailGraduationResult primaryBasicAcademicalCultureGraduationResult = calculateSingleDetailGraduation( | ||
user, PRIMARY_BASIC_ACADEMICAL_CULTURE, takenLectureInventory, graduationRequirement); | ||
return List.of(primaryBasicAcademicalCultureGraduationResult); | ||
} | ||
|
||
private GraduationManager<BasicAcademicalCultureLecture> determineBasicAcademicalCultureGraduationManager( | ||
String userMajor) { | ||
return basicAcademicalGraduationManagers.stream() | ||
.filter(basicAcademicalManager -> basicAcademicalManager.isSatisfied(userMajor)) | ||
.findFirst() | ||
.orElse(new DefaultBasicAcademicalGraduationManager()); | ||
} | ||
|
||
private void syncOriginalTakenLectureInventory(TakenLectureInventory originalTakenLectureInventory, | ||
DetailGraduationResult primaryBasicAcademicalCultureDetailGraduationResult, | ||
DetailGraduationResult dualBasicAcademicalCultureDetailGraduationResult) { | ||
List<Lecture> primaryBasicAcademicalCultureTakenLectures = | ||
primaryBasicAcademicalCultureDetailGraduationResult.getDetailCategory().get(0).getTakenLectures(); | ||
List<Lecture> dualBasicAcademicalCultureTakenLectures = | ||
dualBasicAcademicalCultureDetailGraduationResult.getDetailCategory().get(0).getTakenLectures(); | ||
|
||
Set<Lecture> basicAcademicalCultureTakenLectures = new HashSet<>(); | ||
basicAcademicalCultureTakenLectures.addAll(primaryBasicAcademicalCultureTakenLectures); | ||
basicAcademicalCultureTakenLectures.addAll(dualBasicAcademicalCultureTakenLectures); | ||
originalTakenLectureInventory.sync(basicAcademicalCultureTakenLectures); | ||
} | ||
} |
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
65 changes: 0 additions & 65 deletions
65
...ation/application/service/CalculateDualBasicAcademicalCultureDetailGraduationService.java
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
...ebe/graduation/application/service/CalculateDualElectiveMajorDetailGraduationService.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.