Class CandidateController

java.lang.Object
com.myhrcrmproject.controller.CandidateController

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

    • CandidateController

      public CandidateController()
  • Method Details

    • findAll

      @GetMapping public org.springframework.http.ResponseEntity<List<CandidateResponseDTO>> findAll()
      Endpoint to retrieve a list of all candidates.
      Returns:
      A ResponseEntity with a list of CandidateResponseDTO representing 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 ResponseEntity with the CandidateResponseDTO representing 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 ResponseEntity with the CandidateResponseDTO representing 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 ResponseEntity with the CandidateResponseDTO representing 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 ResponseEntity with a list of CandidateShortResponseDTO representing 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 ResponseEntity with a list of CandidateShortResponseDTO representing candidates associated with the specified vacancy.