Class ContractController
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<ContractResponseDTO>createNew(ContractRequestDTO requestDTO) Endpoint to create a new contract.voidEndpoint to delete a contract.org.springframework.http.ResponseEntity<List<ContractResponseDTO>>findAll()Endpoint to retrieve a list of all contracts.org.springframework.http.ResponseEntity<List<ContractResponseDTO>>Endpoint to retrieve a list of all active contracts.org.springframework.http.ResponseEntity<List<ContractResponseDTO>>Endpoint to retrieve a list of contracts by candidate ID.org.springframework.http.ResponseEntity<List<ContractResponseDTO>>Endpoint to retrieve a list of contracts by client ID.org.springframework.http.ResponseEntity<List<ContractResponseDTO>>Endpoint to retrieve a list of contracts by type ID.org.springframework.http.ResponseEntity<List<ContractResponseDTO>>Endpoint to retrieve a list of contracts by employee ID.org.springframework.http.ResponseEntity<ContractResponseDTO>Endpoint to retrieve a contract by its ID.org.springframework.http.ResponseEntity<ContractResponseDTO>update(Integer id, ContractRequestDTO requestDTO) Endpoint to update an existing contract.
-
Constructor Details
-
ContractController
public ContractController()
-
-
Method Details
-
findAll
Endpoint to retrieve a list of all contracts.- Returns:
- A
ResponseEntitywith a list ofContractResponseDTOrepresenting 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
ResponseEntitywith theContractResponseDTOrepresenting 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
ResponseEntitywith theContractResponseDTOrepresenting 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
ResponseEntitywith theContractResponseDTOrepresenting 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
ResponseEntitywith a list ofContractResponseDTOrepresenting 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
ResponseEntitywith a list ofContractResponseDTOrepresenting 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
ResponseEntitywith a list ofContractResponseDTOrepresenting 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
ResponseEntitywith a list ofContractResponseDTOrepresenting 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
ResponseEntitywith a list ofContractResponseDTOrepresenting all active contracts.
-