User management
This commit is contained in:
@@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,9 +14,16 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
|
||||
UserEntity findByBeneficiaryId(Long beneficiaryId);
|
||||
|
||||
Optional<UserEntity> findByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||
// Optional<UserEntity> findByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||
|
||||
boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||
@Query("SELECT u FROM UserEntity u WHERE LOWER(u.email) = LOWER(:email) AND u.hub.uniqueUuid = :hubUuid AND u.roleEntity.roleType <> :roleType")
|
||||
Optional<UserEntity> findUserExcludingRoleType(
|
||||
@Param("email") String email,
|
||||
@Param("hubUuid") String hubUuid,
|
||||
@Param("roleType") String roleType
|
||||
);
|
||||
|
||||
// boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||
|
||||
List<UserEntity> findByRoleEntityIdAndHubId(Long roleId, Long hubId);
|
||||
|
||||
@@ -24,5 +33,22 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
|
||||
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||
|
||||
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||
Boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||
|
||||
@Query("SELECT COUNT(u) > 0 " +
|
||||
"FROM UserEntity u " +
|
||||
"WHERE u.email = :email " +
|
||||
"AND u.hub.uniqueUuid = :hubUuid " +
|
||||
"AND u.roleEntity.roleType <> :beneficiaryRoleType")
|
||||
Boolean existsByEmailIgnoreCaseForNonBeneficiaries(@Param("email") String email,
|
||||
@Param("hubUuid") String hubUuid,
|
||||
@Param("beneficiaryRoleType") String beneficiaryRoleType);
|
||||
|
||||
@Query("SELECT CASE WHEN COUNT(u) > 0 THEN true ELSE false END " +
|
||||
"FROM UserEntity u " +
|
||||
"WHERE LOWER(u.email) = LOWER(:email) AND u.hub.uniqueUuid = :hubUuid " +
|
||||
"AND u.roleEntity.roleType = :beneficiaryRoleType")
|
||||
Boolean existsByEmailIgnoreCaseForBeneficiaries(String email, String hubUuid, String beneficiaryRoleType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user