Class EmployeeController

java.lang.Object
com.myhrcrmproject.controller.EmployeeController

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

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

Additionally, it includes endpoints for finding employees by their ID, retrieving a list of all employees, creating a new employee (with administrator role required), updating an existing employee, and deleting an employee (with manager role required).

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

Version:
1.0
Author:
Denys Chaykovskyy
  • Constructor Details

    • EmployeeController

      public EmployeeController()
  • Method Details

    • findAll

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

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

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

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

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