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 TypeMethodDescriptionvoid
changePassword
(UUID id, String password) Changes the password for the specified user.void
deactivate
(UUID id) 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.findByLogin
(String login) 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
reactivate
(UUID id) Reactivates the user account identified by the given UUID.Saves a new user record to the data store.void
Updates an existing user's basic information.
-
Method Details
-
findById
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
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 checkuuid
- 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
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 checkuuid
- the UUID of the user to exclude from the check- Returns:
- true if the login exists for a different user, false otherwise
-
findByLogin
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
Retrieves a paginated list of users.- Parameters:
size
- the maximum number of users to returnoffset
- the offset from the start of the user list (used for pagination)- Returns:
- a list of User entities
-
save
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
Updates an existing user's basic information.- Parameters:
id
- the UUID of the user to updatename
- the new name for the useremail
- the new email for the userlogin
- the new login for the userpassword
- 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
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
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
Changes the password for the specified user.- Parameters:
id
- the UUID of the user whose password will be changedpassword
- the new password (should be hashed before saving)
-