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
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:
parent
32b81b5d41
commit
f0b7317d49
1 changed files with 25 additions and 0 deletions
|
@ -3,6 +3,7 @@ package de.hmmh.pmt;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import de.hmmh.pmt.db.*;
|
||||
import de.hmmh.pmt.db.Project;
|
||||
import de.hmmh.pmt.dtos.*;
|
||||
import de.hmmh.pmt.employee.ApiClientFactory;
|
||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||
|
@ -225,4 +226,28 @@ public class ApiController implements DefaultApi {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue