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 Details

    • findUserById

      ViewUserDto findUserById(Long id)
      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

      ViewUserDto findUserByEmail(String email)
      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

      ViewUserDto createUserWithDefaultRole(CreateUserDto createUserDto)
      Creates a new user with default USER role about UserRole, 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

      ViewUserDto updateUser(Long id, UpdateUserDto updateUserDto)
      updates an existing user as long as the current password is confirmed during the update.
      Parameters:
      id - the ID of the user to update
      updateUserDto - 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 exists
      ChangePasswordIncorrectException - if the current password provided does not match the user's existing password
    • deleteUserById

      ViewUserDto deleteUserById(Long id)
      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

      ViewUserDto deleteUserByEmail(String email)
      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