PMT-40: alle Projekte eines Bestimmten Mitarbeiters abfragen #18

Merged
SZUT-Dominik merged 4 commits from story/PMT-40-alle-projekte-eines-bestimmten into trunk 2024-10-24 09:02:40 +00:00
2 changed files with 28 additions and 0 deletions
Showing only changes of commit 096c25e33b - Show all commits

View file

@ -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

Doppeltes anlegen des response DTOs.

Codeflow kann hier auf jedenfall verbessert werden

Doppeltes anlegen des response DTOs. Codeflow kann hier auf jedenfall verbessert werden
.map(Allocation::getProject)
.collect(Collectors.toSet());
EmployeeProjectsDTO response = new EmployeeProjectsDTO();
for (Project project : projects) {
response.addProjectsItem(mapper.mapProject(project));
}
return new ResponseEntity<>(HttpStatus.OK);
}
}

View file

@ -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;
}
}