Package com.myhrcrmproject.controller
Class CandidateController
java.lang.Object
com.myhrcrmproject.controller.CandidateController
Controller class for managing candidate-related operations in the HR CRM system.
This class provides RESTful endpoints for retrieving, creating, updating,
and deleting candidate records. It interacts with the CandidateService
for handling business logic and data access.
Additionally, it includes endpoints for finding candidates by their status
and by the associated vacancy. 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/candidates" endpoint.
- Version:
- 1.0
- Author:
- Denys Chaykovskyy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<CandidateResponseDTO>createNew(CandidateRequestDTO requestDTO) Endpoint to create a new candidate.voidEndpoint to delete a candidate.org.springframework.http.ResponseEntity<List<CandidateResponseDTO>>findAll()Endpoint to retrieve a list of all candidates.org.springframework.http.ResponseEntity<List<CandidateShortResponseDTO>>findAllByStatusId(Integer statusID) Endpoint to retrieve a list of candidates by status ID.org.springframework.http.ResponseEntity<List<CandidateShortResponseDTO>>Endpoint to retrieve a list of candidates by vacancy ID.org.springframework.http.ResponseEntity<CandidateResponseDTO>Endpoint to retrieve a candidate by their ID.org.springframework.http.ResponseEntity<CandidateResponseDTO>update(Integer id, CandidateRequestDTO requestDTO) Endpoint to update an existing candidate.
-
Constructor Details
-
CandidateController
public CandidateController()
-
-
Method Details
-
findAll
Endpoint to retrieve a list of all candidates.- Returns:
- A
ResponseEntitywith a list ofCandidateResponseDTOrepresenting all candidates.
-
findById
@GetMapping("/{id}") public org.springframework.http.ResponseEntity<CandidateResponseDTO> findById(@PathVariable("id") Integer id) Endpoint to retrieve a candidate by their ID.- Parameters:
id- The ID of the candidate to retrieve.- Returns:
- A
ResponseEntitywith theCandidateResponseDTOrepresenting the retrieved candidate.
-
createNew
@PostMapping public org.springframework.http.ResponseEntity<CandidateResponseDTO> createNew(@RequestBody CandidateRequestDTO requestDTO) Endpoint to create a new candidate.- Parameters:
requestDTO- The request body containing candidate details.- Returns:
- A
ResponseEntitywith theCandidateResponseDTOrepresenting the newly created candidate.
-
update
@PutMapping("/{id}") public org.springframework.http.ResponseEntity<CandidateResponseDTO> update(@PathVariable("id") Integer id, @RequestBody CandidateRequestDTO requestDTO) Endpoint to update an existing candidate.- Parameters:
id- The ID of the candidate to update.requestDTO- The request body containing updated candidate details.- Returns:
- A
ResponseEntitywith theCandidateResponseDTOrepresenting the updated candidate.
-
delete
@DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void delete(@PathVariable("id") Integer id) Endpoint to delete a candidate. Requires the manager role.- Parameters:
id- The ID of the candidate to delete.
-
findAllByStatusId
@GetMapping("/findAllByStatus/{id}") public org.springframework.http.ResponseEntity<List<CandidateShortResponseDTO>> findAllByStatusId(@PathVariable("id") Integer statusID) Endpoint to retrieve a list of candidates by status ID.- Parameters:
statusID- The ID of the status to filter by.- Returns:
- A
ResponseEntitywith a list ofCandidateShortResponseDTOrepresenting candidates with the specified status.
-
findAllByVacancyId
@GetMapping("/findAllByVacancy/{id}") public org.springframework.http.ResponseEntity<List<CandidateShortResponseDTO>> findAllByVacancyId(@PathVariable("id") Integer id) Endpoint to retrieve a list of candidates by vacancy ID.- Parameters:
id- The ID of the vacancy to filter by.- Returns:
- A
ResponseEntitywith a list ofCandidateShortResponseDTOrepresenting candidates associated with the specified vacancy.
-