-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: flyway 추가 * feat: 기존 필드 수정 * feat: Semester V3생성 * feat: Repository V3 추가 * feat: timetableLecture, frame V3 추가 * feat: semester 로직 추가 * feat: save 추가 * feat: 테스트추가 * fix : model V3 제거 * fix : model v3 관련 제거 * fix : 테스트코드 작성 * fix : 테스트 수정 * refactor: semester controller분리 * feat: flyway 수정 및 2024-겨울 추가 --------- Co-authored-by: 김원경 <[email protected]>
- Loading branch information
Showing
15 changed files
with
751 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/in/koreatech/koin/domain/timetableV3/controller/SemesterApiV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package in.koreatech.koin.domain.timetableV3.controller; | ||
|
||
import static in.koreatech.koin.domain.user.model.UserType.STUDENT; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import in.koreatech.koin.domain.timetableV3.dto.response.SemesterCheckResponseV3; | ||
import in.koreatech.koin.domain.timetableV3.dto.response.SemesterResponseV3; | ||
import in.koreatech.koin.global.auth.Auth; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@Tag(name = "(Normal) V3-Semester", description = "학기 정보를 관리한다") | ||
public interface SemesterApiV3 { | ||
@ApiResponses( | ||
value = { | ||
@ApiResponse(responseCode = "200"), | ||
@ApiResponse(responseCode = "401", content = @Content(schema = @Schema(hidden = true))), | ||
@ApiResponse(responseCode = "403", content = @Content(schema = @Schema(hidden = true))), | ||
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(hidden = true))) | ||
} | ||
) | ||
@Operation(summary = "학기 정보 조회") | ||
@GetMapping("/v3/semesters") | ||
ResponseEntity<List<SemesterResponseV3>> getSemesters(); | ||
|
||
@ApiResponses( | ||
value = { | ||
@ApiResponse(responseCode = "200"), | ||
@ApiResponse(responseCode = "401", content = @Content(schema = @Schema(hidden = true))) | ||
} | ||
) | ||
@Operation(summary = "학생 학기 정보 조회") | ||
@SecurityRequirement(name = "Jwt Authentication") | ||
@GetMapping("/v3/semesters/check") | ||
ResponseEntity<SemesterCheckResponseV3> getStudentSemesters( | ||
@Auth(permit = {STUDENT}) Integer userId | ||
); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/in/koreatech/koin/domain/timetableV3/controller/SemesterControllerV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package in.koreatech.koin.domain.timetableV3.controller; | ||
|
||
import static in.koreatech.koin.domain.user.model.UserType.STUDENT; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import in.koreatech.koin.domain.timetableV3.dto.response.SemesterCheckResponseV3; | ||
import in.koreatech.koin.domain.timetableV3.dto.response.SemesterResponseV3; | ||
import in.koreatech.koin.domain.timetableV3.service.SemesterServiceV3; | ||
import in.koreatech.koin.global.auth.Auth; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class SemesterControllerV3 { | ||
|
||
private final SemesterServiceV3 semesterServiceV3; | ||
|
||
@GetMapping("/v3/semesters") | ||
public ResponseEntity<List<SemesterResponseV3>> getSemesters() { | ||
List<SemesterResponseV3> semesterResponseV3 = semesterServiceV3.getSemesters(); | ||
return ResponseEntity.ok(semesterResponseV3); | ||
} | ||
|
||
@GetMapping("/v3/semesters/check") | ||
public ResponseEntity<SemesterCheckResponseV3> getStudentSemesters( | ||
@Auth(permit = {STUDENT}) Integer userId | ||
) { | ||
SemesterCheckResponseV3 semesterCheckResponseV3 = semesterServiceV3.getStudentSemesters(userId); | ||
return ResponseEntity.ok(semesterCheckResponseV3); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterCheckResponseV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package in.koreatech.koin.domain.timetableV3.dto.response; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import in.koreatech.koin.domain.timetable.model.Semester; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@JsonNaming(value = SnakeCaseStrategy.class) | ||
public record SemesterCheckResponseV3( | ||
@Schema(description = "유저 id", example = "1", requiredMode = REQUIRED) | ||
Integer userId, | ||
|
||
@Schema(description = "유저 학기", requiredMode = REQUIRED) | ||
List<InnerSemesterCheckResponse> semesters | ||
) { | ||
@JsonNaming(value = SnakeCaseStrategy.class) | ||
public record InnerSemesterCheckResponse( | ||
@Schema(description = "year", example = "2024", requiredMode = REQUIRED) | ||
Integer year, | ||
|
||
@Schema(description = "term", example = "1학기", requiredMode = REQUIRED) | ||
String term | ||
) { | ||
public static InnerSemesterCheckResponse of(Semester semester) { | ||
return new InnerSemesterCheckResponse( | ||
semester.getYear(), | ||
semester.getTerm().getDescription() | ||
); | ||
} | ||
} | ||
|
||
public static SemesterCheckResponseV3 of(Integer userId, List<Semester> semester) { | ||
return new SemesterCheckResponseV3( | ||
userId, | ||
semester.stream() | ||
.map(InnerSemesterCheckResponse::of) | ||
.toList() | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/in/koreatech/koin/domain/timetableV3/dto/response/SemesterResponseV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package in.koreatech.koin.domain.timetableV3.dto.response; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
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 = "year", example = "2024", requiredMode = REQUIRED) | ||
Integer year, | ||
|
||
@Schema(description = "term", example = "1학기", requiredMode = REQUIRED) | ||
String term | ||
) { | ||
public static SemesterResponseV3 of(Semester semester) { | ||
return new SemesterResponseV3( | ||
semester.getYear(), | ||
semester.getTerm().getDescription() | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/in/koreatech/koin/domain/timetableV3/model/Term.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package in.koreatech.koin.domain.timetableV3.model; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum Term { | ||
WINTER("겨울학기", 1), | ||
SECOND("2학기", 2), | ||
SUMMER("여름학기", 3), | ||
FIRST("1학기", 4); | ||
|
||
private final String description; | ||
private final int priority; | ||
|
||
Term(String description, int priority) { | ||
this.description = description; | ||
this.priority = priority; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/in/koreatech/koin/domain/timetableV3/repository/SemesterRepositoryV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package in.koreatech.koin.domain.timetableV3.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.repository.Repository; | ||
|
||
import in.koreatech.koin.domain.timetable.model.Semester; | ||
|
||
public interface SemesterRepositoryV3 extends Repository<Semester, Integer> { | ||
|
||
List<Semester> findAll(); | ||
|
||
Semester save(Semester semester); | ||
} |
12 changes: 12 additions & 0 deletions
12
...main/java/in/koreatech/koin/domain/timetableV3/repository/TimetableFrameRepositoryV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package in.koreatech.koin.domain.timetableV3.repository; | ||
|
||
import org.springframework.data.repository.Repository; | ||
|
||
import java.util.List; | ||
|
||
import in.koreatech.koin.domain.timetableV2.model.TimetableFrame; | ||
|
||
public interface TimetableFrameRepositoryV3 extends Repository<TimetableFrame, Integer> { | ||
|
||
List<TimetableFrame> findByUserIdAndIsMainTrue(Integer userId); | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/in/koreatech/koin/domain/timetableV3/service/SemesterServiceV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package in.koreatech.koin.domain.timetableV3.service; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
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.dto.response.SemesterResponseV3; | ||
import in.koreatech.koin.domain.timetableV3.repository.SemesterRepositoryV3; | ||
import in.koreatech.koin.domain.timetableV3.repository.TimetableFrameRepositoryV3; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class SemesterServiceV3 { | ||
|
||
private final TimetableFrameRepositoryV3 timetableFrameRepository; | ||
private final SemesterRepositoryV3 semesterRepository; | ||
|
||
public List<SemesterResponseV3> getSemesters() { | ||
return semesterRepository.findAll().stream() | ||
.sorted(Comparator.comparing(Semester::getYear).reversed() | ||
.thenComparing(semester -> semester.getTerm().getPriority())) | ||
.map(SemesterResponseV3::of) | ||
.toList(); | ||
} | ||
|
||
public SemesterCheckResponseV3 getStudentSemesters(Integer userId) { | ||
List<Semester> semesters = timetableFrameRepository.findByUserIdAndIsMainTrue(userId).stream() | ||
.map(TimetableFrame::getSemester) | ||
.distinct() | ||
.sorted(Comparator.comparing(Semester::getYear).reversed() | ||
.thenComparing(semester -> semester.getTerm().getPriority())) | ||
.toList(); | ||
return SemesterCheckResponseV3.of(userId, semesters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
alter table semester | ||
add column year int unsigned, | ||
add column term varchar(20); | ||
|
||
update semester set year = 2019, term = 'SECOND' where semester = '20192'; | ||
update semester set year = 2019, term = 'SUMMER' where semester = '2019-여름'; | ||
update semester set year = 2019, term = 'WINTER' where semester = '2019-겨울'; | ||
update semester set year = 2020, term = 'FIRST' where semester = '20201'; | ||
update semester set year = 2020, term = 'SECOND' where semester = '20202'; | ||
update semester set year = 2020, term = 'SUMMER' where semester = '2020-여름'; | ||
update semester set year = 2020, term = 'WINTER' where semester = '2020-겨울'; | ||
update semester set year = 2021, term = 'FIRST' where semester = '20211'; | ||
update semester set year = 2021, term = 'SECOND' where semester = '20212'; | ||
update semester set year = 2021, term = 'SUMMER' where semester = '2021-여름'; | ||
update semester set year = 2021, term = 'WINTER' where semester = '2021-겨울'; | ||
update semester set year = 2022, term = 'FIRST' where semester = '20221'; | ||
update semester set year = 2022, term = 'SECOND' where semester = '20222'; | ||
update semester set year = 2022, term = 'SUMMER' where semester = '2022-여름'; | ||
update semester set year = 2022, term = 'WINTER' where semester = '2022-겨울'; | ||
update semester set year = 2023, term = 'FIRST' where semester = '20231'; | ||
update semester set year = 2023, term = 'SECOND' where semester = '20232'; | ||
update semester set year = 2023, term = 'SUMMER' where semester = '2023-여름'; | ||
update semester set year = 2023, term = 'WINTER' where semester = '2023-겨울'; | ||
update semester set year = 2024, term = 'FIRST' where semester = '20241'; | ||
update semester set year = 2024, term = 'SECOND' where semester = '20242'; | ||
update semester set year = 2024, term = 'SUMMER' where semester = '2024-여름'; | ||
update semester set year = 2024, term = 'WINTER' where semester = '2024-겨울'; | ||
|
||
ALTER TABLE semester | ||
MODIFY COLUMN year INT UNSIGNED NOT NULL, | ||
MODIFY COLUMN term VARCHAR(20) NOT NULL; |
Oops, something went wrong.