Interface UserRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<User,,String> org.springframework.data.jpa.repository.JpaRepository<User,,String> org.springframework.data.jpa.repository.JpaSpecificationExecutor<User>,org.springframework.data.repository.PagingAndSortingRepository<User,,String> org.springframework.data.repository.query.QueryByExampleExecutor<User>,org.springframework.data.repository.Repository<User,String>
@Repository
public interface UserRepository
extends org.springframework.data.jpa.repository.JpaRepository<User,String>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<User>
Repository user table.
-
Method Summary
Modifier and TypeMethodDescriptionlongcountAllByCompany(Integer companyIdentifier) Count Users for a Company.org.springframework.data.domain.Page<User>findAllFiltered(String firstname, String lastname, String documentId, String email, String phone, Integer companyIdentifier, String companyName, String companyRuc, org.springframework.data.domain.Pageable pageable) Find Users for a Company filtered.findOneByIdAndCompanyId(String id, String companyId) Find an user in DB by its id and company.findOneByOnboardingId(String onboardingId) Find an user in DB by its onboardingId.findOneByOnboardingIdAndCompanyId(String onboardingId, String companyId) Find an user in DB by its onboardingId and company.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getOne, getReferenceById, saveAll, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, exists, findAll, findAll, findAll, findOneMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findOneByIdAndCompanyId
Find an user in DB by its id and company.- Parameters:
id- user identifier.companyId- entity identifier.- Returns:
- the user entity if found.
-
findOneByOnboardingIdAndCompanyId
Find an user in DB by its onboardingId and company.- Parameters:
onboardingId- user identifier.companyId- entity identifier.- Returns:
- the user entity if found.
-
findOneByOnboardingId
@Query("SELECT u FROM User u WHERE u.onboardingId = :onboardingId") Optional<User> findOneByOnboardingId(@Param("onboardingId") String onboardingId) Find an user in DB by its onboardingId.- Parameters:
onboardingId- user identifier.- Returns:
- the user entity if found.
-
findAllFiltered
@Query(value="SELECT u FROM User u LEFT JOIN UserCompany uc ON u.id = uc.user.id WHERE (UPPER(u.name) LIKE UPPER(CONCAT(\'%\',:firstname,\'%\')) OR :firstname IS NULL) AND (UPPER(u.surname) LIKE UPPER(CONCAT(\'%\',:lastname,\'%\')) OR :lastname IS NULL) AND (UPPER(u.documentId) LIKE UPPER(CONCAT(\'%\',:documentId,\'%\')) OR :documentId IS NULL) AND (UPPER(u.email) LIKE UPPER(CONCAT(\'%\',:email,\'%\')) OR :email IS NULL) AND (UPPER(u.phone) LIKE UPPER(CONCAT(\'%\',:phone,\'%\')) OR :phone IS NULL) AND (UPPER(uc.company.name) LIKE UPPER(CONCAT(\'%\',:companyName,\'%\')) OR :companyName IS NULL) AND (UPPER(uc.company.ruc) LIKE UPPER(CONCAT(\'%\',:companyRuc,\'%\')) OR :companyRuc IS NULL) AND (uc.company.id = :companyIdentifier OR :companyIdentifier IS NULL)", countQuery="SELECT COUNT(u) FROM User u LEFT JOIN UserCompany uc ON u.id = uc.user.id WHERE (UPPER(u.name) LIKE UPPER(CONCAT(\'%\',:firstname,\'%\')) OR :firstname IS NULL) AND (UPPER(u.surname) LIKE UPPER(CONCAT(\'%\',:lastname,\'%\')) OR :lastname IS NULL) AND (UPPER(u.documentId) LIKE UPPER(CONCAT(\'%\',:documentId,\'%\')) OR :documentId IS NULL) AND (UPPER(u.email) LIKE UPPER(CONCAT(\'%\',:email,\'%\')) OR :email IS NULL) AND (UPPER(u.phone) LIKE UPPER(CONCAT(\'%\',:phone,\'%\')) OR :phone IS NULL) AND (UPPER(uc.company.name) LIKE UPPER(CONCAT(\'%\',:companyName,\'%\')) OR :companyName IS NULL) AND (UPPER(uc.company.ruc) LIKE UPPER(CONCAT(\'%\',:companyRuc,\'%\')) OR :companyRuc IS NULL) AND (uc.company.id = :companyIdentifier OR :companyIdentifier IS NULL)") org.springframework.data.domain.Page<User> findAllFiltered(@Param("firstname") String firstname, @Param("lastname") String lastname, @Param("documentId") String documentId, @Param("email") String email, @Param("phone") String phone, @Param("companyIdentifier") Integer companyIdentifier, @Param("companyName") String companyName, @Param("companyRuc") String companyRuc, org.springframework.data.domain.Pageable pageable) Find Users for a Company filtered.- Parameters:
firstname- user first name.lastname- user last name.documentId- user document.email- user email.phone- user phone.companyIdentifier- Company Identifier.companyName- Company Name.companyRuc- Company Ruc.pageable- Pageable config.- Returns:
- the list of users with pagination.
-
countAllByCompany
@Query("SELECT COUNT(u) FROM User u LEFT JOIN UserCompany uc ON u.id = uc.user.id WHERE uc.company.id = :companyIdentifier") long countAllByCompany(@Param("companyIdentifier") Integer companyIdentifier) Count Users for a Company.- Parameters:
companyIdentifier- Company Identifier.- Returns:
- the number of users.
-