PMT-40 implements ApiController
Some checks failed
Quality Check / Validate OAS (push) Successful in 36s
Quality Check / Linting (push) Failing after 1m6s
Quality Check / Static Analysis (push) Failing after 1m5s
Quality Check / Testing (push) Failing after 1m5s
Quality Check / Validate OAS (pull_request) Successful in 47s
Quality Check / Static Analysis (pull_request) Failing after 1m1s
Quality Check / Linting (pull_request) Failing after 1m4s
Quality Check / Testing (pull_request) Failing after 1m1s

This commit is contained in:
Rajbir Singh 2024-10-23 14:45:59 +02:00
parent 32b81b5d41
commit f0b7317d49

View file

@ -3,6 +3,7 @@ package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import de.hmmh.pmt.db.*; import de.hmmh.pmt.db.*;
import de.hmmh.pmt.db.Project;
import de.hmmh.pmt.dtos.*; import de.hmmh.pmt.dtos.*;
import de.hmmh.pmt.employee.ApiClientFactory; import de.hmmh.pmt.employee.ApiClientFactory;
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO; import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
@ -225,4 +226,28 @@ public class ApiController implements DefaultApi {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
@Override
public ResponseEntity<EmployeeProjectsDTO> getAListOfAllProjectsFromASpecificEmployee(Long id) {
if (!projectRepository.existsById(id)) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
EmployeeProjectsDTO dto = new EmployeeProjectsDTO();
List<Allocation> allocationsByEmployee = allocationRepository.findAllByEmployeeId(id);
if (allocationsByEmployee.isEmpty()) {
return new ResponseEntity<>(dto, HttpStatus.OK);
}
Set<Project> projects = allocationsByEmployee.stream()
.map(Allocation::getProject)
.collect(Collectors.toSet());
EmployeeProjectsDTO response = new EmployeeProjectsDTO();
for (Project project : projects) {
response.addProjectsItem(mapper.mapProject(project));
}
return new ResponseEntity<>(HttpStatus.OK);
}
} }