From 86aa4c3046c8f518b0439c986c766c6962e3f1f7 Mon Sep 17 00:00:00 2001 From: pricelees Date: Fri, 19 Sep 2025 17:48:25 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20schedule=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=EC=97=90=20=EB=A7=A4=EC=9E=A5=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95(ScheduleWithTheme=20->=20Schedul?= =?UTF-8?q?eOverview)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roomescape/schedule/business/ScheduleService.kt | 6 +++--- ...ScheduleWithThemeSummary.kt => ScheduleOverview.kt} | 4 +++- .../infrastructure/persistence/ScheduleRepository.kt | 10 +++++++--- .../kotlin/roomescape/schedule/web/AdminScheduleDto.kt | 6 +++--- src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt | 6 +++--- 5 files changed, 19 insertions(+), 13 deletions(-) rename src/main/kotlin/roomescape/schedule/business/domain/{ScheduleWithThemeSummary.kt => ScheduleOverview.kt} (91%) diff --git a/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt b/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt index 5ad4df11..34b0637a 100644 --- a/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt +++ b/src/main/kotlin/roomescape/schedule/business/ScheduleService.kt @@ -11,7 +11,7 @@ import roomescape.admin.business.AdminService import roomescape.common.config.next import roomescape.common.dto.AuditInfo import roomescape.common.dto.OperatorInfo -import roomescape.schedule.business.domain.ScheduleWithThemeSummary +import roomescape.schedule.business.domain.ScheduleOverview import roomescape.schedule.exception.ScheduleErrorCode import roomescape.schedule.infrastructure.persistence.ScheduleEntity import roomescape.schedule.infrastructure.persistence.ScheduleEntityFactory @@ -45,7 +45,7 @@ class ScheduleService( fun getStoreScheduleByDate(storeId: Long, date: LocalDate): ScheduleWithThemeListResponse { log.info { "[ScheduleService.getStoreScheduleByDate] 매장 일정 조회: storeId=${storeId}, date=$date" } - val schedules: List = + val schedules: List = scheduleRepository.findStoreSchedulesWithThemeByDate(storeId, date) return schedules.toResponse() @@ -78,7 +78,7 @@ class ScheduleService( val searchDate = date ?: LocalDate.now() - val schedules: List = + val schedules: List = scheduleRepository.findStoreSchedulesWithThemeByDate(storeId, searchDate) .filter { (themeId == null) || (it.themeId == themeId) } .sortedBy { it.time } diff --git a/src/main/kotlin/roomescape/schedule/business/domain/ScheduleWithThemeSummary.kt b/src/main/kotlin/roomescape/schedule/business/domain/ScheduleOverview.kt similarity index 91% rename from src/main/kotlin/roomescape/schedule/business/domain/ScheduleWithThemeSummary.kt rename to src/main/kotlin/roomescape/schedule/business/domain/ScheduleOverview.kt index 5259b1e8..e9d9b523 100644 --- a/src/main/kotlin/roomescape/schedule/business/domain/ScheduleWithThemeSummary.kt +++ b/src/main/kotlin/roomescape/schedule/business/domain/ScheduleOverview.kt @@ -5,8 +5,10 @@ import roomescape.theme.infrastructure.persistence.Difficulty import java.time.LocalDate import java.time.LocalTime -class ScheduleWithThemeSummary( +class ScheduleOverview( val id: Long, + val storeId: Long, + val storeName: String, val date: LocalDate, val time: LocalTime, val themeId: Long, diff --git a/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt b/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt index 9fb8049f..59665b08 100644 --- a/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt +++ b/src/main/kotlin/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt @@ -2,7 +2,7 @@ package roomescape.schedule.infrastructure.persistence import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query -import roomescape.schedule.business.domain.ScheduleWithThemeSummary +import roomescape.schedule.business.domain.ScheduleOverview import java.time.LocalDate import java.time.LocalTime @@ -24,8 +24,10 @@ interface ScheduleRepository : JpaRepository { @Query( """ SELECT - new roomescape.schedule.business.domain.ScheduleWithThemeSummary( + new roomescape.schedule.business.domain.ScheduleOverview( s._id, + st._id, + st.name, s.date, s.time, t._id, @@ -38,6 +40,8 @@ interface ScheduleRepository : JpaRepository { ScheduleEntity s JOIN ThemeEntity t ON t._id = s.themeId + JOIN + StoreEntity st ON st._id = s.storeId WHERE s.storeId = :storeId AND s.date = :date @@ -48,5 +52,5 @@ interface ScheduleRepository : JpaRepository { storeId: Long, date: LocalDate, themeId: Long? = null - ): List + ): List } diff --git a/src/main/kotlin/roomescape/schedule/web/AdminScheduleDto.kt b/src/main/kotlin/roomescape/schedule/web/AdminScheduleDto.kt index a17e7abc..47d17915 100644 --- a/src/main/kotlin/roomescape/schedule/web/AdminScheduleDto.kt +++ b/src/main/kotlin/roomescape/schedule/web/AdminScheduleDto.kt @@ -1,6 +1,6 @@ package roomescape.schedule.web -import roomescape.schedule.business.domain.ScheduleWithThemeSummary +import roomescape.schedule.business.domain.ScheduleOverview import roomescape.schedule.infrastructure.persistence.ScheduleStatus import java.time.LocalDate import java.time.LocalTime @@ -16,7 +16,7 @@ data class AdminScheduleSummaryResponse( val status: ScheduleStatus, ) -fun ScheduleWithThemeSummary.toAdminSummaryResponse() = AdminScheduleSummaryResponse( +fun ScheduleOverview.toAdminSummaryResponse() = AdminScheduleSummaryResponse( id = this.id, themeName = this.themeName, startFrom = this.time, @@ -28,7 +28,7 @@ data class AdminScheduleSummaryListResponse( val schedules: List ) -fun List.toAdminSummaryListResponse() = AdminScheduleSummaryListResponse( +fun List.toAdminSummaryListResponse() = AdminScheduleSummaryListResponse( this.map { it.toAdminSummaryResponse() } ) diff --git a/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt b/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt index 4fe174a3..ddf8633c 100644 --- a/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt +++ b/src/main/kotlin/roomescape/schedule/web/ScheduleDto.kt @@ -1,6 +1,6 @@ package roomescape.schedule.web -import roomescape.schedule.business.domain.ScheduleWithThemeSummary +import roomescape.schedule.business.domain.ScheduleOverview import roomescape.schedule.infrastructure.persistence.ScheduleEntity import roomescape.schedule.infrastructure.persistence.ScheduleStatus import roomescape.theme.infrastructure.persistence.Difficulty @@ -20,7 +20,7 @@ data class ScheduleWithThemeResponse( val status: ScheduleStatus ) -fun ScheduleWithThemeSummary.toResponse() = ScheduleWithThemeResponse( +fun ScheduleOverview.toResponse() = ScheduleWithThemeResponse( id = this.id, startFrom = this.time, endAt = this.getEndAt(), @@ -34,7 +34,7 @@ data class ScheduleWithThemeListResponse( val schedules: List ) -fun List.toResponse() = ScheduleWithThemeListResponse( +fun List.toResponse() = ScheduleWithThemeListResponse( this.map { it.toResponse() } )