Skip to content
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

[DEV-52] 외국인 학생 검사 추가 #298

Merged
merged 14 commits into from
Jan 9, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
) {
ParsingAnonymousDto parsingAnonymousDto = parsingAnonymousUseCase.parseAnonymous(
checkGraduationRequirementRequest.getEngLv(),
checkGraduationRequirementRequest.getKorLv(),

Check warning on line 32 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/CheckGraduationRequirementController.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/CheckGraduationRequirementController.java#L32

Added line #L32 was not covered by tests
checkGraduationRequirementRequest.getParsingText()
);
User anonymous = parsingAnonymousDto.getAnonymous();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.plzgraduate.myongjigraduatebe.graduation.api.dto.request;

import com.plzgraduate.myongjigraduatebe.user.domain.model.EnglishLevel;
import com.plzgraduate.myongjigraduatebe.user.domain.model.KoreanLevel;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
Expand All @@ -13,20 +14,32 @@
public class CheckGraduationRequirementRequest {

@NotBlank(message = "영어 레벨을 입력해 주세요.")
@Schema(name = "engLv", example = "ENG34")
@Schema(name = "engLv", example = "ENG12")
private String engLv;

@NotBlank(message = "한국어 레벨을 입력해 주세요.")
@Schema(name = "korLv", example = "FREE")
private String korLv;

@NotNull(message = "parsingText는 null 값이 될 수 없습니다.")
@Schema(name = "parsingText", example = "2023/12/08|1/1|ICT융합대학 융합소프트웨어학부 데이터테크놀로지전공, 나경호(60202455), 현학적 - 재학, 이수 - 3, 입학 - 신입학(2020/03/02)|토익 - 715, 영어교과목면제 - 면제없음, 최종학적변동 - 2/1전과(2023/01/27), 전과내역 - 기계공학과|편입생 인정학점 - 교양 0, 전공 0, 자유선택 0, 성경과인간이해 0|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공학문기초교양 0, 복수전공 0, 연계전공 0, 부전공 0, 자유선택 0|공통교양 16.5, 핵심교양 6, 학문기초교양 6, 일반교양 12, 전공 9, 복수전공 0, 연계전공 0, 부전공 0, 교직 0, 자유선택 7|총 취득학점 - 56.5, 총점 - 230.5, 평균평점 - 4.43|이수구분|수강년도/학기|한글코드|과목코드|과목명|학점|등급|중복|공통교양|2020년 2학기|교필141|KMA02141|4차산업혁명과미래사회진로선택|2|P|공통교양|2020년 2학기|교필122|KMA02122|기독교와문화|2|A+|공통교양|2023년 1학기|교필105|KMA02105|발표와토의|3|A0|공통교양|2020년 1학기|교필127|KMA00101|성서와인간이해|2|A+|공통교양|2020년 1학기|교필123|KMA02123|영어3|2|A+|공통교양|2020년 2학기|교필124|KMA02124|영어4|2|A+|공통교양|2020년 1학기|교필125|KMA02125|영어회화3|1|A0|공통교양|2020년 2학기|교필126|KMA02126|영어회화4|1|A+|공통교양|2020년 1학기|교필101|KMA02101|채플|0.5|P|공통교양|2020년 2학기|교필101|KMA02101|채플|0.5|P|공통교양|2023년 1학기|교필101|KMA02101|채플|0.5|P|핵심교양|2023년 1학기|교선128|KMA02128|글로벌문화|3|A0|핵심교양|2023년 1학기|교선114|KMA02114|민주주의와현대사회|3|A+|학문기초교양|2020년 1학기|기자111|KME02111|물리학1|3|A+|학문기초교양|2020년 1학기|기자101|KME02101|미적분학1|3|A+|일반교양|2020년 2학기|기자112|KME02112|물리학2|3|A+|일반교양|2020년 1학기|기자113|KME02113|물리학실험1|1|A+|일반교양|2020년 2학기|기자114|KME02114|물리학실험2|1|A+|일반교양|2020년 2학기|기자102|KME02102|미적분학2|3|A+|일반교양|2020년 1학기|기자121|KME02121|일반화학|3|A+|일반교양|2020년 1학기|기자122|KME02122|일반화학실험|1|A+|전공1단계|2023년 1학기|데테202|HED01202|R통계분석|3|A+|전공1단계|2023년 1학기|융소102|HEB01102|기초프로그래밍|3|A+|전공1단계|2023년 1학기|데테201|HED01201|자료구조|3|A+|자유선택|2020년 2학기|공과100|JEA00100|공학입문설계|3|A+|자유선택|2020년 1학기|기계207|JEP01207|기계신입생세미나|1|P|자유선택|2020년 2학기|기계209|JEP02209|정역학|3|A+|")
@Schema(
name = "parsingText",
example = "출력일자 : 2024/11/20|1/1|ICT융합대학 융합소프트웨어학부 데이터테크놀로지전공, 김보겸(60211648), 현학적 - 재학, 이수 - 6, 입학 - 신입학(2021/03/02)|토익 - 535, 영어교과목면제 - 면제없음, 최종학적변동 - 불일치복학(2023/01/09)|편입생 인정학점 - 교양 0, 전공 0, 자유선택 0, 성경과인간이해 0|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공학문기초교양 0, 복수전공 0, 융합전공 0, 부전공 0, 자유선택 0|공통교양 17, 핵심교양 12, 학문기초교양 15, 일반교양 14, 전공 50, 복수전공 0, 연계전공 0, 부전공 0, 교직 0, 자유선택 0|총 취득학점 - 108, 총점 - 441.5, 평균평점 - 4.33|이수구분|수강년도/학기|한글코드|과목코드|과목명|학점|등급|중복|공통교양|2023년 2학기|교필141|KMA02141|4차산업혁명과미래사회진로선택|2|P|공통교양|2021년 2학기|교필105|KMA02105|발표와토의|3|A0|공통교양|2021년 2학기|교필127|KMA00101|성서와인간이해|2|A0|공통교양|2021년 1학기|교필106|KMA02106|영어1|2|A+|공통교양|2021년 2학기|교필107|KMA02107|영어2|2|A+|공통교양|2021년 1학기|교필108|KMA02108|영어회화1|1|A+|공통교양|2021년 2학기|교필109|KMA02109|영어회화2|1|A0|공통교양|2021년 1학기|교필101|KMA02101|채플|0.5|P|공통교양|2021년 2학기|교필101|KMA02101|채플|0.5|P|공통교양|2022년 1학기|교필101|KMA02101|채플|0.5|P|공통교양|2023년 1학기|교필101|KMA02101|채플|0.5|P|공통교양|2021년 2학기|교필102|KMA02102|현대사회와기독교윤리|2|A0|핵심교양|2022년 1학기|교선128|KMA02128|글로벌문화|3|A+|핵심교양|2021년 1학기|교선114|KMA02114|민주주의와현대사회|3|A+|핵심교양|2021년 2학기|교선112|KMA02112|역사와문명|3|A0|핵심교양|2021년 1학기|교선135|KMA02135|우주,생명,마음|3|B+|학문기초교양|2023년 1학기|기사133|KMD02133|ICT비즈니스와경영|3|A0|학문기초교양|2023년 1학기|기사134|KMD02134|마케팅과ICT융합기술|3|A0|학문기초교양|2021년 1학기|기인107|KMB02107|인간심리의이해|3|A+|학문기초교양|2021년 2학기|기사135|KMD02135|저작권과소프트웨어|3|A+|학문기초교양|2022년 1학기|기컴112|KMI02112|컴퓨터논리의이해|3|B+|일반교양|2022년 1학기|균인131|KMK02131|사랑의인문학(KCU)|3|A0|일반교양|2021년 1학기|기컴125|KMI02125|생활속의스마트IT(KCU)|3|A+|일반교양|2024년 1학기|기문227|KMC02227|인류문명과기록문화로의여행|3|A+|일반교양|2024년 1학기|균사181|KMM02181|자기경영과실전취업준비|2|A+|일반교양|2024년 1학기|기컴126|KMI02126|파이썬프로그래밍입문|3|A+|전공1단계|2022년 1학기|데테202|HED01202|R통계분석|3|A+|전공1단계|2022년 1학기|데테316|HED01316|고급웹프로그래밍|3|A+|전공1단계|2023년 2학기|데테206|HED01206|기초웹프로그래밍|3|A+|전공1단계|2021년 1학기|융소102|HEB01102|기초프로그래밍|3|A+|전공1단계|2021년 2학기|융소105|HEB01105|기초프로그래밍2|3|A+|전공1단계|2023년 1학기|데테318|HED01203|데이터베이스|3|A+|전공1단계|2024년 1학기|데테319|HED01318|모바일컴퓨팅|3|A+|전공1단계|2023년 2학기|데테403|HED01403|블록체인기초|3|A+|전공1단계|2024년 1학기|데테404|HED01404|빅데이터기술특론1|3|A+|전공1단계|2023년 1학기|데테301|HED01301|소프트웨어공학|3|A+|전공1단계|2023년 2학기|데테209|HED01307|알고리즘|3|A+|전공1단계|2023년 2학기|데테303|HED01303|운영체제|3|A+|전공1단계|2023년 2학기|데테311|HED01311|자기주도학습|2|P|전공1단계|2022년 1학기|데테201|HED01201|자료구조|3|A+|전공1단계|2024년 1학기|데테413|HED01413|캡스톤디자인|3|A+|전공1단계|2023년 1학기|데테309|HED01309|컴퓨터아키텍쳐|3|A0|전공1단계|2023년 2학기|데테313|HED01313|컴퓨터통신|3|A+|"
)
private String parsingText;

@Builder
public CheckGraduationRequirementRequest(String engLv, String parsingText) {
public CheckGraduationRequirementRequest(String engLv, String korLv, String parsingText) {

Check warning on line 32 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/dto/request/CheckGraduationRequirementRequest.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/dto/request/CheckGraduationRequirementRequest.java#L32

Added line #L32 was not covered by tests
this.engLv = engLv;
this.korLv = korLv;

Check warning on line 34 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/dto/request/CheckGraduationRequirementRequest.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/dto/request/CheckGraduationRequirementRequest.java#L34

Added line #L34 was not covered by tests
this.parsingText = parsingText;
}

public EnglishLevel getEngLv() {
return EnglishLevel.valueOf(engLv);
}

public KoreanLevel getKorLv() {
return KoreanLevel.valueOf(korLv);

Check warning on line 43 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/dto/request/CheckGraduationRequirementRequest.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/api/dto/request/CheckGraduationRequirementRequest.java#L43

Added line #L43 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import com.plzgraduate.myongjigraduatebe.core.meta.UseCase;
import com.plzgraduate.myongjigraduatebe.graduation.application.usecase.CalculateGraduationUseCase;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.*;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.ChapelResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DefaultGraduationRequirementType;
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.model.GraduationResult;
import com.plzgraduate.myongjigraduatebe.lecture.application.port.FindBasicAcademicalCulturePort;
import com.plzgraduate.myongjigraduatebe.takenlecture.application.usecase.find.FindTakenLectureUseCase;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory;
Expand Down Expand Up @@ -31,19 +37,20 @@


@Override
public GraduationResult calculateGraduation(User user) {
public GraduationResult calculateGraduation(User user) {
GraduationRequirement graduationRequirement = determineGraduationRequirement(user);
TakenLectureInventory takenLectureInventory = findTakenLectureUseCase.findTakenLectures(
user.getId()
);

ChapelResult chapelResult = generateChapelResult(takenLectureInventory);
List<DetailGraduationResult> detailGraduationResults = generateDetailGraduationResults(
user,
takenLectureInventory,
graduationRequirement
);

ChapelResult chapelResult = generateChapelResult(user, takenLectureInventory);

Check warning on line 52 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java#L52

Added line #L52 was not covered by tests

GraduationResult graduationResult = generateGraduationResult(
chapelResult,
detailGraduationResults,
Expand Down Expand Up @@ -80,22 +87,31 @@
);
}

private double calculateChristianTakenCredits(User user, TakenLectureInventory takenLectureInventory) {
if (!user.getAuthId().equals("anonymous")) {
private double calculateChristianTakenCredits(
User user,
TakenLectureInventory takenLectureInventory
) {
if (!user.isAnonymous()) {
takenLectureInventory = findTakenLectureUseCase.findTakenLectures(user.getId());
}
return takenLectureInventory.calculateChristianCredits();

}

GraduationRequirement determineGraduationRequirement(User user) {
public GraduationRequirement determineGraduationRequirement(User user) {
College userCollage = College.findBelongingCollege(user.getPrimaryMajor());
DefaultGraduationRequirementType defaultGraduationRequirement =
DefaultGraduationRequirementType.determineGraduationRequirement(userCollage, user);
return defaultGraduationRequirement.convertToProfitGraduationRequirement(user);
}

ChapelResult generateChapelResult(TakenLectureInventory takenLectureInventory) {
public ChapelResult generateChapelResult(
User user,
TakenLectureInventory takenLectureInventory
) {
if (user.isChapleReplaced()) {
return ChapelResult.replaced();

Check warning on line 113 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java#L113

Added line #L113 was not covered by tests
}
ChapelResult chapelResult = ChapelResult.create(takenLectureInventory);
chapelResult.checkCompleted();
return chapelResult;
Expand All @@ -109,7 +125,11 @@
List<DetailGraduationResult> detailGraduationResults = new ArrayList<>();
if (user.getStudentCategory() == StudentCategory.TRANSFER) {
detailGraduationResults.add(
generateTransferChristianDetailGraduationResult(user, graduationRequirement, takenLectureInventory)
generateTransferChristianDetailGraduationResult(

Check warning on line 128 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java#L128

Added line #L128 was not covered by tests
user,
graduationRequirement,
takenLectureInventory
)
);
} else {
detailGraduationResults.addAll(List.of(
Expand Down Expand Up @@ -188,7 +208,11 @@
chapelResult,
detailGraduationResults
);
graduationResult.handleLeftTakenLectures(takenLectureInventory, graduationRequirement, user);
graduationResult.handleLeftTakenLectures(

Check warning on line 211 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CalculateGraduationService.java#L211

Added line #L211 was not covered by tests
takenLectureInventory,
graduationRequirement,
user
);
graduationResult.checkGraduated(graduationRequirement, user);
return graduationResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,32 @@
User anonymous,
TakenLectureInventory takenLectureInventory
) {
Set<TakenLecture> takenLectureWithDuplicateCode = takenLectureInventory.getTakenLectures()
.stream()
.map(takenLecture -> TakenLecture.of(
anonymous,
findLecturePort.findLectureById(takenLecture.getLecture().getId()),
takenLecture.getYear(),
takenLecture.getSemester()
)
).collect(Collectors.toSet());
Set<TakenLecture> takenLectureWithDuplicateCode = getTakenLectureWithDuplicateCode(

Check warning on line 31 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L31

Added line #L31 was not covered by tests
anonymous,
takenLectureInventory
);

TakenLectureInventory takenLectureInventoryWithDuplicateCode = TakenLectureInventory.from(
takenLectureWithDuplicateCode);
TakenLectureInventory takenLectureInventoryWithDuplicateCode =
TakenLectureInventory.from(takenLectureWithDuplicateCode);

Check warning on line 37 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L36-L37

Added lines #L36 - L37 were not covered by tests

GraduationRequirement graduationRequirement =
calculateGraduationService.determineGraduationRequirement(anonymous);

ChapelResult chapelResult =
calculateGraduationService.generateChapelResult(takenLectureInventoryWithDuplicateCode);
if (anonymous.getStudentCategory() == StudentCategory.TRANSFER) {
chapelResult.checkAnonymousTransferUserChapelCount();
}

List<DetailGraduationResult> detailGraduationResults = calculateGraduationService.generateDetailGraduationResults(
anonymous,
takenLectureInventoryWithDuplicateCode,
graduationRequirement
);

ChapelResult chapelResult = calculateGraduationService.generateChapelResult(

Check warning on line 48 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L48

Added line #L48 was not covered by tests
anonymous,
takenLectureInventoryWithDuplicateCode
);

if (anonymous.getStudentCategory() == StudentCategory.TRANSFER) {
chapelResult.checkAnonymousTransferUserChapelCount();

Check warning on line 54 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L54

Added line #L54 was not covered by tests
}

GraduationResult graduationResult = calculateGraduationService.generateGraduationResult(
chapelResult,
detailGraduationResults,
Expand All @@ -63,6 +62,22 @@
anonymous
);
calculateGraduationService.handleDuplicatedTakenCredit(anonymous, graduationResult);

return graduationResult;
}

private Set<TakenLecture> getTakenLectureWithDuplicateCode(
User anonymous,
TakenLectureInventory takenLectureInventory
) {
return takenLectureInventory.getTakenLectures()
.stream()
.map(takenLecture -> TakenLecture.of(

Check warning on line 75 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L73-L75

Added lines #L73 - L75 were not covered by tests
anonymous,
findLecturePort.findLectureById(takenLecture.getLecture().getId()),
takenLecture.getYear(),
takenLecture.getSemester()

Check warning on line 79 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L77-L79

Added lines #L77 - L79 were not covered by tests
)
).collect(Collectors.toSet());

Check warning on line 81 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/application/service/CheckGraduationRequirementService.java#L81

Added line #L81 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
.build();
}

public static ChapelResult replaced() {
return ChapelResult.builder()
.isCompleted(true)
.build();

Check warning on line 34 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/ChapelResult.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/ChapelResult.java#L32-L34

Added lines #L32 - L34 were not covered by tests
}

private static int countTakenChapel(TakenLectureInventory takenLectureInventory) {
return (int) takenLectureInventory.getTakenLectures()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import lombok.Builder;
import lombok.Getter;

@Getter
public class DetailCategoryResult {

private final boolean isSatisfiedMandatory;
private final int totalCredits;
private final List<Lecture> takenLectures = new ArrayList<>();
private final List<Lecture> haveToLectures = new ArrayList<>();
private int totalCredits;
private String detailCategoryName;
private boolean isCompleted;
private int takenCredits;
Expand Down Expand Up @@ -116,16 +115,19 @@
graduationLectures.stream()
.filter(graduationLecture -> graduationLecture.getIsRevoked() == 0)
.forEach(haveToLectures::add);

}

private boolean checkCompleted() {
isCompleted = totalCredits <= takenCredits && isSatisfiedMandatory;
return isCompleted;
}

public void addTakenCredits(int credits) {
this.takenCredits += credits;
checkCompleted();
}

public void addChapleCreditToChritain() {
this.totalCredits += (int) (ChapelResult.CHAPEL_CREDIT * ChapelResult.GRADUATION_COUNT);
}

Check warning on line 132 in src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailCategoryResult.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailCategoryResult.java#L131-L132

Added lines #L131 - L132 were not covered by tests
}
Loading
Loading