feat: Repository에 ScheduleWithThemeSummary 조회 메서드 추가

This commit is contained in:
이상진 2025-09-17 10:34:35 +09:00
parent d5037664d7
commit eec279c76f

View File

@ -2,23 +2,40 @@ package roomescape.schedule.infrastructure.persistence
import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query import org.springframework.data.jpa.repository.Query
import roomescape.schedule.business.domain.ScheduleWithThemeSummary
import java.time.LocalDate import java.time.LocalDate
import java.time.LocalTime import java.time.LocalTime
interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> { interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
fun findAllByDate(date: LocalDate): List<ScheduleEntity>
fun findAllByDateAndThemeId(date: LocalDate, themeId: Long): List<ScheduleEntity>
fun existsByDateAndThemeIdAndTime(date: LocalDate, themeId: Long, time: LocalTime): Boolean fun existsByDateAndThemeIdAndTime(date: LocalDate, themeId: Long, time: LocalTime): Boolean
@Query( @Query(
""" """
SELECT DISTINCT s.themeId SELECT
FROM ScheduleEntity s new roomescape.schedule.business.domain.ScheduleWithThemeSummary(
WHERE s.date = :date s._id,
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
WHERE
s.storeId = :storeId
AND s.date = :date
AND (:themeId IS NULL OR s.themeId = :themeId)
""" """
) )
fun findAllUniqueThemeIdByDate(date: LocalDate): List<Long> fun findStoreSchedulesWithThemeByDate(
storeId: Long,
date: LocalDate,
themeId: Long? = null
): List<ScheduleWithThemeSummary>
} }