Skip to content

Commit

Permalink
[FEATURE] 2024학번 균형교양 영역 수정 (#190)
Browse files Browse the repository at this point in the history
fix: 2024학번 균형교양 영역 수정 (#189)
  • Loading branch information
hyunmin0317 authored Feb 1, 2025
1 parent 041b4a9 commit 7b4e210
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static String getDomain(String domain) {
return !Objects.equals(domain, "*") ? domain : null;
}

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

private Course toCourse(AuthCourseResponseDto dto, Member member) {
Course course = dto.toEntity();
Course course = dto.toEntity(member.isNewCurriculum());
course.setMember(member);
return course;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.ArrayList;
import java.util.List;

import static com.smunity.server.global.common.entity.enums.SubDomain.*;
import static com.smunity.server.global.common.entity.enums.SubDomain.BALANCE_NATURAL_ENGINEER;

@Entity
@Getter
Expand Down Expand Up @@ -126,12 +126,16 @@ public List<String> getCompletedNumbers() {

public SubDomain getSubDomain() {
SubDomain subDomain = department.getSubDomain();
return year.getValue() >= 2024 && (subDomain.equals(BALANCE_NATURAL) || subDomain.equals(BALANCE_ENGINEER)) ? BALANCE_NATURAL_ENGINEER : subDomain;
return isNewCurriculum() && subDomain.isNaturalOrEngineer() ? BALANCE_NATURAL_ENGINEER : subDomain;
}

public boolean checkCompleted(SubDomain subDomain) {
return courses.stream()
.map(Course::getSubDomain)
.anyMatch(subDomain::equals);
}

public boolean isNewCurriculum() {
return year.getValue() >= 2024;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ public enum SubDomain {

private final String name;

public static SubDomain of(String name) {
return hasEngMath(name) ? BASIC_ENG_MATH : findByName(name);
public boolean isNaturalOrEngineer() {
return equals(BALANCE_NATURAL) || equals(BALANCE_ENGINEER);
}

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;
}

private static SubDomain findByName(String name) {
Expand Down

0 comments on commit 7b4e210

Please sign in to comment.