Skip to content

Commit

Permalink
Merge pull request #271 from Myongji-Graduate/dev-35-update-info
Browse files Browse the repository at this point in the history
[DEV-35] 학사안내문 업데이트 반영
  • Loading branch information
stophwan authored Jun 13, 2024
2 parents 9a36c31 + 5726119 commit 8349dce
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ private void addMandatoryLectures(Set<Lecture> taken, Set<Lecture> graduationLec
graduationLectures.stream()
.filter(graduationLecture -> graduationLecture.getIsRevoked() == 0)
.forEach(haveToLectures::add);

}

private boolean checkCompleted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory;

public class ElectiveMajorManager {
private static final String ELECTIVE_MAJOR_NAME = "전공선택";
public DetailCategoryResult createDetailCategoryResult(TakenLectureInventory takenLectureInventory,
Set<Lecture> electiveLectures, int electiveMajorTotalCredit) {
Set<Lecture> takenElective = new HashSet<>();
Expand All @@ -19,7 +20,7 @@ public DetailCategoryResult createDetailCategoryResult(TakenLectureInventory tak
finishedTakenLecture.add(takenLecture);
takenElective.add(takenLecture.getLecture());
});
DetailCategoryResult electiveMajorResult = DetailCategoryResult.create("전공선택", true, electiveMajorTotalCredit);
DetailCategoryResult electiveMajorResult = DetailCategoryResult.create(ELECTIVE_MAJOR_NAME, true, electiveMajorTotalCredit);
electiveMajorResult.calculate(takenElective, electiveLectures);
takenLectureInventory.handleFinishedTakenLectures(finishedTakenLecture);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailGraduationResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.GraduationManager;
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception.MajorExceptionHandler;
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception.OptionalMandatoryHandler;
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception.ReplaceMandatoryMajorHandler;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.MajorLecture;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture;
Expand Down Expand Up @@ -41,10 +38,10 @@ public DetailGraduationResult createDetailGraduationResult(User user,
Set<Lecture> mandatoryLectures = filterMandatoryLectures(majorLectures);
Set<Lecture> electiveLectures = filterElectiveLectures(majorLectures);

List<MajorExceptionHandler> majorExceptionHandlers = List.of(
new OptionalMandatoryHandler(),
new ReplaceMandatoryMajorHandler());
MandatoryMajorManager mandatoryMajorManager = new MandatoryMajorManager(majorExceptionHandlers);
List<MandatoryMajorSpecialCaseHandler> mandatoryMajorSpecialCaseHandlers = List.of(
new OptionalMandatoryMandatoryMajorHandler(),
new ReplaceMandatoryMandatoryMajorHandler());
MandatoryMajorManager mandatoryMajorManager = new MandatoryMajorManager(mandatoryMajorSpecialCaseHandlers);
ElectiveMajorManager electiveMajorManager = new ElectiveMajorManager();

DetailCategoryResult mandantoryDetailCategoryResult = mandatoryMajorManager.createDetailCategoryResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Set;

import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception.MajorExceptionHandler;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;
Expand All @@ -16,7 +15,9 @@
@RequiredArgsConstructor
public class MandatoryMajorManager {

private final List<MajorExceptionHandler> majorExceptionHandlers;
private static final String MANDATORY_MAJOR_NAME = "전공필수";

private final List<MandatoryMajorSpecialCaseHandler> mandatoryMajorSpecialCaseHandlers;

public DetailCategoryResult createDetailCategoryResult(User user, TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures,
Expand All @@ -26,11 +27,12 @@ public DetailCategoryResult createDetailCategoryResult(User user, TakenLectureIn
boolean isSatisfiedMandatory = true;
int removeMandatoryTotalCredit = 0;

for (MajorExceptionHandler majorExceptionHandler : majorExceptionHandlers) {
if (majorExceptionHandler.isSupport(user, majorGraduationCategory)) {
isSatisfiedMandatory = majorExceptionHandler.checkMandatoryCondition(takenLectureInventory,
mandatoryLectures, electiveLectures);
removeMandatoryTotalCredit = majorExceptionHandler.getRemovedMandatoryTotalCredit();
for (MandatoryMajorSpecialCaseHandler mandatoryMajorSpecialCaseHandler : mandatoryMajorSpecialCaseHandlers) {
if (mandatoryMajorSpecialCaseHandler.isSupport(user, majorGraduationCategory)) {
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = mandatoryMajorSpecialCaseHandler.getMandatorySpecialCaseInformation(
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
isSatisfiedMandatory = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
removeMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();
}
}

Expand All @@ -40,7 +42,7 @@ public DetailCategoryResult createDetailCategoryResult(User user, TakenLectureIn
finishedTakenLecture.add(takenLecture);
takenMandatory.add(takenLecture.getLecture());
});
DetailCategoryResult majorMandatoryResult = DetailCategoryResult.create("전공필수", isSatisfiedMandatory,
DetailCategoryResult majorMandatoryResult = DetailCategoryResult.create(MANDATORY_MAJOR_NAME, isSatisfiedMandatory,
calculateTotalCredit(takenMandatory, mandatoryLectures, removeMandatoryTotalCredit));
majorMandatoryResult.calculate(takenMandatory, mandatoryLectures);
takenLectureInventory.handleFinishedTakenLectures(finishedTakenLecture);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception;
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import java.util.Set;

import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory;

public interface MajorExceptionHandler {
public interface MandatoryMajorSpecialCaseHandler {
boolean isSupport(User user, MajorGraduationCategory majorGraduationCategory);

boolean checkMandatoryCondition(TakenLectureInventory takenLectureInventory,
MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
User user, MajorGraduationCategory majorGraduationCategory, TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures);

int getRemovedMandatoryTotalCredit();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@Builder
@RequiredArgsConstructor
public class MandatorySpecialCaseInformation {

private final boolean isCompleteMandatorySpecialCase;

private final int removedMandatoryTotalCredit;

public static MandatorySpecialCaseInformation of(boolean completeMandatorySpecialCase, int removedMandatoryTotalCredit) {
return MandatorySpecialCaseInformation.builder()
.isCompleteMandatorySpecialCase(completeMandatorySpecialCase)
.removedMandatoryTotalCredit(removedMandatoryTotalCredit)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception;
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import java.util.Arrays;
import java.util.Objects;
Expand All @@ -20,19 +20,12 @@ public enum OptionalMandatory {
Lecture.of("HBA01113", "비영리조직", 3, 0, null),
Lecture.of("HBA01222", "커뮤니티개발연구", 3, 0, null)
)),
// 기존 OptionalMandatory
// BUSINESS("경영학과", 4, Set.of(
// Lecture.of("HBX01104", "회계원리", 3, 0, null),
// Lecture.of("HBX01113", "인적자원관리", 3, 0, null),
// Lecture.of("HBX01106", "마케팅원론", 3, 0, null),
// Lecture.of("HBX01105", "재무관리원론", 3, 0, null),
// Lecture.of("HBX01114", "생산운영관리", 3, 1, null),
// Lecture.of("HBX01143", "운영관리", 3, 0, null)

BUSINESS("경영학과", 1, Set.of(
Lecture.of("HBW01201", "국제통산원론", 3, 0, "HBW01201"),
Lecture.of("HBX01127", "국제경영학", 3, 0, "CE224"),
Lecture.of("HBX01125", "경영정보", 3, 0, "KMJ01116"),
Lecture.of("HBY01103", "경영정보", 3, 1, "KMJ01116")
Lecture.of("HBX01128", "국제통상원론", 3, 0, null),
Lecture.of("HBX01127", "국제경영학", 3, 0, null),
Lecture.of("HBX01125", "경영정보", 3, 0, null),
Lecture.of("HBY01103", "경영정보", 3, 1, null)
)),
INTERNATIONAL_TRADE("국제통상학과", 4, Set.of(
Lecture.of("HBX01104", "회계원리", 3, 0, null),
Expand All @@ -59,15 +52,15 @@ public static OptionalMandatory from(String major) {
.orElseThrow(() -> new IllegalArgumentException("해당 전공선택필수를 찾을 수 없습니다."));
}

public int getTotalOptionalMandatoryCredit(OptionalMandatory optionalMandatory) {
return optionalMandatory.optionalMandatoryLectures.stream()
public int getTotalOptionalMandatoryCredit() {
return optionalMandatoryLectures.stream()
.filter(lecture -> lecture.getIsRevoked() == 0)
.mapToInt(Lecture::getCredit)
.sum();
}

public int getChooseLectureCredit(OptionalMandatory optionalMandatory) {
return optionalMandatory.chooseNumber * 3;
public int getChooseLectureCredit() {
return chooseNumber * 3;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception;
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import static com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory.DUAL;
import static com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory.PRIMARY;
Expand All @@ -8,65 +8,72 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

public class OptionalMandatoryHandler implements MajorExceptionHandler {
/**
* N택 M의 선택과목이 있는 경우 처리하는 핸들러 클래스
* 국제통상의 경우 회계원리, 마케팅원론, 재무관리 원론, 인적자원관리, 생산운영관리(폐지), 운영관리(구, 생산운영관리) 5개 중 4개 선택
* 경영정보의 경우 인적자원관리, 마켓팅원론, 재무관리원론에서 ~18학번까지는 3개 모두 이수, 19학번 이후 택 2
* 경영의 경우 국제통상원론, 국제경양, 경영정보 중 택1
* 행정의
*/
public class OptionalMandatoryMandatoryMajorHandler implements MandatoryMajorSpecialCaseHandler {

private static final String MANAGEMENT_INFORMATION = "경영정보학과";
private static final String BUSINESS = "경영학과";
private static final String ADMINISTRATIONS = "행정학과";
private static final String INTERNATIONAL_TRADE = "국제통상학과";
private static final int CLASS_OF_17 = 17;
private static final int CLASS_OF_19 = 19;
private int removedMandatoryTotalCredit = 0;
private OptionalMandatory optionalMandatory;

public boolean isSupport(User user, MajorGraduationCategory majorGraduationCategory) {
String calculatingMajor = getCalculatingMajor(user, majorGraduationCategory);
if (calculatingMajor.equals(MANAGEMENT_INFORMATION) && user.getEntryYear() >= CLASS_OF_19) {
this.optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
return true;
}
if (calculatingMajor.equals(ADMINISTRATIONS) && user.getEntryYear() >= CLASS_OF_17) {
this.optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
return true;
}
if (List.of(BUSINESS, INTERNATIONAL_TRADE).contains(calculatingMajor)) {
this.optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
return true;
}
return false;
return List.of(BUSINESS, INTERNATIONAL_TRADE).contains(calculatingMajor);
}

@Override
public boolean checkMandatoryCondition(TakenLectureInventory takenLectureInventory,
public MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
User user, MajorGraduationCategory majorGraduationCategory, TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
boolean checkMandatoryCondition = checkCompleteOptionalMandatory(takenLectureInventory, mandatoryLectures,
electiveLectures);

if (!checkMandatoryCondition) {
removedMandatoryTotalCredit = optionalMandatory.getTotalOptionalMandatoryCredit(optionalMandatory)
- optionalMandatory.getChooseLectureCredit(optionalMandatory);
}
return checkMandatoryCondition;
}
OptionalMandatory optionalMandatory = OptionalMandatory.from(getCalculatingMajor(user, majorGraduationCategory));
int removedMandatoryTotalCredit = 0;
boolean isCompletedMandatorySpecialCase = checkCompleteOptionalMandatory(takenLectureInventory, mandatoryLectures,
electiveLectures, optionalMandatory);

@Override
public int getRemovedMandatoryTotalCredit() {
return removedMandatoryTotalCredit;
if (!isCompletedMandatorySpecialCase ) {
removedMandatoryTotalCredit = optionalMandatory.getTotalOptionalMandatoryCredit()
- optionalMandatory.getChooseLectureCredit();
}
return MandatorySpecialCaseInformation.of(isCompletedMandatorySpecialCase , removedMandatoryTotalCredit);
}

private boolean checkCompleteOptionalMandatory(TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures, OptionalMandatory optionalMandatory) {
int chooseNum = optionalMandatory.getChooseNumber();
//전공과목Set에서 전공필수과목에 해당되는 과목들을 추출한다.
/*
* 전공과목 Set 에서 전공선택필수과목에 해당되는 과목들을 추출한다.
*/

Set<Lecture> optionalMandatoryLectures = mandatoryLectures.stream().filter(
optionalMandatory.getOptionalMandatoryLectures()::contains).collect(Collectors.toSet());

/*
remainingMandatoryLectures에 모든 전공선택필수 과목을 넣고 수강했을 시 제거한다.
최종적으로 전공선택필수 과목들 목록에서 사용자가 전공선택필수과목을 수강했다면 제거한다.
최종적으로 remainingMandatoryLectures에 남아있는 과목은 수강해야하는 과목들이다.
N택 M개 수강이라면 M개 이상 수강하였으면 전공필수에서 전부 제거, 전공 선택으로 이관하고 아니라면 전공필수에 그대로 남아있어야한다.
*/

Set<Lecture> remainingMandatoryLectures = new HashSet<>(optionalMandatoryLectures);
int count = 0;
for (TakenLecture takenLecture : takenLectureInventory.getTakenLectures()) {
Expand All @@ -91,4 +98,23 @@ private String getCalculatingMajor(User user, MajorGraduationCategory majorGradu
}
return user.getSubMajor();
}
/**
@Override
public boolean checkMandatoryCondition(TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
boolean checkMandatoryCondition = checkCompleteOptionalMandatory(takenLectureInventory, mandatoryLectures,
electiveLectures);
if (!checkMandatoryCondition) {
removedMandatoryTotalCredit = optionalMandatory.getTotalOptionalMandatoryCredit()
- optionalMandatory.getChooseLectureCredit();
}
return checkMandatoryCondition;
}
@Override
public int getRemovedMandatoryTotalCredit() {
return removedMandatoryTotalCredit;
}
**/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception;
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import static com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory.*;

Expand All @@ -7,14 +7,16 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.MajorGraduationCategory;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLectureInventory;

public class ReplaceMandatoryMajorHandler implements MajorExceptionHandler {
private int removedMandatoryTotalCredit = 0;
/**
* 철학과의 경우 답사1, 답사2는 폐지 되었지만 2021번 이전까지 전공필수
* '신유학의 이해' '유학사상의이해' 중 택1 이수 시 대체 인정
*/
public class ReplaceMandatoryMandatoryMajorHandler implements MandatoryMajorSpecialCaseHandler {
private static final List<Lecture> REPLACED_LECTURES = List.of(
Lecture.of("HAI01110", "답사1", 1, 1, null),
Lecture.of("HAI01111", "답사2", 1, 1, "HAI01111")
Expand All @@ -38,19 +40,15 @@ public boolean isSupport(User user, MajorGraduationCategory majorGraduationCateg
}

@Override
public boolean checkMandatoryCondition(TakenLectureInventory takenLectureInventory,
Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
boolean checkCondition = checkCompleteReplaceMandatory(takenLectureInventory, mandatoryLectures,
public MandatorySpecialCaseInformation getMandatorySpecialCaseInformation(
User user, MajorGraduationCategory majorGraduationCategory, TakenLectureInventory takenLectureInventory, Set<Lecture> mandatoryLectures, Set<Lecture> electiveLectures) {
boolean completeMandatorySpecialCase = checkCompleteReplaceMandatory(takenLectureInventory, mandatoryLectures,
electiveLectures);
if (!checkCondition) {
int removedMandatoryTotalCredit = 0;
if (!completeMandatorySpecialCase) {
removedMandatoryTotalCredit = 3;
}
return checkCondition;
}

@Override
public int getRemovedMandatoryTotalCredit() {
return removedMandatoryTotalCredit;
return MandatorySpecialCaseInformation.of(completeMandatorySpecialCase, removedMandatoryTotalCredit);
}

public boolean checkCompleteReplaceMandatory(TakenLectureInventory takenLectureInventory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

public class InternationalTradeFixture {
public static final Map<String, Lecture> mockLectureMap = LectureFixture.getMockLectureMap();


}
Loading

0 comments on commit 8349dce

Please sign in to comment.