Interface UserRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<User,​java.lang.Long>, org.springframework.data.jpa.repository.JpaRepository<User,​java.lang.Long>, org.springframework.data.repository.PagingAndSortingRepository<User,​java.lang.Long>, org.springframework.data.repository.query.QueryByExampleExecutor<User>, org.springframework.data.repository.Repository<User,​java.lang.Long>

@Repository
public interface UserRepository
extends org.springframework.data.jpa.repository.JpaRepository<User,​java.lang.Long>
UserRepository.getByAuthority: Return list of: SELECT * FROM User WHERE email = i. Where i, ?1 are equale to variables. UserRepository.getByToken: Return list of: SELECT * FROM User WHERE token = i. Where i, ?1 are equale to variables. UserRepository.searchForUsers: Return list of: SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%). Where i, ?1 are equale to variables. UserRepository.searchForUsers with role: Return list of: SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2"). Where i, ?1 are equale to variables.
  • Method Summary

    Modifier and Type Method Description
    java.util.List<User> getAllByRole​(UserRoles role)  
    java.util.Optional<User> getByAuthority​(java.lang.String authority)
    return user by given authority
    java.util.Optional<User> getByEmail​(java.lang.String authority)  
    java.util.Optional<User> getByRefreshToken​(java.lang.String refreshToken)  
    java.util.Optional<User> getByToken​(java.lang.String token)  
    java.util.Optional<User> getByUsosId​(java.lang.String usosId)  
    java.util.List<User> searchForUsers​(java.lang.String query)  
    java.util.List<User> searchForUsers​(java.lang.String query, UserRoles role)
    search for user with given query

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findOne
  • Method Details

    • getByAuthority

      @Query("FROM User WHERE email = ?1 OR usosId = ?1") java.util.Optional<User> getByAuthority​(@Param("authority") java.lang.String authority)
      return user by given authority
      Parameters:
      authority - user usosId or email
      Returns:
      optional with user if found
    • getByEmail

      @Query("FROM User WHERE email = ?1") java.util.Optional<User> getByEmail​(@Param("authority") java.lang.String authority)
    • getByRefreshToken

      @Query("FROM User WHERE refreshToken = ?1") java.util.Optional<User> getByRefreshToken​(@Param("refreshToken") java.lang.String refreshToken)
    • getByToken

      @Query("FROM User WHERE token = ?1") java.util.Optional<User> getByToken​(@Param("token") java.lang.String token)
    • searchForUsers

      @Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%)") java.util.List<User> searchForUsers​(@Param("query") java.lang.String query)
    • searchForUsers

      @Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2") java.util.List<User> searchForUsers​(@Param("query") java.lang.String query, @Param("role") UserRoles role)
      search for user with given query
      Parameters:
      query - string that will be matched to users name and surname
      role - limits results by role
      Returns:
      list opf results
    • getAllByRole

      @Query("FROM User WHERE role=?1") java.util.List<User> getAllByRole​(@Param("role") UserRoles role)
    • getByUsosId

      @Query("FROM User WHERE usosId = ?1") java.util.Optional<User> getByUsosId​(@Param("usosId") java.lang.String usosId)