Interface UserService

All Known Implementing Classes:
UserServiceImpl

public interface UserService
Service interface for managing User entities. Define methods for CRUD operations and querying users.
  • Method Details

    • create

      User create(User user)
      Creates a new user. If user has role 'tutor', a tutor corresponding to that user is also created.
      Parameters:
      user - the user to create
      Returns:
      the created User
      Throws:
      EntityExistsException - if a user with the same email or phone already exists
    • findById

      User findById(Long id)
      Retrieves an user by its unique identifier.
      Parameters:
      id - the unique identifier of the user
      Returns:
      the found User
      Throws:
      EntityNotFoundException - if no user with the given ID is found
    • findByEmail

      User findByEmail(String email)
      Retrieves a user by its email.
      Parameters:
      email - the email of the user
      Returns:
      the found User
      Throws:
      EntityNotFoundException - if no user with the given email is found
    • findByVerificationToken

      User findByVerificationToken(String token)
      Retrieves a user by its token.
      Parameters:
      token - the verification token of the user
      Returns:
      the found User
      Throws:
      EntityNotFoundException - if no user with the given token is found
    • findAll

      Page<User> findAll(int pageNumber, int pageSize)
      Retrieves a paginated list of users.
      Parameters:
      pageNumber - the page number (starting from 0)
      pageSize - the number of users per page
      Returns:
      a Page containing the requested users
    • update

      void update(User user, Long id)
      Updates an existing user.
      Parameters:
      user - the updated user data
      id - the unique identifier of the user to update
      Throws:
      EntityNotFoundException - if no user with the given ID is found
      EntityExistsException - if a user with the same email or phone already exists
    • delete

      void delete(Long id)
      Deletes a user by its unique identifier.
      Parameters:
      id - the unique identifier of the user to delete
    • verifyUserByVerificationToken

      void verifyUserByVerificationToken(String token)
      Verifies user in system by his verification token.
      Parameters:
      token - verification token of the user