Skip to content

Add new calendar API endpoint #37

Merged
jeyongsong merged 10 commits intomainfrom
calendar-api-redesign
Mar 15, 2026
Merged

Add new calendar API endpoint #37
jeyongsong merged 10 commits intomainfrom
calendar-api-redesign

Conversation

@jeyongsong
Copy link
Member

This pull request introduces a new calendar API endpoint and refactors related code to support richer calendar functionality, including schedule status and event types. The changes also reorganize controller files and add new domain types for calendar events and daily work status.

Calendar API and Schedule Enhancements:

  • Added a new CalendarController under /api/v1/calendar that provides a monthly calendar view including earnings and daily schedules, replacing previous endpoints in WorkdayController. (src/main/kotlin/com/moa/controller/screen/CalendarController.kt, src/main/kotlin/com/moa/controller/screen/CalendarController.ktR1-R26)
  • Refactored WorkdayService to support the new calendar API, including a new getCalendar method, improved getMonthlyEarnings, and enhanced WorkdayResponse with schedule status and calendar events. (src/main/kotlin/com/moa/service/WorkdayService.kt, [1] [2] [3] [4] [5]
  • Added new DTOs: CalendarResponse and updated WorkdayResponse to include status and events fields. (src/main/kotlin/com/moa/service/dto/CalendarResponse.kt, [1]; src/main/kotlin/com/moa/service/dto/WorkdayResponse.kt, [2]

Domain Model Additions:

  • Introduced CalendarEventType and DailWorkStatusType enums to represent calendar events (e.g., payday, holiday) and daily work status (e.g., scheduled, in progress, completed). (src/main/kotlin/com/moa/entity/CalendarEventType.kt, [1]; src/main/kotlin/com/moa/entity/DailWorkStatusType.kt, [2]

Controller Reorganization:

  • Moved and renamed controller files for better structure: HomeController and OnboardingController are now under controller.screen. (src/main/kotlin/com/moa/controller/screen/HomeController.kt, [1]; src/main/kotlin/com/moa/controller/screen/OnboardingController.kt, [2]
  • Updated HomeResponse to include the new status field reflecting daily work status. (src/main/kotlin/com/moa/service/dto/HomeResponse.kt, [1] [2]; src/main/kotlin/com/moa/controller/screen/HomeController.kt, [3]

Deprecation and API Guidance:

  • Deprecated old monthly earnings and schedule endpoints in WorkdayController, directing users to use the new calendar API instead. (src/main/kotlin/com/moa/controller/WorkdayController.kt, [1] [2]

Miscellaneous:

These changes collectively modernize the calendar and scheduling features, provide richer data for UI, and improve code organization.

@github-actions
Copy link

github-actions bot commented Mar 14, 2026

Test Results

32 tests   32 ✅  0s ⏱️
 3 suites   0 💤
 3 files     0 ❌

Results for commit 80882fc.

♻️ This comment has been updated with latest results.

@jeyongsong
Copy link
Member Author

jeyongsong commented Mar 15, 2026

@subsub97

한눈에 보는 변경사항

이번 PR은 기존에 분산되어 있던 월간 근무/수입 조회를 월 캘린더 화면 기준의 단일 API로 통합한 변경입니다.
기존 WorkdayController의 조회 API 3개는 제거하지 않고 유지하되, 별도로 월 단위 캘린더 화면에 필요한 데이터를 한 번에 내려주는 API를 추가했습니다.

새로 추가된 API는 다음과 같습니다.

GET /api/v1/calendar?year={year}&month={month}

이 API는 단순히 날짜 목록만 내려주는 것이 아니라, 아래 정보를 한 번에 제공합니다.

  • 월 누적 수입/시간 요약
  • 해당 월의 날짜별 근무 정보
  • 날짜별 현재 근무 상태
  • 날짜별 이벤트 정보

핵심 변경 사항

1. 월 캘린더 통합 API 추가

CalendarController를 새로 추가해, 월 캘린더 화면에서 필요한 데이터를 한 번에 조회할 수 있도록 했습니다.

응답 구조는 CalendarResponse로 구성되며, 내부에는 다음이 포함됩니다.

  • earnings: 월 누적 수입/시간 요약
  • schedules: 해당 월의 날짜별 상세 정보 목록 (List<WorkdayResponse>)

기존에는 아래 API들을 조합해서 사용해야 했지만,

  • 월 수입 조회 API
  • 월 스케줄 조회 API
  • 일간 조회 API

이제 캘린더 화면에서는 하나의 API로 처리할 수 있습니다.


2. 날짜별 상세 응답 추가

캘린더 API의 날짜별 응답은 WorkdayResponse를 사용하며, 아래 필드를 포함합니다.

  • date
  • type
  • status
  • events
  • dailyPay
  • clockInTime
  • clockOutTime

이를 통해 클라이언트는 날짜별로 아래 정보를 바로 사용할 수 있습니다.

  • 이 날이 근무일인지
  • 현재 근무 상태가 어떤지
  • 월급날 같은 이벤트가 있는지
  • 일급과 출퇴근 시간이 어떻게 되는지

참고로 기존 월간 조회 API GET /api/v1/workdays의 응답은 그대로 MonthlyWorkdayResponse(date, type)를 유지하며, 상세 필드는 새 캘린더 API에서 제공합니다.


3. 근무 상태(status) 개념 추가

날짜별 현재 상태를 표현하기 위해 DailyWorkStatusType enum을 추가했습니다.

값은 다음 세 가지입니다.

  • NONE
  • SCHEDULED
  • COMPLETED

상태 계산은 WorkdayService에서 처리하며 규칙은 아래와 같습니다.

  • 근무 자체가 없으면 NONE
  • 근무가 존재하고 아직 종료 시각 전이면 SCHEDULED
  • 근무 종료 시각이 지나면 COMPLETED

SCHEDULED는 출근 전, 근무 중, 미래 예정 근무를 모두 포함하는 상태입니다.

또한 야간 근무처럼 퇴근 시간이 출근 시간보다 이른 경우에는 다음 날 종료로 해석하도록 처리했습니다.


4. 날짜별 이벤트 개념 추가

날짜별 특이사항 표시를 위해 DailyEventType enum을 추가했습니다.

현재 정의된 값은 다음과 같습니다.

  • PAYDAY
  • HOLIDAY

이 중 실제로 동작하는 것은 PAYDAY이며, HOLIDAY는 이후 확장을 고려해 enum만 먼저 추가하고 서비스에는 TODO를 남겨둔 상태입니다.


5. 월급날 계산 로직 명확화 및 통일

월급날 이벤트는 프로필의 paydayDay를 기준으로 계산합니다.

규칙은 다음과 같습니다.

  • 해당 월에 지정한 날짜가 없으면 말일로 보정
  • 보정된 날짜가 토요일이면 전날 금요일로 당김
  • 보정된 날짜가 일요일이면 이틀 전 금요일로 당김

예를 들면,

  • paydayDay = 31인데 4월이면 → 4월 30일
  • 그 날짜가 토요일이면 → 4월 29일(금)로 당김

이 로직은 캘린더 표시 기준과 실제 알림 발송 기준이 다르지 않도록 아래 두 군데에 동일하게 반영했습니다.

  • WorkdayService
  • PaydayNotificationBatchService

즉 UI 표시 기준과 실제 알림 발송 기준을 일치시킨 것이 중요한 변경점입니다.


6. 월 누적 수입/시간 계산 방식 조정

MonthlyEarningsResponse 구조는 그대로 유지했습니다.

  • workedEarnings
  • workedMinutes
  • standardSalary
  • standardMinutes

대신 월 누적 계산 방식은 아래와 같이 정리했습니다.

  • WORK, VACATION: statusCOMPLETED인 경우에만 workedEarnings, workedMinutes에 반영
  • NONE: 0으로 처리

즉 단순히 근무 유형만으로 반영하는 것이 아니라, 실제로 해당 근무가 종료된 경우에만 월 누적 수입/시간에 포함합니다.


7. 기존 API와의 호환성 유지

기존 WorkdayController의 조회 API는 제거하지 않았습니다.

즉,

  • 기존 클라이언트는 계속 사용 가능
  • 새 캘린더 화면은 통합 API 사용 가능

하도록 하위 호환성을 유지했습니다.

다만 기존 조회 API 3개에는 GET /api/v1/calendar 사용을 유도하는 deprecated 표시를 추가했습니다.


8. 컨트롤러 구조 정리

화면 성격의 컨트롤러들을 controller.screen 패키지로 이동해 구조를 정리했습니다.

  • CalendarController
  • HomeController
  • OnboardingController

이와 함께 HomeResponse에도 오늘의 status를 포함시켜, 홈 화면에서도 현재 근무 상태를 바로 활용할 수 있게 했습니다.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new monthly calendar API for the screen layer and expands schedule/earnings responses to include daily work status and calendar events, while also reorganizing some controller packages and updating payday notification date resolution.

Changes:

  • Added /api/v1/calendar endpoint returning monthly earnings + per-day schedules.
  • Extended schedule/home DTOs with status and added per-day events support (e.g., payday).
  • Updated payday notification batching to adjust payday to month-end and prior Friday when it falls on weekends; reorganized/retagged several controllers.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/main/kotlin/com/moa/controller/screen/CalendarController.kt New calendar screen endpoint combining monthly earnings + daily schedules.
src/main/kotlin/com/moa/service/WorkdayService.kt Adds monthly workday listing, enhances earnings calc for “today”, and enriches WorkdayResponse with status/events (incl. payday logic).
src/main/kotlin/com/moa/service/dto/CalendarResponse.kt New response wrapper for the calendar endpoint.
src/main/kotlin/com/moa/service/dto/WorkdayResponse.kt Adds status and events fields to daily schedule response.
src/main/kotlin/com/moa/service/dto/HomeResponse.kt Adds status field to home response.
src/main/kotlin/com/moa/entity/DailyWorkStatusType.kt New enum for daily work status.
src/main/kotlin/com/moa/entity/DailyEventType.kt New enum for per-day calendar events (e.g., payday/holiday).
src/main/kotlin/com/moa/service/notification/PaydayNotificationBatchService.kt Updates payday profile selection to use “effective payday” with month-end + weekend adjustment.
src/main/kotlin/com/moa/controller/WorkdayController.kt Deprecates older monthly endpoints in favor of calendar endpoint; keeps legacy routes.
src/main/kotlin/com/moa/controller/screen/HomeController.kt Moves to controller.screen package and includes status in response.
src/main/kotlin/com/moa/controller/screen/OnboardingController.kt Moves to controller.screen package and updates Swagger tag description.
src/main/kotlin/com/moa/controller/ProfileController.kt Import ordering + Swagger tag description simplified.
src/main/kotlin/com/moa/controller/NotificationSettingController.kt Swagger tag description simplified.
src/main/kotlin/com/moa/controller/FcmTokenController.kt Swagger tag description updated.
src/main/kotlin/com/moa/controller/AuthController.kt DTO imports consolidated + Swagger tag description simplified.
Comments suppressed due to low confidence (1)

src/main/kotlin/com/moa/service/WorkdayService.kt:303

  • createWorkdayResponse resolves the monthly representative policy via resolveMonthlyRepresentativePolicyOrNull(...) even when callers (like getMonthlyWorkdays) already computed monthlyPolicy. For monthly list responses this can cause repeated DB queries for the same policy; consider threading the policy into this method (or adding an overload) to reuse the pre-fetched value.
        val policy = resolveMonthlyRepresentativePolicyOrNull(memberId, date.year, date.monthValue)
            ?: return WorkdayResponse(
                date = date,
                type = schedule.type,
                status = resolveDailWorkStatus(date, schedule),
                events = events,
                dailyPay = 0,
                clockInTime = schedule.clockIn,
                clockOutTime = schedule.clockOut,
            )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jeyongsong jeyongsong merged commit 905a153 into main Mar 15, 2026
3 checks passed
@jeyongsong jeyongsong deleted the calendar-api-redesign branch March 15, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants