Repository navigation
[Feat/#321] 학생 앱 학사 일정 조회 API 추가 #322
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: main
Are you sure you want to change the base?
Changes from all commits
be608e9
7500e87
39f76fc
465a6cb
7008386
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,29 @@ | ||
| package kr.ac.kookmin.stream.api.app.internal.display; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import kr.ac.kookmin.stream.api.app.internal.display.request.DisplayCalendarScheduleListParams; | ||
| import kr.ac.kookmin.stream.api.app.internal.display.response.DisplayCalendarScheduleListResponse; | ||
| import kr.ac.kookmin.stream.api.common.dto.ApiResponse; | ||
| import kr.ac.kookmin.stream.api.common.openapi.ApiErrorCode; | ||
| import kr.ac.kookmin.stream.common.CommonErrorCode; | ||
| import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayErrorCode; | ||
| import org.springdoc.core.annotations.ParameterObject; | ||
|
|
||
| /** | ||
| * 학생 앱 학사 일정 API의 문서 명세. 구현은 {@link AppDisplayCalendarScheduleController}가 맡는다. | ||
| * <p> | ||
| * 운영진이 디스플레이 관리에서 등록한 학사 일정을 그대로 보여준다. 홈 주간 카드와 학사 일정 상세(한 달 달력)가 함께 쓴다. | ||
| */ | ||
| @Tag(name = "학사 일정", description = "학생 앱 학사 일정 조회") | ||
| public interface AppDisplayCalendarScheduleApi { | ||
|
|
||
| /** 학사 일정. 홈 주간 카드는 한 주, 학사 일정 상세는 달력에 보이는 범위로 조회한다. */ | ||
| @Operation(summary = "학사 일정 조회", | ||
| description = "기간이 startDate~endDate와 하루라도 겹치는 일정을 시작일, 등록 순으로 조회한다. 범위 밖에서 시작했어도 " | ||
| + "범위에 걸치면 포함한다(예: 12/21~1/15 일정은 1월 조회에도 나온다). 하루 일정은 startDate와 endDate가 같다. " | ||
| + "endDate가 startDate보다 앞서면 400이다.") | ||
| @ApiErrorCode(type = CommonErrorCode.class, codes = {"INVALID_INPUT"}) | ||
| @ApiErrorCode(type = DisplayErrorCode.class, codes = {"INVALID_DISPLAY_SCHEDULE_PERIOD"}) | ||
| ApiResponse<DisplayCalendarScheduleListResponse> getSchedules(@ParameterObject DisplayCalendarScheduleListParams params); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package kr.ac.kookmin.stream.api.app.internal.display; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import kr.ac.kookmin.stream.api.app.internal.display.request.DisplayCalendarScheduleListParams; | ||
| import kr.ac.kookmin.stream.api.app.internal.display.response.DisplayCalendarScheduleListResponse; | ||
| import kr.ac.kookmin.stream.api.common.dto.ApiResponse; | ||
| import kr.ac.kookmin.stream.internal.domain.display.service.DisplayService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.ModelAttribute; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/v1/app/calendar-schedules") | ||
| @RequiredArgsConstructor | ||
| public class AppDisplayCalendarScheduleController implements AppDisplayCalendarScheduleApi { | ||
|
|
||
| private final DisplayService displayService; | ||
|
|
||
| @Override | ||
| @GetMapping | ||
| public ApiResponse<DisplayCalendarScheduleListResponse> getSchedules( | ||
|
Member
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.
건너뛴 Testcontainers 테스트가 이번 변경을 덮는 부분은 거의 없어 보여요.
PR에서 도는 테스트 워크플로가 없으니( |
||
| @Valid @ModelAttribute DisplayCalendarScheduleListParams params | ||
| ) { | ||
| return ApiResponse.success( | ||
| DisplayCalendarScheduleListResponse.from(displayService.getSchedules(params.toPeriod()))); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package kr.ac.kookmin.stream.api.app.internal.display.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import java.time.LocalDate; | ||
| import kr.ac.kookmin.stream.internal.domain.display.domain.DisplaySchedulePeriod; | ||
| import org.springframework.format.annotation.DateTimeFormat; | ||
|
|
||
| public record DisplayCalendarScheduleListParams( | ||
|
|
||
| @Schema(description = "조회 시작일. 기간이 startDate~endDate와 하루라도 겹치는 일정을 조회한다", example = "2026-11-01") | ||
| @NotNull(message = "조회 시작일을 입력해 주세요.") | ||
| @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) | ||
| LocalDate startDate, | ||
|
|
||
| @Schema(description = "조회 종료일. 시작일과 같거나 이후여야 한다", example = "2026-12-05") | ||
| @NotNull(message = "조회 종료일을 입력해 주세요.") | ||
| @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) | ||
| LocalDate endDate | ||
| ) { | ||
|
|
||
| public DisplaySchedulePeriod toPeriod() { | ||
| return DisplaySchedulePeriod.of(startDate, endDate); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package kr.ac.kookmin.stream.api.app.internal.display.response; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarSchedule; | ||
|
|
||
| public record DisplayCalendarScheduleListResponse(List<Schedule> schedules) { | ||
|
|
||
| public static DisplayCalendarScheduleListResponse from(List<DisplayCalendarSchedule> schedules) { | ||
| return new DisplayCalendarScheduleListResponse(schedules.stream() | ||
| .map(Schedule::from) | ||
| .toList()); | ||
| } | ||
|
|
||
| // 하루 일정은 startDate와 endDate가 같다 | ||
| public record Schedule(Long scheduleId, String title, LocalDate startDate, LocalDate endDate) { | ||
|
|
||
| public static Schedule from(DisplayCalendarSchedule schedule) { | ||
| return new Schedule(schedule.getId(), schedule.getTitle(), schedule.getStartDate(), schedule.getEndDate()); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| package kr.ac.kookmin.stream.internal.domain.display.domain; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| // 학사 일정 등록 요청. 하루 일정은 시작일과 종료일이 같다. | ||
| public record DisplayCalendarScheduleCreateCommand(String title, LocalDate startDate, LocalDate endDate) { | ||
| public record DisplayCalendarScheduleCreateCommand(String title, DisplaySchedulePeriod period) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| package kr.ac.kookmin.stream.internal.domain.display.domain; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| // 학사 일정 수정 요청. 일정명과 기간을 모두 받아 통째로 바꾼다. | ||
| public record DisplayCalendarScheduleUpdateCommand(String title, LocalDate startDate, LocalDate endDate) { | ||
| public record DisplayCalendarScheduleUpdateCommand(String title, DisplaySchedulePeriod period) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package kr.ac.kookmin.stream.internal.domain.display.domain; | ||
|
|
||
| import java.time.LocalDate; | ||
| import kr.ac.kookmin.stream.common.BusinessException; | ||
|
|
||
| /** | ||
| * 시작일~종료일(양끝 포함)로 이루어진 날짜 기간. 학사 일정의 기간과 학사 일정 조회 범위에 함께 쓴다. | ||
| * <p> | ||
| * 종료일이 시작일보다 앞서면 안 된다는 순서는 이 값 자체의 불변식이라 {@link #of}에서 검증한다. 시작일과 종료일이 같은 | ||
| * 하루 기간은 허용한다. DB에서 복원할 때는 저장 전에 검증을 거친 값이라 표준 생성자로 만든다. | ||
| */ | ||
| public record DisplaySchedulePeriod(LocalDate startDate, LocalDate endDate) { | ||
|
|
||
| public static DisplaySchedulePeriod of(LocalDate startDate, LocalDate endDate) { | ||
|
Member
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.
이번 PR에는 없어도 괜찮아 보여요. 검증이
|
||
| validateOrder(startDate, endDate); | ||
| return new DisplaySchedulePeriod(startDate, endDate); | ||
| } | ||
|
|
||
| // 시작일·종료일 당일도 기간에 든다 | ||
| public boolean includes(LocalDate date) { | ||
| return !date.isBefore(startDate) && !date.isAfter(endDate); | ||
| } | ||
|
|
||
| private static void validateOrder(LocalDate startDate, LocalDate endDate) { | ||
| if (endDate.isBefore(startDate)) { | ||
| throw new BusinessException(DisplayErrorCode.INVALID_DISPLAY_SCHEDULE_PERIOD); | ||
| } | ||
| } | ||
| } | ||
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.
[a]리뷰 포인트 주신 경로와 클래스 이름에 대한 의견이에요.지금처럼 두는 게 좋아 보여요. 같은
internal아래의AppConfigController도 클래스 이름은 도메인(config)을 따르고 경로는 앱에서 보이는 의미(/v1/app/service-links)를 따라서, 이번AppDisplayCalendarSchedule...+/v1/app/calendar-schedules와 같은 방식이에요. 클래스가display패키지에 디스플레이 화면·관리자 API와 함께 모여 있어 코드에서 찾기도 쉬울 것 같아요.