Class TaskController

java.lang.Object
com.myhrcrmproject.controller.TaskController

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

This class defines RESTful APIs for various task actions, including retrieving all tasks, finding tasks by ID, creating new tasks, updating existing tasks, and deleting tasks.

Additionally, it provides endpoints to retrieve tasks based on different criteria such as task status ID, employee ID, candidate ID, vacancy ID, start date, etc.

Version:
1.0
Author:
Denys Chaykovskyy
  • Constructor Details

    • TaskController

      public TaskController()
  • Method Details

    • findAll

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

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

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

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

      @DeleteMapping("/{id}") @ResponseStatus(NO_CONTENT) public void delete(@PathVariable("id") Integer id)
      Endpoint to delete a task.
      Parameters:
      id - The ID of the task to delete.
    • findAllByTaskStatusId

      @GetMapping("/findAllByTaskStatusId/{id}") public org.springframework.http.ResponseEntity<List<TaskResponseDTO>> findAllByTaskStatusId(@PathVariable("id") Integer id)
      Retrieves a list of tasks by task status ID. Requires manager role.
      Parameters:
      id - The ID of the status.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByEmployeeId

      @GetMapping("/findAllByEmployee/{id}") public org.springframework.http.ResponseEntity<List<TaskResponseDTO>> findAllByEmployeeId(@PathVariable("id") Integer id)
      Retrieves a list of tasks by employee ID.
      Parameters:
      id - The ID of the employee.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByCandidateId

      @GetMapping("/findAllByCandidate/{id}") public org.springframework.http.ResponseEntity<List<TaskResponseDTO>> findAllByCandidateId(@PathVariable("id") Integer id)
      Retrieves a list of tasks by candidate ID. Requires manager role.
      Parameters:
      id - The ID of the candidate.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByVacancyId

      @GetMapping("/findAllByVacancy/{id}") public org.springframework.http.ResponseEntity<List<TaskResponseDTO>> findAllByVacancyId(@PathVariable("id") Integer id)
      Retrieves a list of tasks by vacancy ID. Requires manager role.
      Parameters:
      id - The ID of the vacancy.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByStartDate

      @PutMapping("/findAllByStartDate") public org.springframework.http.ResponseEntity<List<TaskResponseDTO>> findAllByStartDate(@RequestBody TaskDateRequestDTO requestDTO)
      Retrieves a list of tasks by start date. Requires manager role.
      Parameters:
      requestDTO - The request body containing start date.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByStartDateAndEmployeeId

      @PutMapping("/findAllByStartDateAndEmployee/{id}") public org.springframework.http.ResponseEntity<List<TaskShortResponseDTO>> findAllByStartDateAndEmployeeId(@PathVariable("id") Integer id, @RequestBody TaskDateRequestDTO requestDTO)
      Retrieves a list of tasks by start date and employee ID.
      Parameters:
      id - The ID of the employee.
      requestDTO - The request body containing start date.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByCandidateIdAndEmployeeId

      @GetMapping("/findAllByCandidateAndEmployee/{candidateId}/{employeeId}") public org.springframework.http.ResponseEntity<List<TaskShortResponseDTO>> findAllByCandidateIdAndEmployeeId(@PathVariable("candidateId") Integer candidateId, @PathVariable("employeeId") Integer employeeId)
      Retrieves a list of tasks by candidate ID and employee ID.
      Parameters:
      candidateId - The ID of the candidate.
      employeeId - The ID of the employee.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByStatusIdAndEmployeeId

      @GetMapping("/findAllByStatusAndEmployee/{statusId}/{employeeId}") public org.springframework.http.ResponseEntity<List<TaskShortResponseDTO>> findAllByStatusIdAndEmployeeId(@PathVariable("statusId") Integer statusId, @PathVariable("employeeId") Integer employeeId)
      Retrieves a list of tasks by status ID and employee ID.
      Parameters:
      statusId - The ID of task status.
      employeeId - The ID of the employee.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).
    • findAllByVacancyIdAndEmployeeId

      @GetMapping("/findAllByVacancyAndEmployee/{vacancyId}/{employeeId}") public org.springframework.http.ResponseEntity<List<TaskShortResponseDTO>> findAllByVacancyIdAndEmployeeId(@PathVariable("vacancyId") Integer vacancyId, @PathVariable("employeeId") Integer employeeId)
      Retrieves a list of tasks by vacancy ID and employee ID.
      Parameters:
      vacancyId - The ID of the vacancy.
      employeeId - The ID of the employee.
      Returns:
      A ResponseEntity with the list of tasks and HTTP status code 200 (OK).