[#41] 예약 스키마 재정의 #42

Merged
pricelees merged 41 commits from refactor/#41 into main 2025-09-09 00:43:39 +00:00
3 changed files with 33 additions and 4 deletions
Showing only changes of commit 0ff7702c83 - Show all commits

View File

@ -30,8 +30,7 @@ class ScheduleService(
fun findThemesByDate(date: LocalDate): AvailableThemeIdListResponse { fun findThemesByDate(date: LocalDate): AvailableThemeIdListResponse {
log.info { "[ScheduleService.findThemesByDate] 동일한 날짜의 모든 테마 조회: date=$date" } log.info { "[ScheduleService.findThemesByDate] 동일한 날짜의 모든 테마 조회: date=$date" }
return scheduleRepository.findAllByDate(date) return AvailableThemeIdListResponse(scheduleRepository.findAllUniqueThemeIdByDate(date))
.toThemeIdListResponse()
.also { .also {
log.info { "[ScheduleService.findThemesByDate] date=${date}${it.themeIds.size}개 테마 조회 완료" } log.info { "[ScheduleService.findThemesByDate] date=${date}${it.themeIds.size}개 테마 조회 완료" }
} }
@ -54,8 +53,8 @@ class ScheduleService(
val schedule: ScheduleEntity = findOrThrow(id) val schedule: ScheduleEntity = findOrThrow(id)
val createdBy = memberService.findById(schedule.createdBy).name val createdBy = memberService.findSummaryById(schedule.createdBy).name
val updatedBy = memberService.findById(schedule.updatedBy).name val updatedBy = memberService.findSummaryById(schedule.updatedBy).name
return schedule.toDetailRetrieveResponse(createdBy, updatedBy) return schedule.toDetailRetrieveResponse(createdBy, updatedBy)
.also { .also {
@ -63,6 +62,16 @@ class ScheduleService(
} }
} }
@Transactional(readOnly = true)
fun findSummaryById(id: Long): ScheduleSummaryResponse {
log.info { "[ScheduleService.findDateTimeById] 일정 개요 조회 시작 : id=$id" }
return findOrThrow(id).toSummaryResponse()
.also {
log.info { "[ScheduleService.findDateTimeById] 일정 개요 조회 완료: id=$id" }
}
}
@Transactional @Transactional
fun createSchedule(request: ScheduleCreateRequest): ScheduleCreateResponse { fun createSchedule(request: ScheduleCreateRequest): ScheduleCreateResponse {
log.info { "[ScheduleService.createSchedule] 일정 생성 시작: date=${request.date}, time=${request.time}, themeId=${request.themeId}" } log.info { "[ScheduleService.createSchedule] 일정 생성 시작: date=${request.date}, time=${request.time}, themeId=${request.themeId}" }

View File

@ -1,6 +1,7 @@
package roomescape.schedule.infrastructure.persistence 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 java.time.LocalDate import java.time.LocalDate
import java.time.LocalTime import java.time.LocalTime
@ -11,4 +12,11 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
fun findAllByDateAndThemeId(date: LocalDate, themeId: Long): 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("""
SELECT DISTINCT s.themeId
FROM ScheduleEntity s
WHERE s.date = :date
""")
fun findAllUniqueThemeIdByDate(date: LocalDate): List<Long>
} }

View File

@ -66,3 +66,15 @@ fun ScheduleEntity.toDetailRetrieveResponse(createdBy: String, updatedBy: String
updatedAt = this.updatedAt, updatedAt = this.updatedAt,
updatedBy = updatedBy updatedBy = updatedBy
) )
data class ScheduleSummaryResponse(
val date: LocalDate,
val time: LocalTime,
val themeId: Long
)
fun ScheduleEntity.toSummaryResponse() = ScheduleSummaryResponse(
date = this.date,
time = this.time,
themeId = this.themeId
)