Compare commits
2 commits
4dafc2d58d
...
32193fb080
Author | SHA1 | Date | |
---|---|---|---|
32193fb080 | |||
9b808a521c |
6 changed files with 26 additions and 60 deletions
|
@ -201,9 +201,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/EmployeeResponseDTO'
|
||||
$ref: '#/components/schemas/EmployeeResponseDTO'
|
||||
post:
|
||||
tags:
|
||||
- employee-controller
|
||||
|
@ -469,5 +467,6 @@ components:
|
|||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
name: bearerAuth
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
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.auth.JwtToken;
|
||||
import de.hmmh.pmt.employee.ApiClient;
|
||||
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
|
||||
import de.hmmh.pmt.oas.DefaultApi;
|
||||
import de.hmmh.pmt.dtos.HelloOut;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
@ -16,8 +17,13 @@ import java.util.Optional;
|
|||
@Controller
|
||||
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
|
||||
public class ApiController implements DefaultApi {
|
||||
|
||||
@Autowired
|
||||
private ApiClientFactory apiClientFactory;
|
||||
private ApiClient apiClient;
|
||||
@Autowired
|
||||
private JwtToken apiToken;
|
||||
@Autowired
|
||||
private EmployeeControllerApi employeeApi;
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
|
@ -31,14 +37,15 @@ public class ApiController implements DefaultApi {
|
|||
|
||||
@Override
|
||||
public ResponseEntity<HelloOut> getHello() {
|
||||
apiClient.setAccessToken(apiToken.getToken());
|
||||
apiClient.setBasePath("https://employee.szut.dev");
|
||||
//TODO: Get Authentication working
|
||||
employeeApi.setApiClient(apiClient);
|
||||
|
||||
String data = employeeApi.findAll1().toString();
|
||||
|
||||
StringBuilder employees = new StringBuilder();
|
||||
for (EmployeeResponseDTO employeeResponseDTO : apiClientFactory.getEmployeeApi().findAll1()) {
|
||||
employees.append(employeeResponseDTO.toString());
|
||||
}
|
||||
|
||||
HelloOut hello = new HelloOut();
|
||||
hello.setMsg(employees.toString());
|
||||
hello.setMsg(data);
|
||||
return ResponseEntity.ok(hello);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import jakarta.servlet.FilterChain;
|
|||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
|
@ -13,8 +12,11 @@ import java.io.IOException;
|
|||
@Component
|
||||
public class JwtTokenFilter extends OncePerRequestFilter {
|
||||
|
||||
@Autowired
|
||||
private JwtToken token;
|
||||
private final JwtToken token;
|
||||
|
||||
public JwtTokenFilter(JwtToken token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package de.hmmh.pmt.employee;
|
||||
|
||||
import de.hmmh.pmt.auth.JwtToken;
|
||||
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
|
||||
import de.hmmh.pmt.employee.api.QualificationControllerApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApiClientFactory {
|
||||
|
||||
@Autowired
|
||||
private ApiClient apiClient;
|
||||
@Autowired
|
||||
private JwtToken apiToken;
|
||||
@Autowired
|
||||
private EmployeeControllerApi employee;
|
||||
@Autowired
|
||||
private QualificationControllerApi qualification;
|
||||
|
||||
public EmployeeControllerApi getEmployeeApi() {
|
||||
prepareApiClient();
|
||||
employee.setApiClient(apiClient);
|
||||
return employee;
|
||||
}
|
||||
|
||||
public QualificationControllerApi getQualificationApi() {
|
||||
prepareApiClient();
|
||||
qualification.setApiClient(apiClient);
|
||||
return qualification;
|
||||
}
|
||||
|
||||
private void prepareApiClient() {
|
||||
apiClient.setAccessToken(apiToken.getToken());
|
||||
apiClient.setBasePath("https://employee.szut.dev");
|
||||
}
|
||||
}
|
|
@ -5,5 +5,6 @@
|
|||
>
|
||||
|
||||
<suppressions>
|
||||
<suppress files="build[\\/]" checks="."/>
|
||||
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]oas" checks="."/>
|
||||
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]dtos" checks="."/>
|
||||
</suppressions>
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<FindBugsFilter xmlns="https://raw.githubusercontent.com/spotbugs/spotbugs/4.8.6/spotbugs/etc/findbugsfilter.xsd">
|
||||
<Match>
|
||||
<!-- We Want This Exposure of Resources the Way it is for our usage -->
|
||||
<Class name="de.hmmh.pmt.employee.ApiClientFactory"/>
|
||||
<Bug code="M,V,EI"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<!--Ignore Auto Generated Code -->
|
||||
<Source name="~.*build/.*"/>
|
||||
<Class name="de.hmmh.pmt.OpenAPISpringBoot$ExitException"/>
|
||||
</Match>
|
||||
</FindBugsFilter>
|
||||
|
|
Loading…
Reference in a new issue