-
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.
[DEV-9] 복수전공 졸업 계산 로직 및 조회 API 작성 (#266)
* feat: GraduationRequirement - 복수전공생 학점 조정 구현 * refactor: 오타 수정 * refactor: 복수전공 졸업 카테고리 분리 및 UseCase 분리 * refactor: MajorManager - 전공 구분 필드 및 지정 로직 추가 * feat: 복수전공필수 졸업계산 로직 구현 및 전체 졸업 계산 로직 시 복수전공 졸업 계산 로직 추가 * feat: 복수전공선택 졸업계산 로직 구현 * refactor: DetailCategoryResult - 상세 카테고리 명 지정 로직 추가 * feat: 복수학문기초교양 졸업 계산 로직 구현 * refactor: 파라미터 순서 오류 수정 * refactor: MajorExceptionHandler - 현재 계산중인 MajorGraduationCategory 지정 로직 추가 및 OptionalMandatory 생성 로직 수정 * refactor: UserMapper - 누락 필드 추가 * refactor: GraduationResult - totalCredit 총점 계산 로직 수정 * refactor: 경영학과 OptionalMandatory 수정(2024-1) * refactor: totalCredit - 채플 중복학점 누적 로직 제거 * refactor: CompletedCredit 응답 시 totalCredit이 0일 경우 응답X 로직 추가 * refactor:FindBasicAcademicalCulturePort - 복수전공 졸업과목 조회 메서드 파라미터 수정
- Loading branch information
Showing
43 changed files
with
813 additions
and
201 deletions.
There are no files selected for viewing
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: 65 additions & 0 deletions
65
...ation/application/service/CalculateDualBasicAcademicalCultureDetailGraduationService.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,65 @@ | ||
package com.plzgraduate.myongjigraduatebe.graduation.application.service; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.DUAL_BASIC_ACADEMICAL_CULTURE; | ||
|
||
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.CalculateDualBasicAcademicalCultureDetailGraduationUseCase; | ||
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.service.GraduationManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture.BasicAcademicalManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture.BusinessBasicAcademicalManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture.DefaultBasicAcademicalManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture.SocialScienceBasicAcademicManager; | ||
import com.plzgraduate.myongjigraduatebe.lecture.application.port.FindBasicAcademicalCulturePort; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.BasicAcademicalCultureLecture; | ||
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.User; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class CalculateDualBasicAcademicalCultureDetailGraduationService implements | ||
CalculateDualBasicAcademicalCultureDetailGraduationUseCase { | ||
|
||
private final FindBasicAcademicalCulturePort findBasicAcademicalCulturePort; | ||
|
||
@Override | ||
public boolean supports(GraduationCategory graduationCategory) { | ||
return graduationCategory == DUAL_BASIC_ACADEMICAL_CULTURE; | ||
} | ||
|
||
@Override | ||
public DetailGraduationResult calculateDetailGraduation(User user, TakenLectureInventory takenLectureInventory, | ||
GraduationRequirement graduationRequirement) { | ||
Set<BasicAcademicalCultureLecture> graduationBasicAcademicalCultureLectures = findBasicAcademicalCulturePort.findBasicAcademicalCulture( | ||
user.getDualMajor()); | ||
GraduationManager<BasicAcademicalCultureLecture> basicAcademicalCultureGraduationManager = determineBasicAcademicalCultureGraduationManager( | ||
user); | ||
DetailGraduationResult detailGraduationResult = basicAcademicalCultureGraduationManager.createDetailGraduationResult( | ||
user, takenLectureInventory, graduationBasicAcademicalCultureLectures, | ||
graduationRequirement.getDualBasicAcademicalCultureCredit()); | ||
detailGraduationResult.assignGraduationCategory(DUAL_BASIC_ACADEMICAL_CULTURE); | ||
return detailGraduationResult; | ||
} | ||
|
||
private GraduationManager<BasicAcademicalCultureLecture> determineBasicAcademicalCultureGraduationManager( | ||
User user) { | ||
List<BasicAcademicalManager> basicAcademicalManagers = List.of( | ||
new BusinessBasicAcademicalManager(), | ||
new SocialScienceBasicAcademicManager()); | ||
|
||
return basicAcademicalManagers.stream() | ||
.filter(basicAcademicalManager -> basicAcademicalManager.isSatisfied(user.getDualMajor())) | ||
.findFirst() | ||
.orElse(new DefaultBasicAcademicalManager()); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
...on/application/service/CalculateDualBasicAcademicalCultureDetailGraduationUseService.java
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
...ebe/graduation/application/service/CalculateDualElectiveMajorDetailGraduationService.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,70 @@ | ||
package com.plzgraduate.myongjigraduatebe.graduation.application.service; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.DUAL_ELECTIVE_MAJOR; | ||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory.DUAL; | ||
|
||
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.CalculateDualElectiveMajorDetailGraduationUseCase; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult; | ||
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.service.GraduationManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorManager; | ||
import com.plzgraduate.myongjigraduatebe.lecture.application.port.FindMajorPort; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.MajorLecture; | ||
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.User; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class CalculateDualElectiveMajorDetailGraduationService | ||
implements CalculateDualElectiveMajorDetailGraduationUseCase { | ||
|
||
private final FindMajorPort findMajorPort; | ||
|
||
@Override | ||
public boolean supports(GraduationCategory graduationCategory) { | ||
return graduationCategory == DUAL_ELECTIVE_MAJOR; | ||
} | ||
|
||
@Override | ||
public DetailGraduationResult calculateDetailGraduation(User user, TakenLectureInventory takenLectureInventory, | ||
GraduationRequirement graduationRequirement) { | ||
Set<MajorLecture> graduationMajorLectures = findMajorPort.findMajor(user.getDualMajor()); | ||
GraduationManager<MajorLecture> majorGraduationManager = new MajorManager(DUAL); | ||
DetailGraduationResult majorDetailGraduationResult = majorGraduationManager.createDetailGraduationResult(user, | ||
takenLectureInventory, graduationMajorLectures, graduationRequirement.getDualMajorCredit()); | ||
|
||
DetailCategoryResult electiveMajorDetailCategoryResult = separateElectiveMajor(majorDetailGraduationResult); | ||
return DetailGraduationResult.create(DUAL_ELECTIVE_MAJOR, electiveMajorDetailCategoryResult.getTotalCredits(), | ||
List.of(electiveMajorDetailCategoryResult)); | ||
} | ||
|
||
@Override | ||
public DetailGraduationResult isolateDualElectiveMajorDetailGraduation( | ||
DetailGraduationResult dualMajorDetailGraduationResult) { | ||
DetailCategoryResult electiveMajorDetailCategoryResult = separateElectiveMajor( | ||
dualMajorDetailGraduationResult); | ||
return DetailGraduationResult.create(DUAL_ELECTIVE_MAJOR, | ||
electiveMajorDetailCategoryResult.getTotalCredits(), List.of(electiveMajorDetailCategoryResult)); | ||
} | ||
|
||
private DetailCategoryResult separateElectiveMajor( | ||
DetailGraduationResult majorDetailGraduationResult) { | ||
DetailCategoryResult dualElectiveMajorDetailCategoryResult = majorDetailGraduationResult.getDetailCategory().stream() | ||
.filter(detailCategoryResult -> detailCategoryResult.getDetailCategoryName().equals("전공선택")) | ||
.findFirst() | ||
.orElseThrow(() -> new RuntimeException("Not Found DetailCategoryResult(전공 선택)")); | ||
dualElectiveMajorDetailCategoryResult.assignDetailCategoryName("복수전공선택"); | ||
return dualElectiveMajorDetailCategoryResult; | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
...igraduatebe/graduation/application/service/CalculateDualMajorDetailGraduationService.java
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
...be/graduation/application/service/CalculateDualMandatoryMajorDetailGraduationService.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,70 @@ | ||
package com.plzgraduate.myongjigraduatebe.graduation.application.service; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.DUAL_MANDATORY_MAJOR; | ||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory.DUAL; | ||
|
||
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.CalculateDualMandatoryMajorDetailGraduationUseCase; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult; | ||
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.service.GraduationManager; | ||
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorManager; | ||
import com.plzgraduate.myongjigraduatebe.lecture.application.port.FindMajorPort; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.MajorLecture; | ||
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.User; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class CalculateDualMandatoryMajorDetailGraduationService | ||
implements CalculateDualMandatoryMajorDetailGraduationUseCase { | ||
|
||
private final FindMajorPort findMajorPort; | ||
|
||
@Override | ||
public boolean supports(GraduationCategory graduationCategory) { | ||
return graduationCategory == DUAL_MANDATORY_MAJOR; | ||
} | ||
|
||
@Override | ||
public DetailGraduationResult calculateDetailGraduation(User user, TakenLectureInventory takenLectureInventory, | ||
GraduationRequirement graduationRequirement) { | ||
Set<MajorLecture> graduationMajorLectures = findMajorPort.findMajor(user.getDualMajor()); | ||
GraduationManager<MajorLecture> majorGraduationManager = new MajorManager(DUAL); | ||
DetailGraduationResult majorDetailGraduationResult = majorGraduationManager.createDetailGraduationResult(user, | ||
takenLectureInventory, graduationMajorLectures, graduationRequirement.getDualMajorCredit()); | ||
|
||
DetailCategoryResult mandatoryMajorDetailCategoryResult = separateMandatoryMajor(majorDetailGraduationResult); | ||
return DetailGraduationResult.create(DUAL_MANDATORY_MAJOR, | ||
mandatoryMajorDetailCategoryResult.getTotalCredits(), List.of(mandatoryMajorDetailCategoryResult)); | ||
} | ||
|
||
@Override | ||
public DetailGraduationResult isolateDualMandatoryMajorDetailGraduation( | ||
DetailGraduationResult dualMajorDetailGraduationResult) { | ||
DetailCategoryResult mandatoryMajorDetailCategoryResult = separateMandatoryMajor( | ||
dualMajorDetailGraduationResult); | ||
return DetailGraduationResult.create(DUAL_MANDATORY_MAJOR, | ||
mandatoryMajorDetailCategoryResult.getTotalCredits(), List.of(mandatoryMajorDetailCategoryResult)); | ||
} | ||
|
||
private DetailCategoryResult separateMandatoryMajor( | ||
DetailGraduationResult majorDetailGraduationResult) { | ||
DetailCategoryResult dualMandatoryMajorDetailCategoryResult = majorDetailGraduationResult.getDetailCategory().stream() | ||
.filter(detailCategoryResult -> detailCategoryResult.getDetailCategoryName().equals("전공필수")) | ||
.findFirst() | ||
.orElseThrow(() -> new RuntimeException("Not Found DetailCategoryResult(전공 필수)")); | ||
dualMandatoryMajorDetailCategoryResult.assignDetailCategoryName("복수전공필수"); | ||
return dualMandatoryMajorDetailCategoryResult; | ||
} | ||
} |
Oops, something went wrong.