Reorganize packages by domain
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
package com.android.trisolarisserver.repo.room
|
||||
|
||||
import com.android.trisolarisserver.models.room.RoomStay
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.data.repository.query.Param
|
||||
import java.util.UUID
|
||||
|
||||
interface RoomStayRepo : JpaRepository<RoomStay, UUID> {
|
||||
@Query("""
|
||||
select rs.room.id
|
||||
from RoomStay rs
|
||||
where rs.property.id = :propertyId
|
||||
and rs.toAt is null
|
||||
""")
|
||||
fun findOccupiedRoomIds(@Param("propertyId") propertyId: UUID): List<UUID>
|
||||
|
||||
@Query("""
|
||||
select distinct rs.room.id
|
||||
from RoomStay rs
|
||||
where rs.property.id = :propertyId
|
||||
and rs.fromAt < :toAt
|
||||
and (rs.toAt is null or rs.toAt > :fromAt)
|
||||
""")
|
||||
fun findOccupiedRoomIdsBetween(
|
||||
@Param("propertyId") propertyId: UUID,
|
||||
@Param("fromAt") fromAt: java.time.OffsetDateTime,
|
||||
@Param("toAt") toAt: java.time.OffsetDateTime
|
||||
): List<UUID>
|
||||
|
||||
@Query("""
|
||||
select rs
|
||||
from RoomStay rs
|
||||
where rs.booking.id = :bookingId
|
||||
and rs.toAt is null
|
||||
""")
|
||||
fun findActiveByBookingId(@Param("bookingId") bookingId: UUID): List<RoomStay>
|
||||
|
||||
@Query("""
|
||||
select rs
|
||||
from RoomStay rs
|
||||
where rs.booking.id = :bookingId
|
||||
""")
|
||||
fun findByBookingId(@Param("bookingId") bookingId: UUID): List<RoomStay>
|
||||
|
||||
@Query("""
|
||||
select rs
|
||||
from RoomStay rs
|
||||
join fetch rs.room r
|
||||
where rs.booking.id = :bookingId
|
||||
""")
|
||||
fun findByBookingIdWithRoom(@Param("bookingId") bookingId: UUID): List<RoomStay>
|
||||
|
||||
@Query("""
|
||||
select rs
|
||||
from RoomStay rs
|
||||
where rs.booking.id in :bookingIds
|
||||
""")
|
||||
fun findByBookingIdIn(@Param("bookingIds") bookingIds: List<UUID>): List<RoomStay>
|
||||
|
||||
@Query("""
|
||||
select rs.room.id
|
||||
from RoomStay rs
|
||||
where rs.property.id = :propertyId
|
||||
and rs.room.id in :roomIds
|
||||
and rs.toAt is null
|
||||
""")
|
||||
fun findActiveRoomIds(
|
||||
@Param("propertyId") propertyId: UUID,
|
||||
@Param("roomIds") roomIds: List<UUID>
|
||||
): List<UUID>
|
||||
|
||||
@Query("""
|
||||
select case when count(rs) > 0 then true else false end
|
||||
from RoomStay rs
|
||||
where rs.property.id = :propertyId
|
||||
and rs.room.id = :roomId
|
||||
and rs.fromAt < :toAt
|
||||
and (rs.toAt is null or rs.toAt > :fromAt)
|
||||
""")
|
||||
fun existsOverlap(
|
||||
@Param("propertyId") propertyId: UUID,
|
||||
@Param("roomId") roomId: UUID,
|
||||
@Param("fromAt") fromAt: java.time.OffsetDateTime,
|
||||
@Param("toAt") toAt: java.time.OffsetDateTime
|
||||
): Boolean
|
||||
|
||||
@Query("""
|
||||
select rs
|
||||
from RoomStay rs
|
||||
join fetch rs.room r
|
||||
join fetch r.roomType rt
|
||||
join fetch rs.booking b
|
||||
left join fetch b.primaryGuest g
|
||||
where rs.property.id = :propertyId
|
||||
and rs.toAt is null
|
||||
order by r.roomNumber
|
||||
""")
|
||||
fun findActiveByPropertyIdWithDetails(@Param("propertyId") propertyId: UUID): List<RoomStay>
|
||||
|
||||
@Query("""
|
||||
select case when count(rs) > 0 then true else false end
|
||||
from RoomStay rs
|
||||
where rs.room.id = :roomId
|
||||
""")
|
||||
fun existsByRoomId(@Param("roomId") roomId: UUID): Boolean
|
||||
|
||||
@Query("""
|
||||
select rs.booking.id as bookingId, r.roomNumber as roomNumber
|
||||
from RoomStay rs
|
||||
join rs.room r
|
||||
where rs.booking.id in :bookingIds
|
||||
and rs.toAt is null
|
||||
""")
|
||||
fun findActiveRoomNumbersByBookingIds(
|
||||
@Param("bookingIds") bookingIds: List<UUID>
|
||||
): List<BookingRoomNumberRow>
|
||||
}
|
||||
|
||||
interface BookingRoomNumberRow {
|
||||
val bookingId: UUID
|
||||
val roomNumber: Int
|
||||
}
|
||||
Reference in New Issue
Block a user