Class ClientController

java.lang.Object
com.myhrcrmproject.controller.ClientController

@RestController @RequestMapping("api/clients") public class ClientController extends Object
Controller class for managing client-related operations in the HR CRM system.

This class provides RESTful endpoints for retrieving, creating, updating, and deleting client records. It interacts with the ClientService for handling business logic and data access.

Additionally, it includes endpoints for finding clients by their ID, retrieving a list of all clients, creating a new client, updating an existing client, and deleting a client. The IsManager annotation is used to secure the delete operation, requiring the manager role.

The class is annotated with @RestController to indicate its role as a Spring REST controller and is mapped to the "/api/clients" endpoint.

Version:
1.0
Author:
Denys Chaykovskyy
  • Constructor Details

    • ClientController

      public ClientController()
  • Method Details

    • findAll

      @GetMapping public org.springframework.http.ResponseEntity<List<ClientResponseDTO>> findAll()
      Endpoint to retrieve a list of all clients.
      Returns:
      A ResponseEntity with a list of ClientResponseDTO representing all clients.
    • findById

      @GetMapping("/{id}") public org.springframework.http.ResponseEntity<ClientResponseDTO> findById(@PathVariable("id") Integer id)
      Endpoint to retrieve a client by their ID.
      Parameters:
      id - The ID of the client to retrieve.
      Returns:
      A ResponseEntity with the ClientResponseDTO representing the retrieved client.
    • createNew

      @PostMapping public org.springframework.http.ResponseEntity<ClientResponseDTO> createNew(@RequestBody ClientRequestDTO requestDTO)
      Endpoint to create a new client.
      Parameters:
      requestDTO - The request body containing client details.
      Returns:
      A ResponseEntity with the ClientResponseDTO representing the newly created client.
    • update

      @PutMapping("/{id}") public org.springframework.http.ResponseEntity<ClientResponseDTO> update(@PathVariable("id") Integer id, @RequestBody ClientRequestDTO requestDTO)
      Endpoint to update an existing client.
      Parameters:
      id - The ID of the client to update.
      requestDTO - The request body containing updated client details.
      Returns:
      A ResponseEntity with the ClientResponseDTO representing the updated client.
    • deleteCandidate

      @DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void deleteCandidate(@PathVariable("id") Integer id)
      Endpoint to delete a client. Requires the manager role.
      Parameters:
      id - The ID of the client to delete.