Class UserDetailsController

java.lang.Object
com.myhrcrmproject.controller.UserDetailsController

@RestController @RequestMapping("api/users") public class UserDetailsController extends Object
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 Details

    • UserDetailsController

      public UserDetailsController()
  • Method Details

    • findAll

      @GetMapping public org.springframework.http.ResponseEntity<List<UserDetailsResponseDTO>> findAll()
      Endpoint to retrieve a list of all user details.
      Returns:
      A ResponseEntity with a list of UserDetailsResponseDTO representing 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 ResponseEntity with the UserDetailsResponseDTO representing 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 ResponseEntity with the UserDetailsResponseDTO representing 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 ResponseEntity with the updated user detail details and HTTP status code 202 (Accepted).