[#44] 매장 기능 도입 #45

Merged
pricelees merged 116 commits from feat/#44 into main 2025-09-20 03:15:06 +00:00
2 changed files with 15 additions and 4 deletions
Showing only changes of commit 89ada4b146 - Show all commits

View File

@ -41,13 +41,13 @@ class ScheduleValidator(
val time: LocalTime = request.time
val themeId: Long = request.themeId
validateAlreadyExists(date, themeId, time)
validateAlreadyExists(storeId, date, themeId, time)
validateNotInPast(date, time)
validateTimeNotConflict(storeId, request.date, request.themeId, request.time)
}
private fun validateAlreadyExists(date: LocalDate, themeId: Long, time: LocalTime) {
if (scheduleRepository.existsByDateAndThemeIdAndTime(date, themeId, time)) {
private fun validateAlreadyExists(storeId: Long, date: LocalDate, themeId: Long, time: LocalTime) {
if (scheduleRepository.existsDuplicate(storeId, date, themeId, time)) {
log.info {
"[ScheduleValidator.validateAlreadyExists] 동일한 날짜, 테마, 시간 존재로 인한 실패: date=${date} / themeId=${themeId} / time=${time}"
}

View File

@ -8,7 +8,18 @@ import java.time.LocalTime
interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
fun existsByDateAndThemeIdAndTime(date: LocalDate, themeId: Long, time: LocalTime): Boolean
@Query("""
SELECT
COUNT(s) > 0
FROM
ScheduleEntity s
WHERE
s.storeId = :storeId
AND s.date = :date
AND s.themeId = :themeId
AND s.time = :time
""")
fun existsDuplicate(storeId: Long, date: LocalDate, themeId: Long, time: LocalTime): Boolean
@Query(
"""