update - 新增拦截器处理版本关系, 同时记录业务方及使用的版本
This commit is contained in:
parent
99a4337ada
commit
e3b774d4eb
@ -40,27 +40,7 @@ public class RequestHeaderContextInterceptor implements HandlerInterceptor {
|
||||
DefaultArtifactVersion serverVersion = new DefaultArtifactVersion(serviceVersion);
|
||||
if (clientVersion.compareTo(serverVersion) >= 0) {
|
||||
|
||||
ExtAxProperty property = extAxPropertyService.getByName(request.getHeader(HEADER_SERVER_NAME))
|
||||
.map(entity -> {
|
||||
entity.setCreated(!Objects.equals(entity.getValue(), serviceVersion));
|
||||
entity.setValue(headerClientVersion);
|
||||
return entity;
|
||||
})
|
||||
.orElseGet(() -> {
|
||||
ExtAxProperty extAxProperty = new ExtAxProperty();
|
||||
extAxProperty.setCreated(true);
|
||||
extAxProperty.setName(request.getHeader(HEADER_SERVER_NAME));
|
||||
extAxProperty.setValue(clientVersion.toString());
|
||||
return extAxProperty;
|
||||
});
|
||||
|
||||
if (property.getCreated()) {
|
||||
if (Objects.isNull(property.getId())) {
|
||||
extAxPropertyService.add(property);
|
||||
} else {
|
||||
extAxPropertyService.update(property);
|
||||
}
|
||||
}
|
||||
recordClientInfo(request, headerClientVersion, clientVersion);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -73,4 +53,27 @@ public class RequestHeaderContextInterceptor implements HandlerInterceptor {
|
||||
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.setValue(headerClientVersion);
|
||||
return entity;
|
||||
}).orElseGet(() -> {
|
||||
ExtAxProperty extAxProperty = new ExtAxProperty();
|
||||
extAxProperty.setCreated(true);
|
||||
extAxProperty.setName(request.getHeader(HEADER_SERVER_NAME));
|
||||
extAxProperty.setValue(clientVersion.toString());
|
||||
return extAxProperty;
|
||||
});
|
||||
|
||||
if (property.getCreated()) {
|
||||
if (Objects.isNull(property.getId())) {
|
||||
extAxPropertyService.add(property);
|
||||
} else {
|
||||
extAxPropertyService.update(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user