PMT-32: Alle Bestehende Projekte mit ihren Informationen abrufen #7
1 changed files with 17 additions and 10 deletions
|
@ -2,9 +2,11 @@ package de.hmmh.pmt;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.hmmh.pmt.employee.ApiClientFactory;
|
import de.hmmh.pmt.employee.ApiClientFactory;
|
||||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
import de.hmmh.pmt.db.Project;
|
||||||
|
import de.hmmh.pmt.db.ProjectRepository;
|
||||||
import de.hmmh.pmt.oas.DefaultApi;
|
import de.hmmh.pmt.oas.DefaultApi;
|
||||||
import de.hmmh.pmt.dtos.HelloOut;
|
import de.hmmh.pmt.dtos.GetAllProjectsDTO;
|
||||||
|
import de.hmmh.pmt.dtos.ProjectInfo;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -18,6 +20,10 @@ import java.util.Optional;
|
||||||
public class ApiController implements DefaultApi {
|
public class ApiController implements DefaultApi {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiClientFactory apiClientFactory;
|
private ApiClientFactory apiClientFactory;
|
||||||
|
@Autowired
|
||||||
|
private ProjectRepository projectRepository;
|
||||||
|
|
||||||
|
// apiClientFactory.getEmployeeApi().findAll1()
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<ObjectMapper> getObjectMapper() {
|
||||||
|
@ -30,15 +36,16 @@ public class ApiController implements DefaultApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<HelloOut> getHello() {
|
public ResponseEntity<GetAllProjectsDTO> getAllProjects() {
|
||||||
|
GetAllProjectsDTO response = new GetAllProjectsDTO();
|
||||||
|
|
||||||
StringBuilder employees = new StringBuilder();
|
for (Project project : this.projectRepository.findAll()){
|
||||||
for (EmployeeResponseDTO employeeResponseDTO : apiClientFactory.getEmployeeApi().findAll1()) {
|
ProjectInfo projectInfo = new ProjectInfo();
|
||||||
employees.append(employeeResponseDTO.toString());
|
projectInfo.setId(project.getId());
|
||||||
|
projectInfo.setName(project.getName());
|
||||||
|
response.add(projectInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
HelloOut hello = new HelloOut();
|
return ResponseEntity.ok(response);
|
||||||
hello.setMsg(employees.toString());
|
|
||||||
return ResponseEntity.ok(hello);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue