Package com.myhrcrmproject.controller
Class ClientController
java.lang.Object
com.myhrcrmproject.controller.ClientController
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<ClientResponseDTO>createNew(ClientRequestDTO requestDTO) Endpoint to create a new client.voidEndpoint to delete a client.org.springframework.http.ResponseEntity<List<ClientResponseDTO>>findAll()Endpoint to retrieve a list of all clients.org.springframework.http.ResponseEntity<ClientResponseDTO>Endpoint to retrieve a client by their ID.org.springframework.http.ResponseEntity<ClientResponseDTO>update(Integer id, ClientRequestDTO requestDTO) Endpoint to update an existing client.
-
Constructor Details
-
ClientController
public ClientController()
-
-
Method Details
-
findAll
Endpoint to retrieve a list of all clients.- Returns:
- A
ResponseEntitywith a list ofClientResponseDTOrepresenting 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
ResponseEntitywith theClientResponseDTOrepresenting 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
ResponseEntitywith theClientResponseDTOrepresenting 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
ResponseEntitywith theClientResponseDTOrepresenting 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.
-