generated from pricelees/issue-pr-template
[#66] 결제 & 예약 확정 로직 수정 #67
@ -16,8 +16,8 @@ interface ReservationRepository : JpaRepository<ReservationEntity, Long> {
|
|||||||
@Query("SELECT r FROM ReservationEntity r WHERE r._id = :id")
|
@Query("SELECT r FROM ReservationEntity r WHERE r._id = :id")
|
||||||
fun findByIdForUpdate(@Param("id") id: Long): ReservationEntity?
|
fun findByIdForUpdate(@Param("id") id: Long): ReservationEntity?
|
||||||
|
|
||||||
|
@Query(
|
||||||
@Query("""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
r.id
|
r.id
|
||||||
FROM
|
FROM
|
||||||
@ -27,7 +27,8 @@ interface ReservationRepository : JpaRepository<ReservationEntity, Long> {
|
|||||||
WHERE
|
WHERE
|
||||||
r.status = 'PENDING' AND r.created_at <= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 MINUTE)
|
r.status = 'PENDING' AND r.created_at <= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 MINUTE)
|
||||||
FOR UPDATE SKIP LOCKED
|
FOR UPDATE SKIP LOCKED
|
||||||
""", nativeQuery = true)
|
""", nativeQuery = true
|
||||||
|
)
|
||||||
fun findAllExpiredReservation(): List<Long>
|
fun findAllExpiredReservation(): List<Long>
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.sangdol.roomescape.schedule.infrastructure.persistence
|
package com.sangdol.roomescape.schedule.infrastructure.persistence
|
||||||
|
|
||||||
import com.sangdol.roomescape.schedule.business.domain.ScheduleOverview
|
import com.sangdol.roomescape.schedule.business.domain.ScheduleOverview
|
||||||
import com.sangdol.roomescape.test.ScheduleWithThemeId
|
|
||||||
import jakarta.persistence.LockModeType
|
import jakarta.persistence.LockModeType
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.data.jpa.repository.Lock
|
import org.springframework.data.jpa.repository.Lock
|
||||||
@ -160,18 +159,4 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun releaseHeldSchedules(@Param("scheduleIds") scheduleIds: List<Long>): Int
|
fun releaseHeldSchedules(@Param("scheduleIds") scheduleIds: List<Long>): Int
|
||||||
|
|
||||||
/**
|
|
||||||
* for test
|
|
||||||
*/
|
|
||||||
@Query("""
|
|
||||||
SELECT
|
|
||||||
s.id, s.theme_id
|
|
||||||
FROM
|
|
||||||
schedule s
|
|
||||||
WHERE
|
|
||||||
s.status = 'AVAILABLE'
|
|
||||||
AND s.date > CURRENT_DATE
|
|
||||||
""", nativeQuery = true)
|
|
||||||
fun findAllAvailableSchedules(): List<ScheduleWithThemeId>
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,4 +42,9 @@ class TestSetupController(
|
|||||||
fun findAllStoreIds(): StoreIdList {
|
fun findAllStoreIds(): StoreIdList {
|
||||||
return testSetupService.findAllStores()
|
return testSetupService.findAllStores()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/reservations-with-user")
|
||||||
|
fun findAllReservationsWithUser(): ReservationWithUserList {
|
||||||
|
return testSetupService.findAllReservationWithUser()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,3 +45,13 @@ data class StoreIdList(
|
|||||||
data class StoreId(
|
data class StoreId(
|
||||||
val storeId: Long
|
val storeId: Long
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class ReservationWithUser(
|
||||||
|
val account: String,
|
||||||
|
val password: String,
|
||||||
|
val reservationId: Long
|
||||||
|
)
|
||||||
|
|
||||||
|
data class ReservationWithUserList(
|
||||||
|
val results: List<ReservationWithUser>
|
||||||
|
)
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
package com.sangdol.roomescape.test
|
||||||
|
|
||||||
|
import com.sangdol.roomescape.reservation.infrastructure.persistence.ReservationEntity
|
||||||
|
import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleEntity
|
||||||
|
import com.sangdol.roomescape.user.infrastructure.persistence.UserEntity
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.data.jpa.repository.Query
|
||||||
|
|
||||||
|
interface TestSetupUserRepository: JpaRepository<UserEntity, Long> {
|
||||||
|
/**
|
||||||
|
* for test
|
||||||
|
*/
|
||||||
|
@Query("""
|
||||||
|
SELECT * FROM users u LIMIT :count
|
||||||
|
""", nativeQuery = true)
|
||||||
|
fun findUsersByCount(count: Long): List<UserEntity>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestSetupScheduleRepository: JpaRepository<ScheduleEntity, Long> {
|
||||||
|
/**
|
||||||
|
* for test
|
||||||
|
*/
|
||||||
|
@Query("""
|
||||||
|
SELECT
|
||||||
|
s.id, s.theme_id
|
||||||
|
FROM
|
||||||
|
schedule s
|
||||||
|
WHERE
|
||||||
|
s.status = 'AVAILABLE'
|
||||||
|
AND s.date > CURRENT_DATE
|
||||||
|
""", nativeQuery = true)
|
||||||
|
fun findAllAvailableSchedules(): List<ScheduleWithThemeId>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestSetupReservationRepository: JpaRepository<ReservationEntity, Long> {
|
||||||
|
/**
|
||||||
|
* for test
|
||||||
|
*/
|
||||||
|
@Query(
|
||||||
|
"""
|
||||||
|
SELECT
|
||||||
|
u.email, u.password, r.id
|
||||||
|
FROM
|
||||||
|
reservation r
|
||||||
|
JOIN users u ON u.id = r.user_id
|
||||||
|
""", nativeQuery = true
|
||||||
|
)
|
||||||
|
fun findAllReservationWithUser(): List<ReservationWithUser>
|
||||||
|
}
|
||||||
@ -3,10 +3,8 @@ package com.sangdol.roomescape.test
|
|||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminPermissionLevel
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminPermissionLevel
|
||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminRepository
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminRepository
|
||||||
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminType
|
import com.sangdol.roomescape.admin.infrastructure.persistence.AdminType
|
||||||
import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleRepository
|
|
||||||
import com.sangdol.roomescape.store.infrastructure.persistence.StoreRepository
|
import com.sangdol.roomescape.store.infrastructure.persistence.StoreRepository
|
||||||
import com.sangdol.roomescape.theme.infrastructure.persistence.ThemeRepository
|
import com.sangdol.roomescape.theme.infrastructure.persistence.ThemeRepository
|
||||||
import com.sangdol.roomescape.user.infrastructure.persistence.UserRepository
|
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
import java.time.LocalTime
|
import java.time.LocalTime
|
||||||
@ -16,8 +14,9 @@ class TestSetupService(
|
|||||||
private val themeRepository: ThemeRepository,
|
private val themeRepository: ThemeRepository,
|
||||||
private val storeRepository: StoreRepository,
|
private val storeRepository: StoreRepository,
|
||||||
private val adminRepository: AdminRepository,
|
private val adminRepository: AdminRepository,
|
||||||
private val userRepository: UserRepository,
|
private val userRepository: TestSetupUserRepository,
|
||||||
private val scheduleRepository: ScheduleRepository,
|
private val scheduleRepository: TestSetupScheduleRepository,
|
||||||
|
private val reservationRepository: TestSetupReservationRepository
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@ -85,4 +84,11 @@ class TestSetupService(
|
|||||||
StoreId(it.id)
|
StoreId(it.id)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
fun findAllReservationWithUser(): ReservationWithUserList {
|
||||||
|
return ReservationWithUserList(
|
||||||
|
reservationRepository.findAllReservationWithUser()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,12 @@
|
|||||||
package com.sangdol.roomescape.user.infrastructure.persistence
|
package com.sangdol.roomescape.user.infrastructure.persistence
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.data.jpa.repository.Query
|
|
||||||
|
|
||||||
interface UserRepository : JpaRepository<UserEntity, Long> {
|
interface UserRepository : JpaRepository<UserEntity, Long> {
|
||||||
|
|
||||||
fun existsByEmail(email: String): Boolean
|
fun existsByEmail(email: String): Boolean
|
||||||
fun existsByPhone(phone: String): Boolean
|
fun existsByPhone(phone: String): Boolean
|
||||||
fun findByEmail(email: String): UserEntity?
|
fun findByEmail(email: String): UserEntity?
|
||||||
|
|
||||||
/**
|
|
||||||
* for test
|
|
||||||
*/
|
|
||||||
@Query("""
|
|
||||||
SELECT * FROM users u LIMIT :count
|
|
||||||
""", nativeQuery = true)
|
|
||||||
fun findUsersByCount(count: Long): List<UserEntity>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserStatusHistoryRepository : JpaRepository<UserStatusHistoryEntity, Long>
|
interface UserStatusHistoryRepository : JpaRepository<UserStatusHistoryEntity, Long>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user