PMT-40: alle Projekte eines Bestimmten Mitarbeiters abfragen #18
2 changed files with 28 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;
|
||||
|
@ -237,4 +238,19 @@ public class ApiController implements DefaultApi {
|
|||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<EmployeeProjectsDTO> getAListOfAllProjectsFromASpecificEmployee(Long id) {
|
||||
List<Allocation> allocationsByEmployee = allocationRepository.findAllByEmployeeId(id);
|
||||
|
||||
Set<Project> projects = allocationsByEmployee.stream()
|
||||
SZUT-Rajbir marked this conversation as resolved
Outdated
|
||||
.map(Allocation::getProject)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
EmployeeProjectsDTO response = new EmployeeProjectsDTO();
|
||||
for (Project project : projects) {
|
||||
response.addProjectsItem(mapper.mapProject(project));
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,4 +82,16 @@ public class Mapper {
|
|||
project.setPlannedEnd(dto.getPlannedEnd());
|
||||
return project;
|
||||
}
|
||||
public de.hmmh.pmt.dtos.Project mapProject(Project project){
|
||||
de.hmmh.pmt.dtos.Project dto = new de.hmmh.pmt.dtos.Project();
|
||||
dto.setId(project.getId());
|
||||
dto.setName(project.getName());
|
||||
dto.setGoal(project.getGoal());
|
||||
dto.setCustomerId(project.getCustomerId());
|
||||
dto.setAdministratorId(project.getAdministratorId());
|
||||
dto.setStart(project.getStart());
|
||||
dto.setPlannedEnd(project.getPlannedEnd());
|
||||
dto.setRealEnd(project.getRealEnd());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue
Doppeltes anlegen des response DTOs.
Codeflow kann hier auf jedenfall verbessert werden