From 5a6f7c4763ccf00bb5a5ccfd46ca8f8a7de888fb Mon Sep 17 00:00:00 2001 From: pricelees Date: Fri, 19 Sep 2025 18:00:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20ScheduleId=EB=A5=BC=20=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=ED=95=9C=20ScheduleOverview=20=EB=8B=A8=EA=B1=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/business/ScheduleService.kt | 10 ++++++++ .../persistence/ScheduleRepository.kt | 25 +++++++++++++++++++ .../roomescape/schedule/web/ScheduleDto.kt | 22 ++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt b/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt index 34b0637a..e080dae5 100644 --- a/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt +++ b/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt @@ -69,6 +69,16 @@ class ScheduleService( throw ScheduleException(ScheduleErrorCode.SCHEDULE_NOT_AVAILABLE) } + @Transactional(readOnly = true) + fun findScheduleOverviewById(id: Long): ScheduleOverviewResponse { + val overview: ScheduleOverview = scheduleRepository.findOverviewByIdOrNull(id) ?: run { + log.warn { "[ScheduleService.findScheduleOverview] 일정 개요 조회 실패: id=$id" } + throw ScheduleException(ScheduleErrorCode.SCHEDULE_NOT_FOUND) + } + + return overview.toOverviewResponse() + } + // ======================================== // All-Admin (본사, 매장 모두 사용가능) // ======================================== diff --git a/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt b/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt index 59665b08..c7503bf7 100644 --- a/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt +++ b/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt @@ -53,4 +53,29 @@ interface ScheduleRepository : JpaRepository { date: LocalDate, themeId: Long? = null ): List + + @Query(""" + SELECT + new roomescape.schedule.business.domain.ScheduleOverview( + s._id, + st._id, + st.name, + s.date, + s.time, + t._id, + t.name, + t.difficulty, + t.availableMinutes, + s.status + ) + FROM + ScheduleEntity s + JOIN + ThemeEntity t ON t._id = s.themeId + JOIN + StoreEntity st ON st._id = s.storeId + WHERE + s._id = :id + """) + fun findOverviewByIdOrNull(id: Long): ScheduleOverview? } diff --git a/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt b/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt index ddf8633c..10f4f03e 100644 --- a/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt +++ b/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt @@ -54,3 +54,25 @@ fun ScheduleEntity.toSummaryResponse() = ScheduleSummaryResponse( themeId = this.themeId, status = this.status ) + +data class ScheduleOverviewResponse( + val id: Long, + val storeId: Long, + val storeName: String, + val date: LocalDate, + val startFrom: LocalTime, + val endAt: LocalTime, + val themeId: Long, + val themeName: String, +) + +fun ScheduleOverview.toOverviewResponse() = ScheduleOverviewResponse( + id = this.id, + storeId = this.storeId, + storeName = this.storeName, + date = this.date, + startFrom = this.time, + endAt = this.getEndAt(), + themeId = this.themeId, + themeName = this.themeName, +)