update - 新增拦截器处理版本关系, 同时记录业务方及使用的版本
This commit is contained in:
parent
99a4337ada
commit
e3b774d4eb
@ -40,13 +40,26 @@ public class RequestHeaderContextInterceptor implements HandlerInterceptor {
|
|||||||
DefaultArtifactVersion serverVersion = new DefaultArtifactVersion(serviceVersion);
|
DefaultArtifactVersion serverVersion = new DefaultArtifactVersion(serviceVersion);
|
||||||
if (clientVersion.compareTo(serverVersion) >= 0) {
|
if (clientVersion.compareTo(serverVersion) >= 0) {
|
||||||
|
|
||||||
ExtAxProperty property = extAxPropertyService.getByName(request.getHeader(HEADER_SERVER_NAME))
|
recordClientInfo(request, headerClientVersion, clientVersion);
|
||||||
.map(entity -> {
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
throw new WorkflowEngineException(CLIENT_VERSION_SUPPORT, serviceVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!request.getRequestURI().contains("/web/") && !StringUtils.hasText(request.getHeader(HEADER_HTTP_CLIENT))) {
|
||||||
|
throw new WorkflowEngineException(CLIENT_VERSION_SUPPORT, serviceVersion);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recordClientInfo(HttpServletRequest request, String headerClientVersion,
|
||||||
|
DefaultArtifactVersion clientVersion) {
|
||||||
|
ExtAxProperty property = extAxPropertyService.getByName(request.getHeader(HEADER_SERVER_NAME)).map(entity -> {
|
||||||
entity.setCreated(!Objects.equals(entity.getValue(), serviceVersion));
|
entity.setCreated(!Objects.equals(entity.getValue(), serviceVersion));
|
||||||
entity.setValue(headerClientVersion);
|
entity.setValue(headerClientVersion);
|
||||||
return entity;
|
return entity;
|
||||||
})
|
}).orElseGet(() -> {
|
||||||
.orElseGet(() -> {
|
|
||||||
ExtAxProperty extAxProperty = new ExtAxProperty();
|
ExtAxProperty extAxProperty = new ExtAxProperty();
|
||||||
extAxProperty.setCreated(true);
|
extAxProperty.setCreated(true);
|
||||||
extAxProperty.setName(request.getHeader(HEADER_SERVER_NAME));
|
extAxProperty.setName(request.getHeader(HEADER_SERVER_NAME));
|
||||||
@ -61,16 +74,6 @@ public class RequestHeaderContextInterceptor implements HandlerInterceptor {
|
|||||||
extAxPropertyService.update(property);
|
extAxPropertyService.update(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
throw new WorkflowEngineException(CLIENT_VERSION_SUPPORT, serviceVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!request.getRequestURI().contains("/web/") && !StringUtils.hasText(request.getHeader(HEADER_HTTP_CLIENT))) {
|
|
||||||
throw new WorkflowEngineException(CLIENT_VERSION_SUPPORT, serviceVersion);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user