Interface UserService
- All Known Implementing Classes:
UserServiceImpl
public interface UserService
Service interface for managing user operations.
This interface defines methods for finding, creating, updating, and deleting users.
It also includes methods for handling user-related exceptions.
- Since:
- 1.0.0
- Author:
- Fernando Cruz Cavina
-
Method Summary
Modifier and TypeMethodDescriptioncreateUserWithDefaultRole
(CreateUserDto createUserDto) Creates a new user with default USER role aboutUserRole
, in other words, a client of user service.deleteUserByEmail
(String email) Deletes a user by their email.deleteUserById
(Long id) Deletes a user by their ID.findUserByEmail
(String email) Finds a user by their email.findUserById
(Long id) Finds a user by their ID.updateUser
(Long id, UpdateUserDto updateUserDto) updates an existing user as long as the current password is confirmed during the update.
-
Method Details
-
findUserById
Finds a user by their ID.- Parameters:
id
- the ID of the user to find- Returns:
- the user details which includes ID, username, email, role, phone, cpf, birthdate and creation date
- Throws:
UserNotFoundException
- if no user with the given ID exists
-
findUserByEmail
Finds a user by their email.- Parameters:
email
- the email of the user to find- Returns:
- the user details which includes ID, username, email, role, phone, cpf, birthdate and creation date
- Throws:
UserNotFoundException
- if no user with the given email exists
-
createUserWithDefaultRole
Creates a new user with default USER role aboutUserRole
, in other words, a client of user service.- Parameters:
createUserDto
- the details of the user to create- Returns:
- the created user details which includes ID, username, email, role, phone, cpf, birthdate and creation date
- Throws:
UserAlreadyExistException
- if a user with the same email already exists
-
updateUser
updates an existing user as long as the current password is confirmed during the update.- Parameters:
id
- the ID of the user to updateupdateUserDto
- the new details for the user- Returns:
- the updated user details which includes ID, username, email, role, phone, cpf, birthdate and creation date
- Throws:
UserNotFoundException
- if no user with the given ID existsChangePasswordIncorrectException
- if the current password provided does not match the user's existing password
-
deleteUserById
Deletes a user by their ID.- Parameters:
id
- the ID of the user to delete- Returns:
- the deleted user details which includes ID, username, email, role, phone, cpf, birthdate and creation date
- Throws:
UserNotFoundException
- if no user with the given ID exists
-
deleteUserByEmail
Deletes a user by their email.- Parameters:
email
- the email of the user to delete- Returns:
- the deleted user details which includes ID, username, email, role, phone, cpf, birthdate and creation date
- Throws:
UserNotFoundException
- if no user with the given email exists
-