Package com.myhrcrmproject.controller
Class UserDetailsController
java.lang.Object
com.myhrcrmproject.controller.UserDetailsController
Controller class for managing user details-related operations in the HR CRM system.
This class defines RESTful APIs for various user details actions, including retrieving all user details, finding user details by ID, updating user details, deleting user details, and setting user roles. It requires an admin role for access.
- Version:
- 1.0
- Author:
- Denys Chaykovskyy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEndpoint to delete a user detail.org.springframework.http.ResponseEntity<List<UserDetailsResponseDTO>>findAll()Endpoint to retrieve a list of all user details.org.springframework.http.ResponseEntity<UserDetailsResponseDTO>Endpoint to retrieve a user detail by its ID.org.springframework.http.ResponseEntity<UserDetailsShortResponseDTO>Updates an user detail's role.org.springframework.http.ResponseEntity<UserDetailsResponseDTO>update(Integer id, UserDetailsRequestDTO requestDTO) Endpoint to update an existing user detail.
-
Constructor Details
-
UserDetailsController
public UserDetailsController()
-
-
Method Details
-
findAll
Endpoint to retrieve a list of all user details.- Returns:
- A
ResponseEntitywith a list ofUserDetailsResponseDTOrepresenting all user details.
-
findById
@GetMapping("/{id}") public org.springframework.http.ResponseEntity<UserDetailsResponseDTO> findById(@PathVariable("id") Integer id) Endpoint to retrieve a user detail by its ID.- Parameters:
id- The ID of the user detail to retrieve.- Returns:
- A
ResponseEntitywith theUserDetailsResponseDTOrepresenting the retrieved user detail.
-
update
@PutMapping("/{id}") public org.springframework.http.ResponseEntity<UserDetailsResponseDTO> update(@PathVariable("id") Integer id, @RequestBody UserDetailsRequestDTO requestDTO) Endpoint to update an existing user detail.- Parameters:
id- The ID of the user detail to update.requestDTO- The request body containing updated user detail.- Returns:
- A
ResponseEntitywith theUserDetailsResponseDTOrepresenting the updated user detail.
-
delete
@DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void delete(@PathVariable("id") Integer id) Endpoint to delete a user detail.- Parameters:
id- The ID of the user detail to delete.
-
setRole
@PutMapping("/setRole") public org.springframework.http.ResponseEntity<UserDetailsShortResponseDTO> setRole(@RequestParam("id") Integer id, @RequestParam("role") String request) Updates an user detail's role. Requires admin role.- Parameters:
id- The ID of the user detail to update.request- The role to set for the user detail.- Returns:
- A
ResponseEntitywith the updated user detail details and HTTP status code 202 (Accepted).
-