Compare commits
8 commits
32193fb080
...
4dafc2d58d
Author | SHA1 | Date | |
---|---|---|---|
4dafc2d58d | |||
61852ade0e | |||
a2cb7e6a59 | |||
319f187cae | |||
d3755984d9 | |||
12d97a88d1 | |||
558cd46a7c | |||
b04ab575cf |
6 changed files with 60 additions and 26 deletions
|
@ -201,7 +201,9 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/EmployeeResponseDTO'
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/EmployeeResponseDTO'
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- employee-controller
|
- employee-controller
|
||||||
|
@ -467,6 +469,5 @@ components:
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
bearerAuth:
|
bearerAuth:
|
||||||
type: http
|
type: http
|
||||||
name: bearerAuth
|
|
||||||
scheme: bearer
|
scheme: bearer
|
||||||
bearerFormat: JWT
|
bearerFormat: JWT
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package de.hmmh.pmt;
|
package de.hmmh.pmt;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.hmmh.pmt.auth.JwtToken;
|
import de.hmmh.pmt.employee.ApiClientFactory;
|
||||||
import de.hmmh.pmt.employee.ApiClient;
|
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||||
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
|
|
||||||
import de.hmmh.pmt.oas.DefaultApi;
|
import de.hmmh.pmt.oas.DefaultApi;
|
||||||
import de.hmmh.pmt.dtos.HelloOut;
|
import de.hmmh.pmt.dtos.HelloOut;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
@ -17,13 +16,8 @@ import java.util.Optional;
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
|
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
|
||||||
public class ApiController implements DefaultApi {
|
public class ApiController implements DefaultApi {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiClient apiClient;
|
private ApiClientFactory apiClientFactory;
|
||||||
@Autowired
|
|
||||||
private JwtToken apiToken;
|
|
||||||
@Autowired
|
|
||||||
private EmployeeControllerApi employeeApi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<ObjectMapper> getObjectMapper() {
|
||||||
|
@ -37,15 +31,14 @@ public class ApiController implements DefaultApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<HelloOut> getHello() {
|
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();
|
HelloOut hello = new HelloOut();
|
||||||
hello.setMsg(data);
|
hello.setMsg(employees.toString());
|
||||||
return ResponseEntity.ok(hello);
|
return ResponseEntity.ok(hello);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import jakarta.servlet.FilterChain;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
|
@ -12,11 +13,8 @@ import java.io.IOException;
|
||||||
@Component
|
@Component
|
||||||
public class JwtTokenFilter extends OncePerRequestFilter {
|
public class JwtTokenFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
private final JwtToken token;
|
@Autowired
|
||||||
|
private JwtToken token;
|
||||||
public JwtTokenFilter(JwtToken token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(
|
protected void doFilterInternal(
|
||||||
|
|
37
src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java
Normal file
37
src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
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,6 +5,5 @@
|
||||||
>
|
>
|
||||||
|
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]oas" checks="."/>
|
<suppress files="build[\\/]" checks="."/>
|
||||||
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]dtos" checks="."/>
|
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<FindBugsFilter xmlns="https://raw.githubusercontent.com/spotbugs/spotbugs/4.8.6/spotbugs/etc/findbugsfilter.xsd">
|
<FindBugsFilter xmlns="https://raw.githubusercontent.com/spotbugs/spotbugs/4.8.6/spotbugs/etc/findbugsfilter.xsd">
|
||||||
<Match>
|
<Match>
|
||||||
<Class name="de.hmmh.pmt.OpenAPISpringBoot$ExitException"/>
|
<!-- 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/.*"/>
|
||||||
</Match>
|
</Match>
|
||||||
</FindBugsFilter>
|
</FindBugsFilter>
|
||||||
|
|
Loading…
Reference in a new issue