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-42] 연계전공 및 편입 등 추가 정보 파싱 #286

Merged
merged 6 commits into from
Nov 24, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public enum GraduationCategory {
SUB_MAJOR("부전공"),
PRIMARY_BASIC_ACADEMICAL_CULTURE("주학문기초교양"),
DUAL_BASIC_ACADEMICAL_CULTURE("복수학문기초교양"),
// 연계전공필수, 연계전공선택, 연계전공교양필수, 연계전공교양선택
ASSOCIATED_MANDATORY_MAJOR("연계전공필수"),
ASSOCIATED_ELECTIVE_MAJOR("연계전공선택"),
ASSOCIATED_MANDATORY_CULTURE("연계전공교양필수"),
ASSOCIATED_ELECTIVE_CULTURE("연계전공교양선택"),
NORMAL_CULTURE("일반교양"),
FREE_ELECTIVE("자유선택"),
CHAPEL("채플");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ private List<TakenLectureInformation> getSaveTakenLectureCommand(
}

private void checkUnSupportedUser(ParsingInformation parsingInformation) {
if (parsingInformation.getStudentCategory() == ASSOCIATED_MAJOR
|| parsingInformation.getStudentCategory() == DOUBLE_SUB) {
if (parsingInformation.getStudentCategory() == DOUBLE_SUB) {
throw new IllegalArgumentException(ErrorCode.UNSUPPORTED_STUDENT_CATEGORY.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ public class ParsingInformation {

@Builder
public ParsingInformation(String studentName, String studentNumber, String major,
String changeMajor, String subMajor, String dualMajor,
String associatedMajor, StudentCategory studentCategory,
List<ParsingTakenLectureDto> takenLectureInformation) {
String changeMajor, String subMajor, String dualMajor,
String associatedMajor, StudentCategory studentCategory,
List<ParsingTakenLectureDto> takenLectureInformation) {
this.studentName = studentName;
this.studentNumber = studentNumber;
this.major = major;
this.changeMajor = changeMajor;
this.dualMajor = dualMajor;
this.subMajor = subMajor;
this.associatedMajor = associatedMajor;
this.studentCategory = studentCategory;
this.studentCategory = studentCategory;
this.takenLectureInformation = takenLectureInformation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class ParsingStudentCategoryDto {

@Builder
private ParsingStudentCategoryDto(String changeMajor, String dualMajor, String subMajor,
String associatedMajor,
StudentCategory studentCategory) {
String associatedMajor,
StudentCategory studentCategory) {
this.changeMajor = changeMajor;
this.dualMajor = dualMajor;
this.subMajor = subMajor;
this.associatedMajor = associatedMajor;
this.studentCategory = studentCategory;
this.studentCategory = studentCategory;
}

public static ParsingStudentCategoryDto of(String changeMajor, String subMajor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public User updateUser(UpdateStudentInformationCommand updateStudentInformationC
updateStudentInformationCommand.getMajor(),
updateStudentInformationCommand.getDualMajor(),
updateStudentInformationCommand.getSubMajor(),
updateStudentInformationCommand.getAssociatedMajor(),
updateStudentInformationCommand.getStudentCategory(),
updateStudentInformationCommand.getTotalCredit(),
updateStudentInformationCommand.getTakenCredit(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

private String subMajor;

private String associatedMajor;

private StudentCategory studentCategory;

private int totalCredit;
Expand All @@ -32,13 +34,14 @@

@Builder
private UpdateStudentInformationCommand(User user, String name, String major, String dualMajor,
String subMajor, StudentCategory studentCategory, int totalCredit, double takenCredit,
String subMajor, String associatedMajor, StudentCategory studentCategory, int totalCredit, double takenCredit,
boolean graduate) {
this.user = user;
this.name = name;
this.major = major;
this.dualMajor = dualMajor;
this.subMajor = subMajor;
this.associatedMajor = associatedMajor;
this.studentCategory = studentCategory;
this.totalCredit = totalCredit;
this.takenCredit = takenCredit;
Expand All @@ -53,6 +56,7 @@
.major(parsingInformation.getMajor())
.dualMajor(parsingInformation.getDualMajor())
.subMajor(parsingInformation.getSubMajor())
.associatedMajor(parsingInformation.getAssociatedMajor())
.studentCategory(parsingInformation.getStudentCategory())
.build();
}
Expand All @@ -66,6 +70,7 @@
.major(user.getPrimaryMajor())
.dualMajor(user.getDualMajor())
.subMajor(user.getSubMajor())
.associatedMajor(user.getAssociatedMajor())

Check warning on line 73 in src/main/java/com/plzgraduate/myongjigraduatebe/user/application/usecase/update/UpdateStudentInformationCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/plzgraduate/myongjigraduatebe/user/application/usecase/update/UpdateStudentInformationCommand.java#L73

Added line #L73 was not covered by tests
.totalCredit(graduationResult.getTotalCredit())
.takenCredit(graduationResult.getTakenCredit())
.graduate(graduationResult.isGraduated())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.PRIMARY_BASIC_ACADEMICAL_CULTURE;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.PRIMARY_ELECTIVE_MAJOR;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.PRIMARY_MANDATORY_MAJOR;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.ASSOCIATED_MANDATORY_CULTURE;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.ASSOCIATED_ELECTIVE_CULTURE;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.ASSOCIATED_MANDATORY_MAJOR;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.ASSOCIATED_ELECTIVE_MAJOR;

import com.plzgraduate.myongjigraduatebe.core.exception.ErrorCode;
import com.plzgraduate.myongjigraduatebe.core.exception.PdfParsingException;
Expand Down Expand Up @@ -45,9 +49,11 @@ public enum StudentCategory {
FREE_ELECTIVE, CHAPEL)),
ASSOCIATED_MAJOR(List.of("연계전공"),
// 현재 미지원
List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE,
PRIMARY_MANDATORY_MAJOR,
PRIMARY_ELECTIVE_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, CHAPEL)),
List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE,
ASSOCIATED_MANDATORY_CULTURE, ASSOCIATED_ELECTIVE_CULTURE,
PRIMARY_MANDATORY_MAJOR, PRIMARY_ELECTIVE_MAJOR, ASSOCIATED_MANDATORY_MAJOR,
ASSOCIATED_ELECTIVE_MAJOR, NORMAL_CULTURE, FREE_ELECTIVE, CHAPEL
)),
DOUBLE_SUB(List.of("복수전공", "부전공"),
// 현재 미지원
List.of(COMMON_CULTURE, CORE_CULTURE, PRIMARY_BASIC_ACADEMICAL_CULTURE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public class User {
private String primaryMajor;
private String subMajor;
private String dualMajor;
// 연계전공명
// 편입 여부
private String associatedMajor;
private StudentCategory studentCategory;
private int totalCredit;
private double takenCredit;
Expand All @@ -35,7 +34,7 @@ public class User {
@Builder
private User(Long id, String authId, String password, EnglishLevel englishLevel, String name,
String studentNumber,
int entryYear, String primaryMajor, String subMajor, String dualMajor,
int entryYear, String primaryMajor, String subMajor, String dualMajor, String associatedMajor,
StudentCategory studentCategory,
int totalCredit, double takenCredit, boolean graduated, Instant createdAt,
Instant updatedAt) {
Expand All @@ -49,6 +48,7 @@ private User(Long id, String authId, String password, EnglishLevel englishLevel,
this.primaryMajor = primaryMajor;
this.subMajor = subMajor;
this.dualMajor = dualMajor;
this.associatedMajor = associatedMajor;
this.studentCategory = studentCategory;
this.totalCredit = totalCredit;
this.takenCredit = takenCredit;
Expand Down Expand Up @@ -76,12 +76,13 @@ private static int parseEntryYearInStudentNumber(String studentNumber) {
}

public void updateStudentInformation(String name, String major, String dualMajor,
String subMajor,
String subMajor, String associatedMajor,
StudentCategory studentCategory, int totalCredit, double takenCredit, boolean graduate) {
this.name = name;
this.primaryMajor = major;
this.dualMajor = dualMajor;
this.subMajor = subMajor;
this.associatedMajor = associatedMajor;
this.studentCategory = studentCategory;
this.totalCredit = totalCredit;
this.takenCredit = takenCredit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class UserJpaEntity extends TimeBaseEntity {

private String subMajor;

private String associatedMajor;

private int totalCredit;

private double takenCredit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public User mapToDomainEntity(UserJpaEntity user) {
.primaryMajor(user.getMajor())
.dualMajor(user.getDualMajor())
.subMajor(user.getSubMajor())
.associatedMajor(user.getAssociatedMajor())
.studentCategory(user.getStudentCategory())
.totalCredit(user.getTotalCredit())
.takenCredit(user.getTakenCredit())
Expand All @@ -41,6 +42,7 @@ public UserJpaEntity mapToJpaEntity(User user) {
.major(user.getPrimaryMajor())
.dualMajor(user.getDualMajor())
.subMajor(user.getSubMajor())
.associatedMajor(user.getAssociatedMajor())
.studentCategory(user.getStudentCategory())
.totalCredit(user.getTotalCredit())
.takenCredit(user.getTakenCredit())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void createParsingInformation() {
StudentCategory.SUB_MAJOR);
}


@DisplayName("재수강, F학점, Non pass인 경우 수강 정보를 추출하지 않는다.")
@Test
void RFN인경우_수강정보제외() {
Expand All @@ -121,4 +120,27 @@ void createParsingInformation() {
assertThat(parsingInformation.getTakenLectureInformation()).hasSize(46);
}

@DisplayName("연계전공을 할 경우 StudentCategory는 ASSOCIATED_MAJOR이며, associated_major에 연계전공명이 입력된다.")
@Test
void 연계전공생_확인() {
//given
String parsingText = "출력일자 : 2022/11/14|1/1"
+ "|경영대학 경영정보학과, 연계전공 - 프로세스 자동화 경영, 장예지(60191363), 현학적 - 재학, 이수 - 7, 입학 - 신입학(2019/03/04)"
+ "|토익 - 410, 영어교과목면제 - 면제없음, 최종학적변동 - 신입학(2019/03/04)"
+ "|편입생 인정학점 - 교양 0, 전공 0, 자유선택 0, 성경과인간이해 0"
+ "|교환학생 인정학점 - 학문기초교양 0, 일반교양 0, 전공 0, 복수전공학문기초교양 0, 복수전공 0, 연계전공 0, 부전공 0, 자유선택 0"
+ "|공통교양 17, 핵심교양 12, 학문기초교양 6, 일반교양 18, 전공 48, 복수전공 0, 연계전공 9, 부전공 0, 교직 0, 자유선택 9"
+ "|총 취득학점 - 119, 총점 - 436.5, 평균평점 - 3.83"
+ "|이수구분|수강년도/학기|한글코드|과목코드|과목명|학점|등급|중복|공통교양 (구 필수교양)|2021년 1학기|교필141|KMA02141|4차산업혁명과미래사회진로선택|2|P"
+ "|공통교양 (구 필수교양)|2019년 1학기|교필105|KMA02105|발표와토의|3|B0";

//when
ParsingInformation parsingInformation = ParsingInformation.parsing(parsingText);

//then
assertThat(parsingInformation)
.extracting("studentName", "studentNumber", "major", "associatedMajor",
"studentCategory")
.contains("장예지", "60191363", "경영정보학과", "프로세스 자동화 경영", StudentCategory.ASSOCIATED_MAJOR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void create() {
@Test
void updateStudentInformation() {
//given //when
user.updateStudentInformation("테스터2", "경영학과", null, null, StudentCategory.CHANGE_MAJOR, 134,
user.updateStudentInformation("테스터2", "경영학과", null, null, null, StudentCategory.CHANGE_MAJOR, 134,
120.5, true);
//then
assertThat(user)
Expand Down
Loading