Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import kr.ac.kookmin.stream.api.common.dto.ApiResponse;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarSchedule;
import kr.ac.kookmin.stream.internal.domain.display.service.AdminDisplayCalendarScheduleService;
import kr.ac.kookmin.stream.internal.domain.display.service.DisplayService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -28,15 +29,16 @@
public class AdminDisplayCalendarScheduleController implements AdminDisplayCalendarScheduleApi {

private final AdminDisplayCalendarScheduleService adminDisplayCalendarScheduleService;
private final DisplayService displayService;

@Override
@GetMapping
public ApiResponse<DisplayCalendarScheduleListResponse> getSchedules(
AdminApiUser apiUser,
@Valid @ModelAttribute DisplayCalendarScheduleListParams params
) {
return ApiResponse.success(DisplayCalendarScheduleListResponse.from(
adminDisplayCalendarScheduleService.getSchedules(params.startDate(), params.endDate())));
return ApiResponse.success(
DisplayCalendarScheduleListResponse.from(displayService.getSchedules(params.toPeriod())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarScheduleCreateCommand;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplaySchedulePeriod;

public record DisplayCalendarScheduleCreateRequest(
@Schema(description = "일정명", example = "학생회 간담회")
Expand All @@ -23,6 +24,6 @@ public record DisplayCalendarScheduleCreateRequest(
) {

public DisplayCalendarScheduleCreateCommand toCommand() {
return new DisplayCalendarScheduleCreateCommand(title, startDate, endDate);
return new DisplayCalendarScheduleCreateCommand(title, DisplaySchedulePeriod.of(startDate, endDate));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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(
Expand All @@ -17,4 +18,10 @@ public record DisplayCalendarScheduleListParams(
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
LocalDate endDate
) {

// 시작일·종료일이 뒤바뀐 요청(예: 10/31~10/1)은 일정 기간과 같은 에러로 거절한다.
// 그대로 조회하면 겹침 조건이 뒤집혀 범위 전체를 덮는 일정만 걸려 나온다
public DisplaySchedulePeriod toPeriod() {
return DisplaySchedulePeriod.of(startDate, endDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarScheduleUpdateCommand;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplaySchedulePeriod;

public record DisplayCalendarScheduleUpdateRequest(
@Schema(description = "일정명", example = "학생회 간담회")
Expand All @@ -23,6 +24,6 @@ public record DisplayCalendarScheduleUpdateRequest(
) {

public DisplayCalendarScheduleUpdateCommand toCommand() {
return new DisplayCalendarScheduleUpdateCommand(title, startDate, endDate);
return new DisplayCalendarScheduleUpdateCommand(title, DisplaySchedulePeriod.of(startDate, endDate));
}
}
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")

Copy link
Copy Markdown
Member

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와 함께 모여 있어 코드에서 찾기도 쉬울 것 같아요.

@RequiredArgsConstructor
public class AppDisplayCalendarScheduleController implements AppDisplayCalendarScheduleApi {

private final DisplayService displayService;

@Override
@GetMapping
public ApiResponse<DisplayCalendarScheduleListResponse> getSchedules(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[a] 리뷰 포인트 주신 검증 범위에 대한 의견이에요.

건너뛴 Testcontainers 테스트가 이번 변경을 덮는 부분은 거의 없어 보여요.

  • 테스트 소스에 display 쪽 테스트가 없어서(domain.display·calendar-schedules로 찾아봤어요), 건너뛴 RentalApplyConcurrencyTest·ItemOptimisticLockTest가 이번 코드를 직접 부르지는 않아요
  • JPA 쿼리 DisplayCalendarScheduleJpaRepository.findAllOverlapping은 그대로이고 어댑터가 VO를 풀어 넘기기만 해서, DB 쪽 동작은 main과 같아요
  • 전체 컨텍스트를 띄우는 RentalApplyConcurrencyTest가 이번 변경에서 잡아 줄 수 있는 건 빈 주입·경로 중복 정도인데, DisplayService 구현체는 DisplayServiceImpl 하나이고 /v1/app/calendar-schedules 매핑도 이 컨트롤러뿐이라 문제없어 보여요
  • 바인딩은 main에서 쓰던 관리자 DisplayCalendarScheduleListParams와 같은 모양(@NotNull + @DateTimeFormat(iso = DATE))이고, 인증은 SecurityConfig.java:45에서 /v1/app/**에 STUDENT 권한을 요구해 다른 앱 API와 같아요

PR에서 도는 테스트 워크플로가 없으니(review-assign.yml만 있어요), 머지 후 dev에 배포되면 Swagger에서 앱 경로를 한 번 불러 보시면 충분할 것 같아요.

@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,6 @@
package kr.ac.kookmin.stream.internal.domain.display.domain;

import java.time.LocalDate;
import kr.ac.kookmin.stream.common.BusinessException;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
Expand All @@ -14,34 +13,31 @@ public class DisplayCalendarSchedule {

private Long id;
private String title;
private LocalDate startDate;
private LocalDate endDate;
private DisplaySchedulePeriod period;

public static DisplayCalendarSchedule create(DisplayCalendarScheduleCreateCommand command) {
validatePeriod(command.startDate(), command.endDate());
return new DisplayCalendarSchedule(null, command.title(), command.startDate(), command.endDate());
return new DisplayCalendarSchedule(null, command.title(), command.period());
}

public static DisplayCalendarSchedule of(Long id, String title, LocalDate startDate, LocalDate endDate) {
return new DisplayCalendarSchedule(id, title, startDate, endDate);
return new DisplayCalendarSchedule(id, title, new DisplaySchedulePeriod(startDate, endDate));
}

public void update(DisplayCalendarScheduleUpdateCommand command) {
validatePeriod(command.startDate(), command.endDate());
this.title = command.title();
this.startDate = command.startDate();
this.endDate = command.endDate();
this.period = command.period();
}

// 시작일·종료일 당일도 기간에 든다
public boolean includes(LocalDate date) {
return !date.isBefore(startDate) && !date.isAfter(endDate);
// 기간을 VO로 묶기 전부터 쓰던 getter다. 호출부가 VO 구조를 몰라도 되도록 남겨 둔다
public LocalDate getStartDate() {
return period.startDate();
}

public LocalDate getEndDate() {
return period.endDate();
}

// 시작일과 종료일이 같은 하루 일정은 허용한다
private static void validatePeriod(LocalDate startDate, LocalDate endDate) {
if (endDate.isBefore(startDate)) {
throw new BusinessException(DisplayErrorCode.INVALID_DISPLAY_SCHEDULE_PERIOD);
}
public boolean includes(LocalDate date) {
return period.includes(date);
}
}
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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[a] 리뷰 포인트 주신 DisplaySchedulePeriod 단위 테스트에 대한 의견이에요.

이번 PR에는 없어도 괜찮아 보여요. 검증이 validateOrder의 조건 하나뿐이고, AGENTS.md도 테스트는 요청이 있을 때만 쓰기로 정해 두었어요. 나중에 넣으신다면 같은 모양인 EventPeriodTest처럼 경계만 보면 될 것 같아요.

  • 종료일이 시작일보다 앞서면 INVALID_DISPLAY_SCHEDULE_PERIOD
  • 시작일과 종료일이 같으면 허용(EventPeriod는 같은 시각을 거부해서 여기가 달라요)
  • includes는 시작일·종료일 당일도 포함

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);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package kr.ac.kookmin.stream.internal.domain.display.repository;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarSchedule;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplaySchedulePeriod;

public interface DisplayCalendarScheduleRepository {

Optional<DisplayCalendarSchedule> findById(Long id);

// 기간이 startDate~endDate(양끝 포함)와 하루라도 겹치는 일정. 시작일 → 등록 순(id 오름차순)
List<DisplayCalendarSchedule> findAllOverlapping(LocalDate startDate, LocalDate endDate);
// 기간이 period(양끝 포함)와 하루라도 겹치는 일정. 시작일 → 등록 순(id 오름차순)
List<DisplayCalendarSchedule> findAllOverlapping(DisplaySchedulePeriod period);

DisplayCalendarSchedule save(DisplayCalendarSchedule schedule);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package kr.ac.kookmin.stream.internal.domain.display.service;

import java.time.LocalDate;
import java.util.List;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarSchedule;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarScheduleCreateCommand;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarScheduleUpdateCommand;

/**
* 운영진용 디스플레이 학사 일정 서비스. 일정 조회·등록·수정·삭제를 맡는다.
* 운영진용 디스플레이 학사 일정 서비스. 일정 등록·수정·삭제를 맡는다. 조회는 학생 앱과 같은
* {@link DisplayService#getSchedules}를 쓴다.
*/
public interface AdminDisplayCalendarScheduleService {

// 기간이 startDate~endDate와 하루라도 겹치는 일정. 관리자 화면은 한 달 범위로 부른다
List<DisplayCalendarSchedule> getSchedules(LocalDate startDate, LocalDate endDate);

// 같은 이름·같은 기간의 일정이 있어도 중복 확인 없이 저장한다
DisplayCalendarSchedule create(DisplayCalendarScheduleCreateCommand command);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package kr.ac.kookmin.stream.internal.domain.display.service;

import java.util.List;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarSchedule;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayDailySchedule;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayPoster;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplaySchedulePeriod;

/**
* 오프라인 디스플레이 화면용 조회 서비스. 로그인 없이 부르는 공개 화면 조회가 쓴다.
* 포스터·학사 일정 관리는 {@link AdminDisplayPosterService}, {@link AdminDisplayCalendarScheduleService}가 맡는다.
* 디스플레이 포스터·학사 일정 조회 서비스. 로그인 없이 부르는 디스플레이 화면 조회와, 학생 앱·운영진 화면의 학사 일정
* 조회가 함께 쓴다. 포스터 관리와 학사 일정 등록·수정·삭제는 {@link AdminDisplayPosterService},
* {@link AdminDisplayCalendarScheduleService}가 맡는다.
*/
public interface DisplayService {

Expand All @@ -15,4 +18,7 @@ public interface DisplayService {

// 오늘(KST) 앞뒤 3일, 7일치 학사 일정을 날짜 오름차순으로. 일정이 없는 날도 빈 목록으로 넣어 항상 7개다
List<DisplayDailySchedule> getDailySchedulesAroundToday();

// 기간이 period와 하루라도 겹치는 일정. 학생 앱은 한 주·한 달 달력 범위로, 관리자 화면은 한 달 범위로 부른다
List<DisplayCalendarSchedule> getSchedules(DisplaySchedulePeriod period);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package kr.ac.kookmin.stream.internal.domain.display.service.impl;

import java.time.LocalDate;
import java.util.List;
import kr.ac.kookmin.stream.common.BusinessException;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarSchedule;
import kr.ac.kookmin.stream.internal.domain.display.domain.DisplayCalendarScheduleCreateCommand;
Expand All @@ -19,12 +17,6 @@ class AdminDisplayCalendarScheduleServiceImpl implements AdminDisplayCalendarSch

private final DisplayCalendarScheduleRepository displayCalendarScheduleRepository;

@Override
public List<DisplayCalendarSchedule> getSchedules(LocalDate startDate, LocalDate endDate) {
validateSearchPeriod(startDate, endDate);
return displayCalendarScheduleRepository.findAllOverlapping(startDate, endDate);
}

@Override
@Transactional
public DisplayCalendarSchedule create(DisplayCalendarScheduleCreateCommand command) {
Expand All @@ -46,14 +38,6 @@ public void delete(Long scheduleId) {
displayCalendarScheduleRepository.deleteById(scheduleId);
}

// startDate·endDate가 뒤바뀐 요청(예: 10/31~10/1)은 일정 기간과 같은 에러로 거절한다.
// 그대로 조회하면 겹침 조건이 뒤집혀 범위 전체를 덮는 일정만 걸려 나온다
private void validateSearchPeriod(LocalDate startDate, LocalDate endDate) {
if (endDate.isBefore(startDate)) {
throw new BusinessException(DisplayErrorCode.INVALID_DISPLAY_SCHEDULE_PERIOD);
}
}

private DisplayCalendarSchedule getScheduleById(Long scheduleId) {
return displayCalendarScheduleRepository.findById(scheduleId)
.orElseThrow(() -> new BusinessException(DisplayErrorCode.DISPLAY_SCHEDULE_NOT_FOUND));
Expand Down
Loading
Loading