small rename

This commit is contained in:
androidlover5842
2026-01-24 16:43:04 +05:30
parent 756c0cb671
commit 8d2341a727
14 changed files with 26 additions and 27 deletions

View File

@@ -0,0 +1,48 @@
package com.android.trisolarisserver.repo
import com.android.trisolarisserver.models.room.Room
import org.springframework.data.jpa.repository.EntityGraph
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 RoomRepo : JpaRepository<Room, UUID> {
@EntityGraph(attributePaths = ["roomType"])
fun findByPropertyIdOrderByRoomNumber(propertyId: UUID): List<Room>
fun findByIdAndPropertyId(id: UUID, propertyId: UUID): Room?
fun existsByPropertyIdAndRoomNumber(propertyId: UUID, roomNumber: Int): Boolean
fun existsByPropertyIdAndRoomNumberAndIdNot(propertyId: UUID, roomNumber: Int, id: UUID): Boolean
fun existsByPropertyIdAndRoomTypeId(propertyId: UUID, roomTypeId: UUID): Boolean
@Query("""
select r
from Room r
where r.property.id = :propertyId
and r.active = true
and r.maintenance = false
and not exists (
select 1 from RoomStay rs
where rs.room = r
and rs.toAt is null
)
order by r.roomNumber
""")
fun findFreeRooms(@Param("propertyId") propertyId: UUID): List<Room>
@Query("""
select r
from Room r
join RoomStay rs on rs.room = r
where r.property.id = :propertyId
and rs.toAt is null
order by r.roomNumber
""")
fun findOccupiedRooms(@Param("propertyId") propertyId: UUID): List<Room>
}