Interface UserRepository

All Known Implementing Classes:
UserRepositoryImpl

public interface UserRepository
Repository interface for managing User entities. Provides methods for querying, saving, updating, and managing user records.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    changePassword(UUID id, String password)
    Changes the password for the specified user.
    void
    Deactivates the user account identified by the given UUID.
    boolean
    emailAlreadyExistsForDifferentUsers(@Email String email, @UUID UUID uuid)
    Checks if an email is already associated with a different user than the one specified.
    boolean
    existsByEmail(@NotBlank(message="User field \'email\' is required") @Email(message="User field \'email\' must be a valid email address") String email)
    Checks if a user exists with the given email.
    boolean
    existsByLogin(@NotBlank(message="User field \'login\' is required") String login)
    Checks if a user exists with the given login.
    findAll(int size, int offset)
    Retrieves a paginated list of users.
    Finds a user by their unique identifier.
    Finds a user by their login (username or email).
    boolean
    loginAlreadyExistsForDifferentUsers(@Email String login, @UUID UUID uuid)
    Checks if a login is already associated with a different user than the one specified.
    void
    Reactivates the user account identified by the given UUID.
    save(User user)
    Saves a new user record to the data store.
    void
    update(UUID id, String name, String email, String login, String password)
    Updates an existing user's basic information.
  • Method Details

    • findById

      Optional<User> findById(UUID id)
      Finds a user by their unique identifier.
      Parameters:
      id - the UUID of the user to find
      Returns:
      an Optional containing the User if found, or empty if no user with the given ID exists
    • emailAlreadyExistsForDifferentUsers

      boolean emailAlreadyExistsForDifferentUsers(@Email @Email String email, @UUID @UUID UUID uuid)
      Checks if an email is already associated with a different user than the one specified. Useful for email uniqueness validation during updates.
      Parameters:
      email - the email address to check
      uuid - the UUID of the user to exclude from the check (usually the current user)
      Returns:
      true if the email exists for a different user, false otherwise
    • loginAlreadyExistsForDifferentUsers

      boolean loginAlreadyExistsForDifferentUsers(@Email @Email String login, @UUID @UUID UUID uuid)
      Checks if a login is already associated with a different user than the one specified. Useful for login uniqueness validation during updates.
      Parameters:
      login - the login (username/email) to check
      uuid - the UUID of the user to exclude from the check
      Returns:
      true if the login exists for a different user, false otherwise
    • findByLogin

      Optional<User> findByLogin(String login)
      Finds a user by their login (username or email).
      Parameters:
      login - the login string to search by
      Returns:
      an Optional containing the User if found, or empty if no user with the given login exists
    • findAll

      List<User> findAll(int size, int offset)
      Retrieves a paginated list of users.
      Parameters:
      size - the maximum number of users to return
      offset - the offset from the start of the user list (used for pagination)
      Returns:
      a list of User entities
    • save

      UUID save(User user)
      Saves a new user record to the data store.
      Parameters:
      user - the User entity to save
      Returns:
      the UUID assigned to the saved user
    • update

      void update(UUID id, String name, String email, String login, String password)
      Updates an existing user's basic information.
      Parameters:
      id - the UUID of the user to update
      name - the new name for the user
      email - the new email for the user
      login - the new login for the user
      password - the new password for the user (should be hashed)
    • existsByEmail

      boolean existsByEmail(@NotBlank(message="User field \'email\' is required") @Email(message="User field \'email\' must be a valid email address") @NotBlank(message="User field \'email\' is required") @Email(message="User field \'email\' must be a valid email address") String email)
      Checks if a user exists with the given email.
      Parameters:
      email - the email address to check; must not be blank and must be valid
      Returns:
      true if a user with the email exists, false otherwise
    • existsByLogin

      boolean existsByLogin(@NotBlank(message="User field \'login\' is required") @NotBlank(message="User field \'login\' is required") String login)
      Checks if a user exists with the given login.
      Parameters:
      login - the login string to check; must not be blank
      Returns:
      true if a user with the login exists, false otherwise
    • deactivate

      void deactivate(UUID id)
      Deactivates the user account identified by the given UUID. Typically, sets an 'active' flag to false or similar.
      Parameters:
      id - the UUID of the user to deactivate
    • reactivate

      void reactivate(UUID id)
      Reactivates the user account identified by the given UUID. Typically, sets an 'active' flag to true or similar.
      Parameters:
      id - the UUID of the user to reactivate
    • changePassword

      void changePassword(UUID id, String password)
      Changes the password for the specified user.
      Parameters:
      id - the UUID of the user whose password will be changed
      password - the new password (should be hashed before saving)