Skip to content

Commit

Permalink
fix : model v3 관련 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
김원경 committed Dec 21, 2024
1 parent 0a2a7eb commit 1ccbbcc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<SemesterV3> semesterV3s) {
public static SemesterCheckResponseV3 of(Integer userId, List<Semester> semester) {
return new SemesterCheckResponseV3(
userId,
semesterV3s.stream()
semester.stream()
.map(InnerSemesterCheckResponse::of)
.toList()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<SemesterV3, Integer> {
public interface SemesterRepositoryV3 extends Repository<Semester, Integer> {

List<SemesterV3> findAll();
List<Semester> findAll();

SemesterV3 save(SemesterV3 semesterV3);
Semester save(Semester semester);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<TimetableFrameV3, Integer> {
public interface TimetableFrameRepositoryV3 extends Repository<TimetableFrame, Integer> {

List<TimetableFrameV3> findByUserIdAndIsMainTrue(Integer userId);
List<TimetableFrame> findByUserIdAndIsMainTrue(Integer userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,19 +24,19 @@ public class SemesterServiceV3 {

public List<SemesterResponseV3> 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<SemesterV3> semesterV3s = timetableFrameRepository.findByUserIdAndIsMainTrue(userId).stream()
.map(TimetableFrameV3::getSemesterV3)
List<Semester> 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);
}
}

0 comments on commit 1ccbbcc

Please sign in to comment.