From aed297a5fbc8df9dab01b28da21f872ee546b43c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 13 十月 2025 16:15:11 +0800
Subject: [PATCH] 2025.10.13 1. 统一调整controller层的返回类型,通过添加全局响应增强器GlobalResponseAdvice来管理返回结果; 2. 新增mybatis-generator自定义插件,实现给数据库实体entity自动添加swagger注解@ApiModel和@ApiModelProperty

---
 src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt b/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt
index f0a66e6..372623a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt
@@ -1,5 +1,6 @@
 package cn.flightfeather.supervision.config
 
+import io.swagger.annotations.Api
 import org.springframework.beans.factory.annotation.Value
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
@@ -13,10 +14,14 @@
 /**
  * @author riku
  * Date: 2020/8/28
+ * 璁块棶鍦板潃锛歨ttp://localhost:8080/swagger-ui/index.html
  */
 @Configuration
 @EnableSwagger2
-class Swagger2Configuration {
+class Swagger2Configuration(
+    @Value("\${springfox.documentation.swagger.v2.enabled}")
+    var swagger2Enable: Boolean,
+) {
 
     companion object {
         const val SWAGGER_SCAN_BASE_PACKAGE = "cn.flightfeather.supervision"
@@ -24,24 +29,22 @@
         const val VERSION = "1.0.0"
     }
 
-    @Value("\${springfox.documentation.swagger.v2.enabled}")
-    private val swagger2Enable: Boolean = true
-
     @Bean
     fun createRestApi(): Docket =
-            Docket(DocumentationType.SWAGGER_2)
-                    .enable(swagger2Enable)
-                    .apiInfo(apiInfo())
-                    .select()
-                    .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
-                    .paths(PathSelectors.any())
-                    .build()
+        Docket(DocumentationType.SWAGGER_2)
+            .enable(swagger2Enable)
+            .apiInfo(apiInfo())
+            .select()
+            .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
+            .apis(RequestHandlerSelectors.withClassAnnotation(Api::class.java))
+            .paths(PathSelectors.any())
+            .build()
 
 
     private fun apiInfo() =
-            ApiInfoBuilder()
-                    .title("绗笁鏂圭洃绠℃湇鍔�")
-                    .description("绗笁鏂圭洃绠℃湇鍔� API 鎺ュ彛鏂囨。")
-                    .version(VERSION)
-                    .build()
+        ApiInfoBuilder()
+            .title("绗笁鏂圭洃绠℃湇鍔�")
+            .description("绗笁鏂圭洃绠℃湇鍔� API 鎺ュ彛鏂囨。")
+            .version(VERSION)
+            .build()
 }
\ No newline at end of file

--
Gitblit v1.9.3