generated from pricelees/issue-pr-template
feat: ScheduleId를 이용한 ScheduleOverview 단건 조회 기능 추가
This commit is contained in:
parent
86aa4c3046
commit
5a6f7c4763
@ -69,6 +69,16 @@ class ScheduleService(
|
|||||||
throw ScheduleException(ScheduleErrorCode.SCHEDULE_NOT_AVAILABLE)
|
throw ScheduleException(ScheduleErrorCode.SCHEDULE_NOT_AVAILABLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
fun findScheduleOverviewById(id: Long): ScheduleOverviewResponse {
|
||||||
|
val overview: ScheduleOverview = scheduleRepository.findOverviewByIdOrNull(id) ?: run {
|
||||||
|
log.warn { "[ScheduleService.findScheduleOverview] 일정 개요 조회 실패: id=$id" }
|
||||||
|
throw ScheduleException(ScheduleErrorCode.SCHEDULE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
|
||||||
|
return overview.toOverviewResponse()
|
||||||
|
}
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
// All-Admin (본사, 매장 모두 사용가능)
|
// All-Admin (본사, 매장 모두 사용가능)
|
||||||
// ========================================
|
// ========================================
|
||||||
|
|||||||
@ -53,4 +53,29 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
date: LocalDate,
|
date: LocalDate,
|
||||||
themeId: Long? = null
|
themeId: Long? = null
|
||||||
): List<ScheduleOverview>
|
): List<ScheduleOverview>
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT
|
||||||
|
new roomescape.schedule.business.domain.ScheduleOverview(
|
||||||
|
s._id,
|
||||||
|
st._id,
|
||||||
|
st.name,
|
||||||
|
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
|
||||||
|
JOIN
|
||||||
|
StoreEntity st ON st._id = s.storeId
|
||||||
|
WHERE
|
||||||
|
s._id = :id
|
||||||
|
""")
|
||||||
|
fun findOverviewByIdOrNull(id: Long): ScheduleOverview?
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,3 +54,25 @@ fun ScheduleEntity.toSummaryResponse() = ScheduleSummaryResponse(
|
|||||||
themeId = this.themeId,
|
themeId = this.themeId,
|
||||||
status = this.status
|
status = this.status
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class ScheduleOverviewResponse(
|
||||||
|
val id: Long,
|
||||||
|
val storeId: Long,
|
||||||
|
val storeName: String,
|
||||||
|
val date: LocalDate,
|
||||||
|
val startFrom: LocalTime,
|
||||||
|
val endAt: LocalTime,
|
||||||
|
val themeId: Long,
|
||||||
|
val themeName: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun ScheduleOverview.toOverviewResponse() = ScheduleOverviewResponse(
|
||||||
|
id = this.id,
|
||||||
|
storeId = this.storeId,
|
||||||
|
storeName = this.storeName,
|
||||||
|
date = this.date,
|
||||||
|
startFrom = this.time,
|
||||||
|
endAt = this.getEndAt(),
|
||||||
|
themeId = this.themeId,
|
||||||
|
themeName = this.themeName,
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user