generated from pricelees/issue-pr-template
feat: schedule의 요약 정보를 제공하는 메서드 추가 & 날짜로 조회할 때 DISTINCT 쿼리 추가
This commit is contained in:
parent
3243c936c7
commit
0ff7702c83
@ -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}" }
|
||||||
|
|||||||
@ -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>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user