From 35baa39723180e0de2350b5b2287b1846dabaf58 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 28 九月 2023 10:48:20 +0800
Subject: [PATCH] 分模块

---
 server/web/src/main/java/com/doumee/config/swagger/SwaggerConfig.java |   38 +++++++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/server/src/main/java/com/doumee/config/swagger/SwaggerConfig.java b/server/web/src/main/java/com/doumee/config/swagger/SwaggerConfig.java
similarity index 69%
copy from server/src/main/java/com/doumee/config/swagger/SwaggerConfig.java
copy to server/web/src/main/java/com/doumee/config/swagger/SwaggerConfig.java
index 1a2de87..97c15be 100644
--- a/server/src/main/java/com/doumee/config/swagger/SwaggerConfig.java
+++ b/server/web/src/main/java/com/doumee/config/swagger/SwaggerConfig.java
@@ -8,12 +8,17 @@
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.RequestHandler;
 import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.service.Parameter;
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.oas.annotations.EnableOpenApi;
+import springfox.documentation.schema.ModelRef;
 import springfox.documentation.service.ApiInfo;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spring.web.plugins.Docket;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.function.Predicate;
 
 /**
@@ -46,32 +51,39 @@
                 .version(version)
                 .build();
     }
-
     @Bean
-    public Docket getDocket() {
+    public Docket getDocket3() {
         return new Docket(DocumentationType.SWAGGER_2)
-                .apiInfo(this.getApiInfo()).groupName("銆愮鐞嗙鎺ュ彛API銆�")
+                .apiInfo(this.getApiInfo()).groupName("銆愬皬绋嬪簭鎺ュ彛API銆�")
                 .host(host)
                 .select()
-                .apis( basePackage("com.doumee.api.system;com.doumee.api.business;"))
+                .apis( basePackage("com.doumee.api.web"))
                 // 璁剧疆闇�瑕佽鎵弿鐨勭被锛岃繖閲岃缃负娣诲姞浜咢Api娉ㄨВ鐨勭被
 //                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                 .paths(PathSelectors.any())
-                .build();
+                .build()
+                .globalOperationParameters(this.getParameterList());
     }
 
+    private List<Parameter> getParameterList() {
+        ParameterBuilder tokenPar = new ParameterBuilder();
+        List<Parameter> pars = new ArrayList<>();
+        tokenPar.name("token").description("浠ょ墝").modelRef(new ModelRef("string")).defaultValue("璁剧疆token榛樿鍊�").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
+        pars.add(tokenPar.build());
+        return  pars;
+    }
 
     @Bean
-    public Docket getDocket2() {
+    public Docket getDocket1() {
         return new Docket(DocumentationType.SWAGGER_2)
-                .apiInfo(this.getApiInfo()).groupName("銆愬叕鍏辨帴鍙PI銆�")
-                .host(host)
-                .select()
-                .apis( basePackage("com.doumee.api.common"))
-                // 璁剧疆闇�瑕佽鎵弿鐨勭被锛岃繖閲岃缃负娣诲姞浜咢Api娉ㄨВ鐨勭被
+            .apiInfo(this.getApiInfo()).groupName("銆愬叕鍏辨帴鍙PI銆�")
+            .host(host)
+            .select()
+            .apis( basePackage("com.doumee.api.common"))
+            // 璁剧疆闇�瑕佽鎵弿鐨勭被锛岃繖閲岃缃负娣诲姞浜咢Api娉ㄨВ鐨勭被
 //                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
-                .paths(PathSelectors.any())
-                .build();
+            .paths(PathSelectors.any())
+            .build();
     }
     /**
      * 閲嶅啓basePackage鏂规硶锛屼娇鑳藉瀹炵幇澶氬寘璁块棶锛屽鍒惰创涓婂幓

--
Gitblit v1.9.3