From 61852ade0e00a4f940d464ccea23f4125c286d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Mon, 30 Sep 2024 09:10:32 +0200 Subject: [PATCH] PMT-9: Extend Example usage, to show how to use the API Client --- src/main/java/de/hmmh/pmt/ApiController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index d210430..8b56898 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -1,9 +1,12 @@ package de.hmmh.pmt; import com.fasterxml.jackson.databind.ObjectMapper; +import de.hmmh.pmt.employee.ApiClientFactory; +import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO; import de.hmmh.pmt.oas.DefaultApi; import de.hmmh.pmt.dtos.HelloOut; import jakarta.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -13,6 +16,8 @@ import java.util.Optional; @Controller @RequestMapping("${openapi.projectManagement.base-path:/api/v1}") public class ApiController implements DefaultApi { + @Autowired + private ApiClientFactory apiClientFactory; @Override public Optional getObjectMapper() { @@ -26,8 +31,14 @@ public class ApiController implements DefaultApi { @Override public ResponseEntity getHello() { + + StringBuilder employees = new StringBuilder(); + for (EmployeeResponseDTO employeeResponseDTO : apiClientFactory.getEmployeeApi().findAll1()) { + employees.append(employeeResponseDTO.toString()); + } + HelloOut hello = new HelloOut(); - hello.setMsg("Hello World"); + hello.setMsg(employees.toString()); return ResponseEntity.ok(hello); } }