java.lang.Object
com.fiap.tech_challenge.parte1.ms_users.services.UsersService

@Service public class UsersService extends Object
Service class responsible for managing user operations such as creation, update, retrieval, password changes, and activation status.
  • Constructor Details

  • Method Details

    • findById

      public UsersResponseDTO findById(UUID id)
      Retrieves a user by ID, including their associated addresses.
      Parameters:
      id - the user ID
      Returns:
      the user response DTO
      Throws:
      UserNotFoundException - if the user is not found
    • findAllUsers

      public List<UsersResponseDTO> findAllUsers(int size, int page)
      Retrieves a paginated list of all users and their addresses.
      Parameters:
      size - page size
      page - page number
      Returns:
      list of user response DTOs
    • createUser

      @Transactional public UsersResponseDTO createUser(UsersRequestDTO dto)
      Creates a new user and saves their associated addresses.
      Parameters:
      dto - the user request DTO
      Returns:
      the created user response DTO
    • deactivateUser

      public void deactivateUser(UUID id)
      Deactivates a user by ID.
      Parameters:
      id - the user ID
      Throws:
      UserNotFoundException - if the user is not found
    • reactivateUser

      public void reactivateUser(UUID id)
      Reactivates a previously deactivated user.
      Parameters:
      id - the user ID
      Throws:
      UserNotFoundException - if the user is not found
    • changePassword

      public void changePassword(UUID id, @Valid @Valid ChangePasswordRequestDTO dto)
      Changes the password of a user after validating the old password.
      Parameters:
      id - the user ID
      dto - the change password request DTO
      Throws:
      UserNotFoundException - if the user is not found
    • updateUser

      @Transactional public UsersResponseDTO updateUser(UUID id, UpdateUserDTO dto)
      Updates user information including name, email, login, and address.
      Parameters:
      id - the user ID
      dto - the update user DTO
      Returns:
      the updated user response DTO