From 1ccbbcc57b2134ef0f8623734b93a5374c7b4847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9B=90=EA=B2=BD?= Date: Sat, 21 Dec 2024 16:18:58 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20model=20v3=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../koin/domain/timetable/model/Semester.java | 5 +++-- .../dto/response/SemesterCheckResponseV3.java | 12 ++++++------ .../dto/response/SemesterResponseV3.java | 16 ++++------------ .../repository/SemesterRepositoryV3.java | 8 ++++---- .../repository/TimetableFrameRepositoryV3.java | 6 +++--- .../timetableV3/service/SemesterServiceV3.java | 16 ++++++++-------- 6 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/main/java/in/koreatech/koin/domain/timetable/model/Semester.java b/src/main/java/in/koreatech/koin/domain/timetable/model/Semester.java index 326ac009f..ef9dc1eee 100644 --- a/src/main/java/in/koreatech/koin/domain/timetable/model/Semester.java +++ b/src/main/java/in/koreatech/koin/domain/timetable/model/Semester.java @@ -40,13 +40,14 @@ public class Semester { @Column(name = "year", nullable = false) private Integer year; - @Size(max = 20) @Enumerated(EnumType.STRING) @Column(name = "term", nullable = false, length = 20) private Term term; @Builder - public Semester(String semester) { + public Semester(String semester, Integer year, Term term) { this.semester = semester; + this.year = year; + this.term = term; } } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterCheckResponseV3.java b/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterCheckResponseV3.java index c4ff8f7ea..2cd239a05 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterCheckResponseV3.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterCheckResponseV3.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import in.koreatech.koin.domain.timetableV3.model.SemesterV3; +import in.koreatech.koin.domain.timetable.model.Semester; import io.swagger.v3.oas.annotations.media.Schema; @JsonNaming(value = SnakeCaseStrategy.class) @@ -26,18 +26,18 @@ public record InnerSemesterCheckResponse( @Schema(description = "term", example = "1학기", requiredMode = REQUIRED) String term ) { - public static InnerSemesterCheckResponse of(SemesterV3 semesterV3) { + public static InnerSemesterCheckResponse of(Semester semester) { return new InnerSemesterCheckResponse( - semesterV3.getYear(), - semesterV3.getTerm().getDescription() + semester.getYear(), + semester.getTerm().getDescription() ); } } - public static SemesterCheckResponseV3 of(Integer userId, List semesterV3s) { + public static SemesterCheckResponseV3 of(Integer userId, List semester) { return new SemesterCheckResponseV3( userId, - semesterV3s.stream() + semester.stream() .map(InnerSemesterCheckResponse::of) .toList() ); diff --git a/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterResponseV3.java b/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterResponseV3.java index 90b0fce42..1bdc3bbef 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterResponseV3.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterResponseV3.java @@ -5,29 +5,21 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import in.koreatech.koin.domain.timetableV3.model.SemesterV3; +import in.koreatech.koin.domain.timetable.model.Semester; import io.swagger.v3.oas.annotations.media.Schema; @JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class) public record SemesterResponseV3( - @Schema(description = "id", example = "1", requiredMode = REQUIRED) - Integer id, - - @Schema(description = "학기", example = "20241", requiredMode = REQUIRED) - String semester, - @Schema(description = "year", example = "2024", requiredMode = REQUIRED) Integer year, @Schema(description = "term", example = "1학기", requiredMode = REQUIRED) String term ) { - public static SemesterResponseV3 from(SemesterV3 semesterV3) { + public static SemesterResponseV3 of(Semester semester) { return new SemesterResponseV3( - semesterV3.getId(), - semesterV3.getSemester(), - semesterV3.getYear(), - semesterV3.getTerm().getDescription() + semester.getYear(), + semester.getTerm().getDescription() ); } } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV3/repository/SemesterRepositoryV3.java b/src/main/java/in/koreatech/koin/domain/timetableV3/repository/SemesterRepositoryV3.java index 60a9cc86c..dd8454dae 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV3/repository/SemesterRepositoryV3.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV3/repository/SemesterRepositoryV3.java @@ -4,11 +4,11 @@ import org.springframework.data.repository.Repository; -import in.koreatech.koin.domain.timetableV3.model.SemesterV3; +import in.koreatech.koin.domain.timetable.model.Semester; -public interface SemesterRepositoryV3 extends Repository { +public interface SemesterRepositoryV3 extends Repository { - List findAll(); + List findAll(); - SemesterV3 save(SemesterV3 semesterV3); + Semester save(Semester semester); } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV3/repository/TimetableFrameRepositoryV3.java b/src/main/java/in/koreatech/koin/domain/timetableV3/repository/TimetableFrameRepositoryV3.java index 60efc61e9..c860bd18f 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV3/repository/TimetableFrameRepositoryV3.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV3/repository/TimetableFrameRepositoryV3.java @@ -4,9 +4,9 @@ import java.util.List; -import in.koreatech.koin.domain.timetableV3.model.TimetableFrameV3; +import in.koreatech.koin.domain.timetableV2.model.TimetableFrame; -public interface TimetableFrameRepositoryV3 extends Repository { +public interface TimetableFrameRepositoryV3 extends Repository { - List findByUserIdAndIsMainTrue(Integer userId); + List findByUserIdAndIsMainTrue(Integer userId); } diff --git a/src/main/java/in/koreatech/koin/domain/timetableV3/service/SemesterServiceV3.java b/src/main/java/in/koreatech/koin/domain/timetableV3/service/SemesterServiceV3.java index ea869a050..f342cbb62 100644 --- a/src/main/java/in/koreatech/koin/domain/timetableV3/service/SemesterServiceV3.java +++ b/src/main/java/in/koreatech/koin/domain/timetableV3/service/SemesterServiceV3.java @@ -6,9 +6,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import in.koreatech.koin.domain.timetable.model.Semester; +import in.koreatech.koin.domain.timetableV2.model.TimetableFrame; import in.koreatech.koin.domain.timetableV3.dto.response.SemesterCheckResponseV3; -import in.koreatech.koin.domain.timetableV3.model.SemesterV3; -import in.koreatech.koin.domain.timetableV3.model.TimetableFrameV3; import in.koreatech.koin.domain.timetableV3.dto.response.SemesterResponseV3; import in.koreatech.koin.domain.timetableV3.repository.SemesterRepositoryV3; import in.koreatech.koin.domain.timetableV3.repository.TimetableFrameRepositoryV3; @@ -24,19 +24,19 @@ public class SemesterServiceV3 { public List getSemesters() { return semesterRepository.findAll().stream() - .sorted(Comparator.comparing(SemesterV3::getYear).reversed() + .sorted(Comparator.comparing(Semester::getYear).reversed() .thenComparing(semester -> semester.getTerm().getPriority())) - .map(SemesterResponseV3::from) + .map(SemesterResponseV3::of) .toList(); } public SemesterCheckResponseV3 getStudentSemesters(Integer userId) { - List semesterV3s = timetableFrameRepository.findByUserIdAndIsMainTrue(userId).stream() - .map(TimetableFrameV3::getSemesterV3) + List semesters = timetableFrameRepository.findByUserIdAndIsMainTrue(userId).stream() + .map(TimetableFrame::getSemester) .distinct() - .sorted(Comparator.comparing(SemesterV3::getYear).reversed() + .sorted(Comparator.comparing(Semester::getYear).reversed() .thenComparing(semester -> semester.getTerm().getPriority())) .toList(); - return SemesterCheckResponseV3.of(userId, semesterV3s); + return SemesterCheckResponseV3.of(userId, semesters); } }