Add user search and property access code flow
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s
This commit is contained in:
@@ -7,4 +7,5 @@ import java.util.UUID
|
||||
interface AppUserRepo : JpaRepository<AppUser, UUID> {
|
||||
fun findByFirebaseUid(firebaseUid: String): AppUser?
|
||||
fun existsByFirebaseUid(firebaseUid: String): Boolean
|
||||
fun findByPhoneE164Containing(phoneE164: String): List<AppUser>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.android.trisolarisserver.repo.property
|
||||
|
||||
import com.android.trisolarisserver.models.property.PropertyAccessCode
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.data.repository.query.Param
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.UUID
|
||||
|
||||
interface PropertyAccessCodeRepo : JpaRepository<PropertyAccessCode, UUID> {
|
||||
|
||||
@Query(
|
||||
"""
|
||||
select pac
|
||||
from PropertyAccessCode pac
|
||||
where pac.property.id = :propertyId
|
||||
and pac.code = :code
|
||||
and pac.usedAt is null
|
||||
and pac.expiresAt > :now
|
||||
"""
|
||||
)
|
||||
fun findActiveByPropertyAndCode(
|
||||
@Param("propertyId") propertyId: UUID,
|
||||
@Param("code") code: String,
|
||||
@Param("now") now: OffsetDateTime
|
||||
): PropertyAccessCode?
|
||||
|
||||
@Query(
|
||||
"""
|
||||
select case when count(pac) > 0 then true else false end
|
||||
from PropertyAccessCode pac
|
||||
where pac.property.id = :propertyId
|
||||
and pac.code = :code
|
||||
and pac.usedAt is null
|
||||
and pac.expiresAt > :now
|
||||
"""
|
||||
)
|
||||
fun existsActiveByPropertyAndCode(
|
||||
@Param("propertyId") propertyId: UUID,
|
||||
@Param("code") code: String,
|
||||
@Param("now") now: OffsetDateTime
|
||||
): Boolean
|
||||
}
|
||||
@@ -14,6 +14,31 @@ interface PropertyUserRepo : JpaRepository<PropertyUser, PropertyUserId> {
|
||||
|
||||
fun findByIdPropertyId(propertyId: UUID): List<PropertyUser>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
select pu
|
||||
from PropertyUser pu
|
||||
join fetch pu.user u
|
||||
where pu.id.propertyId = :propertyId
|
||||
"""
|
||||
)
|
||||
fun findByPropertyIdWithUser(@Param("propertyId") propertyId: UUID): List<PropertyUser>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
select pu
|
||||
from PropertyUser pu
|
||||
join fetch pu.user u
|
||||
where pu.id.propertyId = :propertyId
|
||||
and u.phoneE164 is not null
|
||||
and u.phoneE164 like concat('%', :phone, '%')
|
||||
"""
|
||||
)
|
||||
fun findByPropertyIdAndPhoneLike(
|
||||
@Param("propertyId") propertyId: UUID,
|
||||
@Param("phone") phone: String
|
||||
): List<PropertyUser>
|
||||
|
||||
@Query("""
|
||||
select r
|
||||
from PropertyUser pu join pu.roles r
|
||||
|
||||
Reference in New Issue
Block a user