Package com.myhrcrmproject.service
Class UserDetailsServiceImpl
java.lang.Object
com.myhrcrmproject.service.UserDetailsServiceImpl
- All Implemented Interfaces:
CommonService<UserDetailsRequestDTO,,UserDetailsResponseDTO> org.springframework.security.core.userdetails.UserDetailsService
@Service
public class UserDetailsServiceImpl
extends Object
implements CommonService<UserDetailsRequestDTO,UserDetailsResponseDTO>, org.springframework.security.core.userdetails.UserDetailsService
Service class that handles CRUD (Create, Read, Update, Delete) operations for user details entities.
This service provides methods to perform operations on user details entities, such as retrieving,
creating, updating, and deleting user details records. It also includes additional methods for setting
user roles and implementing Spring Security's UserDetailsService.
- Version:
- 1.0
- Author:
- Denys Chaykovskyy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(UserDetailsRequestDTO requestDTO) Creates a new user details record based on the provided request DTO.voidDeletes a user details record based on the provided id.findAll()Retrieves a list of all user details records.Retrieves a user details record by its unique identifier.org.springframework.security.core.userdetails.UserDetailsloadUserByUsername(String userName) Loads a user by the given username.Sets the role of a user based on the provided id and role name.update(Integer id, UserDetailsRequestDTO requestDTO) Updates an existing user details record based on the provided id and request DTO.
-
Constructor Details
-
UserDetailsServiceImpl
public UserDetailsServiceImpl()
-
-
Method Details
-
findAll
Retrieves a list of all user details records.- Specified by:
findAllin interfaceCommonService<UserDetailsRequestDTO,UserDetailsResponseDTO> - Returns:
- A list of response DTOs representing all user details records.
-
findById
Retrieves a user details record by its unique identifier.- Specified by:
findByIdin interfaceCommonService<UserDetailsRequestDTO,UserDetailsResponseDTO> - Parameters:
id- The identifier of the user details record to retrieve.- Returns:
- The response DTO representing the retrieved user details record.
- Throws:
NotFoundException- if the user details record with the specified id is not found.
-
create
Creates a new user details record based on the provided request DTO.- Specified by:
createin interfaceCommonService<UserDetailsRequestDTO,UserDetailsResponseDTO> - Parameters:
requestDTO- The request DTO containing information for creating the user details record.- Returns:
- The response DTO representing the created user details record.
- Throws:
AlreadyExistsException- if a user with the specified username already exists.
-
update
Updates an existing user details record based on the provided id and request DTO.- Specified by:
updatein interfaceCommonService<UserDetailsRequestDTO,UserDetailsResponseDTO> - Parameters:
id- The identifier of the user details record to update.requestDTO- The request DTO containing information for updating the user details record.- Returns:
- The response DTO representing the updated user details record.
- Throws:
NotFoundException- if the user details record with the specified id is not found.
-
delete
Deletes a user details record based on the provided id.- Specified by:
deletein interfaceCommonService<UserDetailsRequestDTO,UserDetailsResponseDTO> - Parameters:
id- The identifier of the user details record to delete.- Throws:
NotFoundException- if the user details record with the specified id is not found.
-
setRole
Sets the role of a user based on the provided id and role name.- Parameters:
id- The identifier of the user details record to update.userRole- The name of the role to set.- Returns:
- The short response DTO representing the user details record with the updated role.
- Throws:
NotFoundException- if the user details record with the specified id or the specified role is not found.
-
loadUserByUsername
public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String userName) throws org.springframework.security.core.userdetails.UsernameNotFoundException Loads a user by the given username.- Specified by:
loadUserByUsernamein interfaceorg.springframework.security.core.userdetails.UserDetailsService- Parameters:
userName- The username of the user to load.- Returns:
- The UserDetails object representing the loaded user.
- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException- if the user with the specified username is not found.
-