move card issuence server side
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.android.trisolarisserver.repo
|
||||
|
||||
import com.android.trisolarisserver.models.room.IssuedCard
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import java.util.UUID
|
||||
|
||||
interface IssuedCardRepo : JpaRepository<IssuedCard, UUID> {
|
||||
fun findByRoomStayIdOrderByIssuedAtDesc(roomStayId: UUID): List<IssuedCard>
|
||||
fun findByIdAndPropertyId(id: UUID, propertyId: UUID): IssuedCard?
|
||||
|
||||
@org.springframework.data.jpa.repository.Query("""
|
||||
select case when count(c) > 0 then true else false end
|
||||
from IssuedCard c
|
||||
where c.property.id = :propertyId
|
||||
and c.room.id = :roomId
|
||||
and c.revokedAt is null
|
||||
and c.expiresAt > :now
|
||||
""")
|
||||
fun existsActiveForRoom(
|
||||
@org.springframework.data.repository.query.Param("propertyId") propertyId: UUID,
|
||||
@org.springframework.data.repository.query.Param("roomId") roomId: UUID,
|
||||
@org.springframework.data.repository.query.Param("now") now: java.time.OffsetDateTime
|
||||
): Boolean
|
||||
|
||||
@org.springframework.data.jpa.repository.Query("""
|
||||
select case when count(c) > 0 then true else false end
|
||||
from IssuedCard c
|
||||
where c.roomStay.id = :roomStayId
|
||||
and c.revokedAt is null
|
||||
and c.expiresAt > :now
|
||||
""")
|
||||
fun existsActiveForRoomStay(
|
||||
@org.springframework.data.repository.query.Param("roomStayId") roomStayId: UUID,
|
||||
@org.springframework.data.repository.query.Param("now") now: java.time.OffsetDateTime
|
||||
): Boolean
|
||||
}
|
||||
Reference in New Issue
Block a user