Class ContractController

java.lang.Object
com.myhrcrmproject.controller.ContractController

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

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

Additionally, it includes endpoints for finding contracts by their ID, retrieving a list of all contracts, creating a new contract, updating an existing contract, and deleting a contract. There are also endpoints for finding contracts by type ID, employee ID, client ID, and candidate ID. Additionally, it provides endpoints for finding all active contracts by candidate ID and retrieving a list of all active contracts.

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

Version:
1.0
Author:
Denys Chaykovskyy
  • Constructor Details

    • ContractController

      public ContractController()
  • Method Details

    • findAll

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

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

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

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

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

      @GetMapping("/findAllByContractTypeId/{id}") public org.springframework.http.ResponseEntity<List<ContractResponseDTO>> findAllByContractTypeId(@PathVariable("id") Integer id)
      Endpoint to retrieve a list of contracts by type ID.
      Parameters:
      id - The ID of the contract type.
      Returns:
      A ResponseEntity with a list of ContractResponseDTO representing contracts by type ID.
    • findAllByEmployeeId

      @GetMapping("/findAllByEmployee/{id}") public org.springframework.http.ResponseEntity<List<ContractResponseDTO>> findAllByEmployeeId(@PathVariable("id") Integer id)
      Endpoint to retrieve a list of contracts by employee ID.
      Parameters:
      id - The ID of the employee.
      Returns:
      A ResponseEntity with a list of ContractResponseDTO representing contracts by employee ID.
    • findAllByClientId

      @GetMapping("/findAllByClient/{id}") public org.springframework.http.ResponseEntity<List<ContractResponseDTO>> findAllByClientId(@PathVariable("id") Integer id)
      Endpoint to retrieve a list of contracts by client ID.
      Parameters:
      id - The ID of the client.
      Returns:
      A ResponseEntity with a list of ContractResponseDTO representing contracts by client ID.
    • findAllActiveContracts

      @GetMapping("/findAllByCandidate/{id}") public org.springframework.http.ResponseEntity<List<ContractResponseDTO>> findAllActiveContracts(@PathVariable("id") Integer id)
      Endpoint to retrieve a list of contracts by candidate ID.
      Parameters:
      id - The ID of the candidate.
      Returns:
      A ResponseEntity with a list of ContractResponseDTO representing contracts by candidate ID.
    • findAllActiveContracts

      @GetMapping("/findAllActiveContracts") public org.springframework.http.ResponseEntity<List<ContractResponseDTO>> findAllActiveContracts()
      Endpoint to retrieve a list of all active contracts.
      Returns:
      A ResponseEntity with a list of ContractResponseDTO representing all active contracts.