java.lang.Object
com.example.wellbeing_project.universal.DBAppUserDao
All Implemented Interfaces:
IAppUserDAO

public class DBAppUserDao extends Object implements IAppUserDAO
Data Access Object (DAO) class for managing AppUser data in the database Implements the IAppUserDAO interface.
  • Constructor Details

    • DBAppUserDao

      public DBAppUserDao()
      Constructor for the DBAppUserDao Class. Initializes the database connection.
  • Method Details

    • addUser

      public void addUser(AppUser appUser)
      Adds a new user to the database.
      Specified by:
      addUser in interface IAppUserDAO
      Parameters:
      appUser - the AppUser object to be added to the database.
    • verifyPassword

      public boolean verifyPassword(String plainTextPassword, String hashedPassword)
      Verifies whether the proved plain text password match the hashed password.
      Parameters:
      plainTextPassword - The plain text password.
      hashedPassword - The hashed password.
      Returns:
      True if the passwords match, false otherwise.
    • updateUser

      public void updateUser(AppUser appUser)
      Updates the user entry in the database.
      Specified by:
      updateUser in interface IAppUserDAO
      Parameters:
      appUser - The AppUser object with updated information.
    • deleteUser

      public void deleteUser(AppUser appUser)
      Description copied from interface: IAppUserDAO
      Deletes a user from the database.
      Specified by:
      deleteUser in interface IAppUserDAO
      Parameters:
      appUser - The AppUser object representing the user to be deleted.
    • getUser

      public AppUser getUser(int userId)
      Retrieves the user with the specified ID from the database.
      Specified by:
      getUser in interface IAppUserDAO
      Parameters:
      userId - The ID of the user to retrieve
      Returns:
      The AppUser object representing the retrieved user.Return null if user is not found.
    • getUserByEmail

      public AppUser getUserByEmail(String email)
      Retrieves the user with the specified email from the database.
      Parameters:
      email - The email of the user to retrieve.
      Returns:
      The AppUser object representing the retrieved user. Return null if user is not found.
    • getAllUsers

      public List<AppUser> getAllUsers()
      Description copied from interface: IAppUserDAO
      Retrieves a list of all users from the database.
      Specified by:
      getAllUsers in interface IAppUserDAO
      Returns:
      A List of AppUser objects representing all users in the database.