-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 어드민 학기 생성 API 구현 #2324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: 어드민 학기 생성 API 구현 #2324
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package in.koreatech.koin.admin.semester.dto; | ||
|
|
||
| import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
|
||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
|
||
| import in.koreatech.koin.domain.timetableV3.model.Term; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Positive; | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| public record AdminTimetableSemesterCreateRequest( | ||
| @Schema(description = "연도", example = "2026", requiredMode = REQUIRED) | ||
| @NotNull(message = "연도는 필수입니다.") | ||
| @Positive(message = "연도는 양수여야 합니다.") | ||
| Integer year, | ||
|
|
||
| @Schema(description = "학기", example = "FIRST", requiredMode = REQUIRED) | ||
| @NotNull(message = "학기는 필수입니다.") | ||
| Term term | ||
| ) { | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package in.koreatech.koin.admin.semester.repository; | ||
|
|
||
| import org.springframework.data.repository.Repository; | ||
|
|
||
| import in.koreatech.koin.domain.timetable.model.Semester; | ||
| import in.koreatech.koin.domain.timetableV3.model.Term; | ||
|
|
||
| public interface AdminTimetableSemesterRepository extends Repository<Semester, Integer> { | ||
|
|
||
| boolean existsBySemesterOrYearAndTerm(String semester, Integer year, Term term); | ||
|
|
||
| Semester save(Semester semester); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package in.koreatech.koin.admin.semester.service; | ||
|
|
||
| import static in.koreatech.koin.global.code.ApiResponseCode.DUPLICATE_SEMESTER; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import in.koreatech.koin.admin.semester.dto.AdminTimetableSemesterCreateRequest; | ||
| import in.koreatech.koin.admin.semester.repository.AdminTimetableSemesterRepository; | ||
| import in.koreatech.koin.domain.timetable.model.Semester; | ||
| import in.koreatech.koin.global.exception.CustomException; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class AdminTimetableSemesterService { | ||
|
|
||
| private final AdminTimetableSemesterRepository adminTimetableSemesterRepository; | ||
|
|
||
| @Transactional | ||
| public void createSemester(AdminTimetableSemesterCreateRequest request) { | ||
| Semester semester = Semester.of(request.year(), request.term()); | ||
| validateDuplicateSemester(semester); | ||
| adminTimetableSemesterRepository.save(semester); | ||
| } | ||
|
|
||
| private void validateDuplicateSemester(Semester semester) { | ||
| if (adminTimetableSemesterRepository.existsBySemesterOrYearAndTerm( | ||
| semester.getSemester(), semester.getYear(), semester.getTerm() | ||
| )) { | ||
| throw CustomException.of(DUPLICATE_SEMESTER); | ||
|
Comment on lines
+20
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect existing exception translation for database uniqueness failures.
rg -n -C 3 -g '*.java' \
'DataIntegrityViolationException|ConstraintViolationException|DUPLICATE_SEMESTER|`@ExceptionHandler`' \
src/main/java
# Inspect schema definitions that create the semester uniqueness constraint.
rg -n -C 3 -g '*.sql' -g '*.xml' -g '*.yml' -g '*.yaml' \
'semester|unique' .Repository: BCSDLab/KOIN_API_V2 Length of output: 34901 Map the duplicate semester constraint failure to
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 50375
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 1855
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 12855
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 4197
Limit
yearso generated semester labels fit the 10-character field@Positiveaccepts10_000_000, andSemester.ofthen stores10000000-여름/10000000-겨울, whose length is 11. Store the same created label back intoSemester, so validation on the DTO is the user-visible failure point.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents