Class DBAppUserDao
java.lang.Object
com.example.wellbeing_project.universal.DBAppUserDao
- All Implemented Interfaces:
IAppUserDAO
Data Access Object (DAO) class for managing AppUser data in the database
Implements the IAppUserDAO interface.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new user to the database.void
deleteUser
(AppUser appUser) Deletes a user from the database.Retrieves a list of all users from the database.getUser
(int userId) Retrieves the user with the specified ID from the database.getUserByEmail
(String email) Retrieves the user with the specified email from the database.void
updateUser
(AppUser appUser) Updates the user entry in the database.boolean
verifyPassword
(String plainTextPassword, String hashedPassword) Verifies whether the proved plain text password match the hashed password.
-
Constructor Details
-
DBAppUserDao
public DBAppUserDao()Constructor for the DBAppUserDao Class. Initializes the database connection.
-
-
Method Details
-
addUser
Adds a new user to the database.- Specified by:
addUser
in interfaceIAppUserDAO
- Parameters:
appUser
- the AppUser object to be added to the database.
-
verifyPassword
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
Updates the user entry in the database.- Specified by:
updateUser
in interfaceIAppUserDAO
- Parameters:
appUser
- The AppUser object with updated information.
-
deleteUser
Description copied from interface:IAppUserDAO
Deletes a user from the database.- Specified by:
deleteUser
in interfaceIAppUserDAO
- Parameters:
appUser
- The AppUser object representing the user to be deleted.
-
getUser
Retrieves the user with the specified ID from the database.- Specified by:
getUser
in interfaceIAppUserDAO
- 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
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
Description copied from interface:IAppUserDAO
Retrieves a list of all users from the database.- Specified by:
getAllUsers
in interfaceIAppUserDAO
- Returns:
- A List of AppUser objects representing all users in the database.
-