|
|
@@ -10,6 +10,7 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.http.server.ServerHttpRequest;
|
|
|
import org.springframework.http.server.ServerHttpResponse;
|
|
|
+import org.springframework.util.AntPathMatcher;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
|
|
|
|
|
@@ -26,6 +27,8 @@ import java.util.Map;
|
|
|
@ConditionalOnMissingClass("ZdGatewayApplication")
|
|
|
public class ResponseAdvice implements ResponseBodyAdvice<Object> {
|
|
|
|
|
|
+ static AntPathMatcher antPathMatcher = new AntPathMatcher();
|
|
|
+
|
|
|
@Override
|
|
|
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
|
|
|
return true;
|
|
|
@@ -38,11 +41,21 @@ public class ResponseAdvice implements ResponseBodyAdvice<Object> {
|
|
|
ServerHttpRequest serverHttpRequest,
|
|
|
ServerHttpResponse serverHttpResponse) {
|
|
|
|
|
|
+
|
|
|
if(o instanceof TableDataInfo || o instanceof AjaxResult || o instanceof ResultData
|
|
|
|| o instanceof R || o instanceof String){
|
|
|
return o;
|
|
|
}
|
|
|
|
|
|
+ //swagger 不包装
|
|
|
+ boolean match = antPathMatcher.match("/**/api-docs", serverHttpRequest.getURI().getPath());
|
|
|
+ boolean match1 = antPathMatcher.match("/swagger-resources/**", serverHttpRequest.getURI().getPath());
|
|
|
+ boolean match2 = antPathMatcher.match("/actuator/health/**", serverHttpRequest.getURI().getPath());
|
|
|
+ boolean match3 = antPathMatcher.match("/actuator/**", serverHttpRequest.getURI().getPath());
|
|
|
+ if (match || match1 || match2 || match3) {
|
|
|
+ return o;
|
|
|
+ }
|
|
|
+
|
|
|
if (methodParameter.getMethod().getName().equals("error")) {
|
|
|
return ResultData.fail(((Map<String, Object>) o).get("error").toString());
|
|
|
}
|