generated from pricelees/issue-pr-template
refactor: 성능 테스트 환경 설정을 위해 사용되는 Repository 별도 분리
This commit is contained in:
parent
c3330e5652
commit
cce59e522e
@ -16,8 +16,8 @@ interface ReservationRepository : JpaRepository<ReservationEntity, Long> {
|
||||
@Query("SELECT r FROM ReservationEntity r WHERE r._id = :id")
|
||||
fun findByIdForUpdate(@Param("id") id: Long): ReservationEntity?
|
||||
|
||||
|
||||
@Query("""
|
||||
@Query(
|
||||
"""
|
||||
SELECT
|
||||
r.id
|
||||
FROM
|
||||
@ -27,7 +27,8 @@ interface ReservationRepository : JpaRepository<ReservationEntity, Long> {
|
||||
WHERE
|
||||
r.status = 'PENDING' AND r.created_at <= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 MINUTE)
|
||||
FOR UPDATE SKIP LOCKED
|
||||
""", nativeQuery = true)
|
||||
""", nativeQuery = true
|
||||
)
|
||||
fun findAllExpiredReservation(): List<Long>
|
||||
|
||||
@Modifying
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.sangdol.roomescape.schedule.infrastructure.persistence
|
||||
|
||||
import com.sangdol.roomescape.schedule.business.domain.ScheduleOverview
|
||||
import com.sangdol.roomescape.test.ScheduleWithThemeId
|
||||
import jakarta.persistence.LockModeType
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Lock
|
||||
@ -160,18 +159,4 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
||||
"""
|
||||
)
|
||||
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 {
|
||||
return testSetupService.findAllStores()
|
||||
}
|
||||
|
||||
@GetMapping("/reservations-with-user")
|
||||
fun findAllReservationsWithUser(): ReservationWithUserList {
|
||||
return testSetupService.findAllReservationWithUser()
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,4 +44,14 @@ data class StoreIdList(
|
||||
|
||||
data class StoreId(
|
||||
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.AdminRepository
|
||||
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.theme.infrastructure.persistence.ThemeRepository
|
||||
import com.sangdol.roomescape.user.infrastructure.persistence.UserRepository
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.time.LocalTime
|
||||
@ -16,8 +14,9 @@ class TestSetupService(
|
||||
private val themeRepository: ThemeRepository,
|
||||
private val storeRepository: StoreRepository,
|
||||
private val adminRepository: AdminRepository,
|
||||
private val userRepository: UserRepository,
|
||||
private val scheduleRepository: ScheduleRepository,
|
||||
private val userRepository: TestSetupUserRepository,
|
||||
private val scheduleRepository: TestSetupScheduleRepository,
|
||||
private val reservationRepository: TestSetupReservationRepository
|
||||
) {
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@ -85,4 +84,11 @@ class TestSetupService(
|
||||
StoreId(it.id)
|
||||
})
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun findAllReservationWithUser(): ReservationWithUserList {
|
||||
return ReservationWithUserList(
|
||||
reservationRepository.findAllReservationWithUser()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,12 @@
|
||||
package com.sangdol.roomescape.user.infrastructure.persistence
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
|
||||
interface UserRepository : JpaRepository<UserEntity, Long> {
|
||||
|
||||
fun existsByEmail(email: String): Boolean
|
||||
fun existsByPhone(phone: String): Boolean
|
||||
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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user