Class UserRepositoryImpl

java.lang.Object
org.example.crmedu.infrastructure.repository.user.UserRepositoryImpl
All Implemented Interfaces:
UserRepository

@Component public class UserRepositoryImpl extends Object implements UserRepository
Implementation of the UserRepository interface using JPA. Provides methods for managing User entities in the database.
  • Constructor Details

    • UserRepositoryImpl

      public UserRepositoryImpl()
  • Method Details

    • findAll

      public Page<User> findAll(int pageNumber, int pageSize)
      Description copied from interface: UserRepository
      Retrieves a paginated list of users.
      Specified by:
      findAll in interface UserRepository
      Parameters:
      pageNumber - the page number (starting from 0)
      pageSize - the number of the users per page
      Returns:
      a Page containing the requested users
    • findById

      public Optional<User> findById(Long id)
      Description copied from interface: UserRepository
      Retrieves an user by its unique identifier.
      Specified by:
      findById in interface UserRepository
      Parameters:
      id - the unique identifier of the user
      Returns:
      an Optional containing the user if found, otherwise empty
    • findByEmail

      public Optional<User> findByEmail(String email)
      Description copied from interface: UserRepository
      Retrieves a user by its email.
      Specified by:
      findByEmail in interface UserRepository
      Parameters:
      email - the email of the user
      Returns:
      an Optional containing the user if found, otherwise empty
    • findByVerificationToken

      public Optional<User> findByVerificationToken(String token)
      Description copied from interface: UserRepository
      Retrieves a user by its verification token.
      Specified by:
      findByVerificationToken in interface UserRepository
      Parameters:
      token - the verification token of the user
      Returns:
      an Optional containing the user if found, otherwise empty
    • existsByEmail

      public boolean existsByEmail(User user)
      Description copied from interface: UserRepository
      Checks whether a user with the same email already exists.
      Specified by:
      existsByEmail in interface UserRepository
      Parameters:
      user - the user to check
      Returns:
      true if a user with the same email exists, otherwise false
    • existsByPhone

      public boolean existsByPhone(User user)
      Description copied from interface: UserRepository
      Checks whether a user with the same phone already exists.
      Specified by:
      existsByPhone in interface UserRepository
      Parameters:
      user - the user to check
      Returns:
      true if a user with the same phone exists, otherwise false
    • save

      public User save(User user)
      Description copied from interface: UserRepository
      Saves a new user or updates an existing one.
      Specified by:
      save in interface UserRepository
      Parameters:
      user - the user to save
      Returns:
      the saved User entity
    • update

      public void update(User user)
      Description copied from interface: UserRepository
      Updates an existing user.
      Specified by:
      update in interface UserRepository
      Parameters:
      user - the user entity with updated information
    • delete

      public void delete(Long id)
      Description copied from interface: UserRepository
      Deletes an user by its unique identifier.
      Specified by:
      delete in interface UserRepository
      Parameters:
      id - the unique identifier of the subject to delete.