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

@@ -1,11 +0,0 @@
package com.android.trisolarisserver.db.repo
import com.android.trisolarisserver.models.property.AppUser
import org.springframework.data.jpa.repository.JpaRepository
import java.util.UUID
interface AppUserRepo : JpaRepository<AppUser, UUID> {
fun findByFirebaseUid(firebaseUid: String): AppUser?
fun existsByFirebaseUid(firebaseUid: String): Boolean
fun findByOrgId(orgId: UUID): List<AppUser>
}

View File

@@ -1,11 +0,0 @@
package com.android.trisolarisserver.db.repo
import com.android.trisolarisserver.models.property.Organization
import org.springframework.data.jpa.repository.JpaRepository
import java.util.UUID
interface OrganizationRepo : JpaRepository<Organization, UUID> {
fun findByName(name: String): Organization?
fun findByNameIgnoreCase(name: String): Organization?
fun existsByNameIgnoreCase(name: String): Boolean
}

View File

@@ -1,10 +0,0 @@
package com.android.trisolarisserver.db.repo
import com.android.trisolarisserver.models.property.Property
import org.springframework.data.jpa.repository.JpaRepository
import java.util.UUID
interface PropertyRepo : JpaRepository<Property, UUID> {
fun existsByOrgIdAndCode(orgId: UUID, code: String): Boolean
fun existsByOrgIdAndCodeAndIdNot(orgId: UUID, code: String, id: UUID): Boolean
}

View File

@@ -1,64 +0,0 @@
package com.android.trisolarisserver.db.repo
import com.android.trisolarisserver.models.property.*
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 PropertyUserRepo : JpaRepository<PropertyUser, PropertyUserId> {
fun existsByIdPropertyIdAndIdUserId(propertyId: UUID, userId: UUID): Boolean
fun findByIdUserId(userId: UUID): List<PropertyUser>
fun findByIdPropertyId(propertyId: UUID): List<PropertyUser>
@Query("""
select r
from PropertyUser pu join pu.roles r
where pu.id.propertyId = :propertyId
and pu.id.userId = :userId
""")
fun findRolesByPropertyAndUser(
@Param("propertyId") propertyId: UUID,
@Param("userId") userId: UUID
): Set<Role>
@Query("""
select pu.property.id
from PropertyUser pu
where pu.user.id = :userId
and pu.property.org.id = :orgId
""")
fun findPropertyIdsByOrgAndUser(
@Param("orgId") orgId: UUID,
@Param("userId") userId: UUID
): List<UUID>
@Query("""
select case when count(pu) > 0 then true else false end
from PropertyUser pu join pu.roles r
where pu.id.propertyId = :propertyId
and pu.id.userId = :userId
and r in :roles
""")
fun hasAnyRole(
@Param("propertyId") propertyId: UUID,
@Param("userId") userId: UUID,
@Param("roles") roles: Set<Role>
): Boolean
@Query("""
select case when count(pu) > 0 then true else false end
from PropertyUser pu join pu.roles r
where pu.user.id = :userId
and pu.property.org.id = :orgId
and r in :roles
""")
fun hasAnyRoleInOrg(
@Param("orgId") orgId: UUID,
@Param("userId") userId: UUID,
@Param("roles") roles: Set<Role>
): Boolean
}

View File

@@ -1,48 +0,0 @@
package com.android.trisolarisserver.db.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>
}

View File

@@ -1,17 +0,0 @@
package com.android.trisolarisserver.db.repo
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>
}

View File

@@ -1,14 +0,0 @@
package com.android.trisolarisserver.db.repo
import com.android.trisolarisserver.models.room.RoomType
import org.springframework.data.jpa.repository.EntityGraph
import org.springframework.data.jpa.repository.JpaRepository
import java.util.UUID
interface RoomTypeRepo : JpaRepository<RoomType, UUID> {
fun findByIdAndPropertyId(id: UUID, propertyId: UUID): RoomType?
@EntityGraph(attributePaths = ["property"])
fun findByPropertyIdOrderByCode(propertyId: UUID): List<RoomType>
fun existsByPropertyIdAndCode(propertyId: UUID, code: String): Boolean
fun existsByPropertyIdAndCodeAndIdNot(propertyId: UUID, code: String, id: UUID): Boolean
}