Skip to content

Commit

Permalink
[REFACTOR] 교양과목 영역 할당 로직 리팩토링 (#192)
Browse files Browse the repository at this point in the history
refactor: 교양과목 영역 할당 로직 리팩토링 (#191)
  • Loading branch information
hyunmin0317 authored Feb 1, 2025
1 parent 7b4e210 commit 9c8a85b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.json.JSONObject;

import java.util.List;
import java.util.Objects;
import java.util.stream.IntStream;

@Builder
Expand Down Expand Up @@ -37,15 +36,11 @@ private static AuthCourseResponseDto from(JSONObject obj) {
.grade(obj.getString("GRD_NM"))
.year(obj.getString("SCH_YEAR"))
.semester(obj.getString("SMT_NM"))
.domain(getDomain(obj.getString("CULT_ARA_NM")))
.domain(obj.getString("CULT_ARA_NM"))
.credit(obj.getInt("CDT"))
.build();
}

private static String getDomain(String domain) {
return !Objects.equals(domain, "*") ? domain : null;
}

public Course toEntity(boolean isNewCurriculum) {
return Course.builder()
.name(name)
Expand All @@ -55,7 +50,7 @@ public Course toEntity(boolean isNewCurriculum) {
.type(type)
.domain(domain)
.category(Category.of(type))
.subDomain(domain != null ? SubDomain.of(domain, isNewCurriculum) : null)
.subDomain(SubDomain.of(domain, isNewCurriculum))
.credit(credit)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean isNaturalOrEngineer() {

public static SubDomain of(String name, boolean isNewCurriculum) {
SubDomain subDomain = hasEngMath(name) ? BASIC_ENG_MATH : findByName(name);
return isNewCurriculum && subDomain.isNaturalOrEngineer() ? BALANCE_NATURAL_ENGINEER : subDomain;
return isNewCurriculum && subDomain != null && subDomain.isNaturalOrEngineer() ? BALANCE_NATURAL_ENGINEER : subDomain;
}

private static SubDomain findByName(String name) {
Expand Down

0 comments on commit 9c8a85b

Please sign in to comment.