From a0741df5a2cff792740d7d31f7101ba2339ba3ec Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Tue, 09 Dec 2025 15:30:36 +0800
Subject: [PATCH] 2025-12-09 zwy 增加机场飞行器摄像头切换状态通道,增加LiveStatusTwoReceiver路由
---
ard-admin/src/main/java/com/ard/web/core/config/SwaggerConfig.java | 90 +++++++++++++++++++++++++++++++-------------
1 files changed, 63 insertions(+), 27 deletions(-)
diff --git a/ard-admin/src/main/java/com/ard/web/core/config/SwaggerConfig.java b/ard-admin/src/main/java/com/ard/web/core/config/SwaggerConfig.java
index 7db59b3..dfeb8d7 100644
--- a/ard-admin/src/main/java/com/ard/web/core/config/SwaggerConfig.java
+++ b/ard-admin/src/main/java/com/ard/web/core/config/SwaggerConfig.java
@@ -24,46 +24,76 @@
/**
* Swagger2的接口配置
*
- * @author ruoyi
+ * @author ard
*/
@Configuration
-public class SwaggerConfig
-{
+public class SwaggerConfig {
+
/** 系统基础配置 */
@Autowired
private UavConfig uavConfig;
- /**
- * 创建API
- */
- @Bean
- public Docket createRestApi()
- {
- return new Docket(DocumentationType.OAS_30)
- // 是否启用Swagger
+ private Docket createApiDocket(ApiGroup apiGroup) {
+ return new Docket(DocumentationType.SWAGGER_2)
.enable(true)
- // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
- .apiInfo(apiInfo())
- // 设置哪些接口暴露给Swagger展示
+ .groupName(apiGroup.getGroupName())
+ .apiInfo(apiInfo(apiGroup.getTitle()))
.select()
- // 扫描所有有注解的api,用这种方式更灵活
- .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
- // 扫描指定包中的swagger注解
- // .apis(RequestHandlerSelectors.basePackage("com.ard.project.tool.swagger"))
- // 扫描所有 .apis(RequestHandlerSelectors.any())
+ .apis(requestHandler ->
+ requestHandler.declaringClass().getPackage().getName()
+ .startsWith(apiGroup.getPackagePath()) &&
+ requestHandler.isAnnotatedWith(io.swagger.annotations.ApiOperation.class)
+ )
.paths(PathSelectors.any())
.build()
- /* 设置安全模式,swagger可以设置访问token */
.securitySchemes(securitySchemes())
- .securityContexts(securityContexts())
- .pathMapping("/");
+ .securityContexts(securityContexts());
+ }
+
+ @Bean
+ public Docket systemApi() {
+ return createApiDocket(ApiGroup.SYSTEM);
+ }
+
+ @Bean
+ public Docket droneApi() {
+ return createApiDocket(ApiGroup.DRONE);
+ }
+
+ @Bean
+ public Docket sampleApi() {
+ return createApiDocket(ApiGroup.SAMPLE);
+ }
+
+ @Bean
+ public Docket mediaMTXApi() {
+ return createApiDocket(ApiGroup.MEDIA_MTX);
+ }
+
+ @Bean
+ public Docket deviceApi() {
+ return createApiDocket(ApiGroup.DEVICE);
+ }
+
+ @Bean
+ public Docket dataApi() {
+ return createApiDocket(ApiGroup.DATA);
+ }
+
+ @Bean
+ public Docket storageApi() {
+ return createApiDocket(ApiGroup.STORAGE);
+ }
+
+ @Bean
+ public Docket routeApi() {
+ return createApiDocket(ApiGroup.ROUTE);
}
/**
* 安全模式,这里指定token通过Authorization头请求头传递
*/
- private List<SecurityScheme> securitySchemes()
- {
+ private List<SecurityScheme> securitySchemes() {
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
return apiKeyList;
@@ -78,7 +108,7 @@
securityContexts.add(
SecurityContext.builder()
.securityReferences(defaultAuth())
- .operationSelector(o -> o.requestMappingPattern().matches("/.*"))
+ .forPaths(PathSelectors.regex("^(?!auth).*$"))
.build());
return securityContexts;
}
@@ -99,8 +129,7 @@
/**
* 添加摘要信息
*/
- private ApiInfo apiInfo()
- {
+ private ApiInfo apiInfo() {
// 用ApiInfoBuilder进行定制
return new ApiInfoBuilder()
// 设置标题
@@ -113,4 +142,11 @@
.version(uavConfig.getVersion())
.build();
}
+ private ApiInfo apiInfo(String title) {
+ return new ApiInfoBuilder()
+ .title(title)
+ .description("API 文档")
+ .version("1.0")
+ .build();
+ }
}
--
Gitblit v1.9.3