Forráskód Böngészése

文档问题修复

liubo 3 éve
szülő
commit
c88916d118

+ 13 - 0
zd-common/common-core/src/main/java/com/zd/common/core/aspect/ResponseAdvice.java

@@ -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());
         }

+ 5 - 0
zd-modules/zd-base/pom.xml

@@ -37,6 +37,11 @@
         </dependency>
 
         <dependency>
+            <groupId>com.zd.swagger</groupId>
+            <artifactId>common-swagger</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>com.zd.core</groupId>
             <artifactId>common-core</artifactId>
             <exclusions>

+ 0 - 9
zd-modules/zd-chemical/pom.xml

@@ -158,15 +158,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
 </project>