Class UserServiceImpl

java.lang.Object
dev.fernando.user_authentication_api.service.impl.UserServiceImpl
All Implemented Interfaces:
UserService

@Service public class UserServiceImpl extends Object implements UserService
  • Constructor Details

    • UserServiceImpl

      @Autowired public UserServiceImpl(UserRepository userRepository, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, UserPublisher userEventPublisher)
  • Method Details

    • findUserById

      public ViewUserDto findUserById(Long id)
      Description copied from interface: UserService
      Finds a user by their ID.
      Specified by:
      findUserById in interface UserService
      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
    • findUserByEmail

      public ViewUserDto findUserByEmail(String email)
      Description copied from interface: UserService
      Finds a user by their email.
      Specified by:
      findUserByEmail in interface UserService
      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
    • createUserWithDefaultRole

      @Transactional public ViewUserDto createUserWithDefaultRole(CreateUserDto createUserDto)
      Description copied from interface: UserService
      Creates a new user with default USER role about UserRole, in other words, a client of user service.
      Specified by:
      createUserWithDefaultRole in interface UserService
      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
    • updateUser

      @Transactional public ViewUserDto updateUser(Long id, UpdateUserDto updateUserDto)
      Description copied from interface: UserService
      updates an existing user as long as the current password is confirmed during the update.
      Specified by:
      updateUser in interface UserService
      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
    • deleteUserById

      @Transactional public ViewUserDto deleteUserById(Long id)
      Description copied from interface: UserService
      Deletes a user by their ID.
      Specified by:
      deleteUserById in interface UserService
      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
    • deleteUserByEmail

      @Transactional public ViewUserDto deleteUserByEmail(String email)
      Description copied from interface: UserService
      Deletes a user by their email.
      Specified by:
      deleteUserByEmail in interface UserService
      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