Class UserDAO
java.lang.Object
com.JesacaLin.GrubGoblin_v13.daos.UserDAO
DAO class for managing User entities in the database.
-
Constructor Summary
ConstructorsConstructorDescriptionUserDAO
(DataSource dataSource, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) Constructs a new UserDAO with the given DataSource and PasswordEncoder. -
Method Summary
Modifier and TypeMethodDescriptionaddRoleToUser
(String username, String role) Adds a role to a User.createUser
(User user) Creates a new User.int
deleteUser
(String username) Deletes a User by its username.Retrieves all Users.getRolesForUser
(String username) Retrieves all roles for a specific User.getUserByUsername
(String username) Retrieves a User by its username.void
removeRoleFromUser
(String username, String role) Removes a role from a User.updateUser
(String username, User user) Updates a User.
-
Constructor Details
-
UserDAO
public UserDAO(DataSource dataSource, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) Constructs a new UserDAO with the given DataSource and PasswordEncoder.- Parameters:
dataSource
- the DataSource to use for database accesspasswordEncoder
- the PasswordEncoder to use for password hashing
-
-
Method Details
-
getAllUsers
-
getUserByUsername
-
createUser
-
updateUser
-
deleteUser
Deletes a User by its username.- Parameters:
username
- the username of the User to delete- Returns:
- the number of rows affected by the delete
-
getRolesForUser
-
addRoleToUser
-
removeRoleFromUser
-