generated from pricelees/issue-pr-template
[#46] 더미 데이터 생성 및 1개의 슬로우쿼리 개선 #47
@ -11,11 +11,11 @@ class ScheduleOverview(
|
|||||||
val storeName: String,
|
val storeName: String,
|
||||||
val date: LocalDate,
|
val date: LocalDate,
|
||||||
val time: LocalTime,
|
val time: LocalTime,
|
||||||
|
val status: ScheduleStatus,
|
||||||
val themeId: Long,
|
val themeId: Long,
|
||||||
val themeName: String,
|
val themeName: String,
|
||||||
val themeDifficulty: Difficulty,
|
val themeDifficulty: Difficulty,
|
||||||
val themeAvailableMinutes: Short,
|
val themeAvailableMinutes: Short
|
||||||
val status: ScheduleStatus
|
|
||||||
) {
|
) {
|
||||||
fun getEndAt(): LocalTime {
|
fun getEndAt(): LocalTime {
|
||||||
return time.plusMinutes(themeAvailableMinutes.toLong())
|
return time.plusMinutes(themeAvailableMinutes.toLong())
|
||||||
|
|||||||
@ -8,7 +8,8 @@ import java.time.LocalTime
|
|||||||
|
|
||||||
interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
||||||
|
|
||||||
@Query("""
|
@Query(
|
||||||
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(s) > 0
|
COUNT(s) > 0
|
||||||
FROM
|
FROM
|
||||||
@ -18,7 +19,8 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
AND s.date = :date
|
AND s.date = :date
|
||||||
AND s.themeId = :themeId
|
AND s.themeId = :themeId
|
||||||
AND s.time = :time
|
AND s.time = :time
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
fun existsDuplicate(storeId: Long, date: LocalDate, themeId: Long, time: LocalTime): Boolean
|
fun existsDuplicate(storeId: Long, date: LocalDate, themeId: Long, time: LocalTime): Boolean
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
@ -30,23 +32,21 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
st.name,
|
st.name,
|
||||||
s.date,
|
s.date,
|
||||||
s.time,
|
s.time,
|
||||||
|
s.status,
|
||||||
t._id,
|
t._id,
|
||||||
t.name,
|
t.name,
|
||||||
t.difficulty,
|
t.difficulty,
|
||||||
t.availableMinutes,
|
t.availableMinutes
|
||||||
s.status
|
|
||||||
)
|
)
|
||||||
FROM
|
FROM
|
||||||
ScheduleEntity s
|
ScheduleEntity s
|
||||||
JOIN
|
JOIN
|
||||||
ThemeEntity t ON t._id = s.themeId
|
ThemeEntity t ON t._id = s.themeId and (:themeId IS NULL OR t._id = :themeId)
|
||||||
JOIN
|
JOIN
|
||||||
StoreEntity st ON st._id = s.storeId
|
StoreEntity st ON st._id = s.storeId and st._id = :storeId
|
||||||
WHERE
|
WHERE
|
||||||
s.storeId = :storeId
|
s.date = :date
|
||||||
AND s.date = :date
|
"""
|
||||||
AND (:themeId IS NULL OR s.themeId = :themeId)
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
fun findStoreSchedulesWithThemeByDate(
|
fun findStoreSchedulesWithThemeByDate(
|
||||||
storeId: Long,
|
storeId: Long,
|
||||||
@ -54,7 +54,8 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
themeId: Long? = null
|
themeId: Long? = null
|
||||||
): List<ScheduleOverview>
|
): List<ScheduleOverview>
|
||||||
|
|
||||||
@Query("""
|
@Query(
|
||||||
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
new roomescape.schedule.business.domain.ScheduleOverview(
|
new roomescape.schedule.business.domain.ScheduleOverview(
|
||||||
s._id,
|
s._id,
|
||||||
@ -62,11 +63,11 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
st.name,
|
st.name,
|
||||||
s.date,
|
s.date,
|
||||||
s.time,
|
s.time,
|
||||||
|
s.status,
|
||||||
t._id,
|
t._id,
|
||||||
t.name,
|
t.name,
|
||||||
t.difficulty,
|
t.difficulty,
|
||||||
t.availableMinutes,
|
t.availableMinutes
|
||||||
s.status
|
|
||||||
)
|
)
|
||||||
FROM
|
FROM
|
||||||
ScheduleEntity s
|
ScheduleEntity s
|
||||||
@ -76,6 +77,7 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
StoreEntity st ON st._id = s.storeId
|
StoreEntity st ON st._id = s.storeId
|
||||||
WHERE
|
WHERE
|
||||||
s._id = :id
|
s._id = :id
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
fun findOverviewByIdOrNull(id: Long): ScheduleOverview?
|
fun findOverviewByIdOrNull(id: Long): ScheduleOverview?
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user