added auth,property db and room db,org db
This commit is contained in:
@@ -10,6 +10,32 @@ 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
|
||||
@@ -22,4 +48,17 @@ interface PropertyUserRepo : JpaRepository<PropertyUser, PropertyUserId> {
|
||||
@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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user