From 153de26c04208cb0a165cc8a9cebba49213a4428 Mon Sep 17 00:00:00 2001 From: qraddx Date: Sun, 27 Mar 2022 23:18:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:sparkles:=20Introducing=20new=20features.?= =?UTF-8?q?=20close=20#I4ZOTH=20swagger2=20=E8=BF=81=E7=A7=BB=E8=87=B3=20s?= =?UTF-8?q?pringdoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/pig.sql | 9 +- pig-auth/pom.xml | 2 +- pig-common/pig-common-bom/pom.xml | 353 +++++++++--------- pig-common/pig-common-core/pom.xml | 91 +++-- pig-common/pig-common-datasource/pom.xml | 2 +- pig-common/pig-common-feign/pom.xml | 2 +- pig-common/pig-common-job/pom.xml | 2 +- pig-common/pig-common-log/pom.xml | 2 +- pig-common/pig-common-mybatis/pom.xml | 2 +- pig-common/pig-common-security/pom.xml | 2 +- pig-common/pig-common-swagger/pom.xml | 97 +++-- ...ablePigSwagger2.java => EnablePigDoc.java} | 9 +- .../GatewaySwaggerAutoConfiguration.java | 88 ----- .../config/SwaggerAutoConfiguration.java | 165 ++------ .../config/WebFluxSwaggerConfiguration.java | 21 -- .../support/SwaggerBasicGatewayFilter.java | 75 ---- .../swagger/support/SwaggerProperties.java | 128 +------ .../swagger/support/SwaggerProvider.java | 74 ---- .../support/SwaggerResourceHandler.java | 52 --- .../support/SwaggerSecurityHandler.java | 52 --- .../swagger/support/SwaggerUiHandler.java | 52 --- pig-common/pig-common-test/pom.xml | 2 +- pig-common/pom.xml | 2 +- pig-gateway/pom.xml | 156 ++++---- .../pig/gateway/PigGatewayApplication.java | 11 +- .../gateway/config/GatewayConfiguration.java | 6 + .../config/SpringDocConfiguration.java | 45 +++ .../filter/PigRequestGlobalFilter.java | 4 + .../filter/PigSpringDocGlobalFilter.java | 69 ++++ pig-register/pom.xml | 2 +- pig-upms/pig-upms-api/pom.xml | 79 ++-- .../pig/admin/api/dto/SysLogDTO.java | 9 +- .../pig/admin/api/entity/SysDept.java | 13 +- .../pig/admin/api/entity/SysDeptRelation.java | 9 +- .../pig/admin/api/entity/SysDict.java | 17 +- .../pig/admin/api/entity/SysDictItem.java | 23 +- .../pig/admin/api/entity/SysLog.java | 24 +- .../pig/admin/api/entity/SysMenu.java | 18 +- .../api/entity/SysOauthClientDetails.java | 24 +- .../pig/admin/api/entity/SysPost.java | 17 +- .../pig/admin/api/entity/SysPublicParam.java | 27 +- .../pig/admin/api/entity/SysRole.java | 10 +- .../pig/admin/api/entity/SysRoleMenu.java | 6 +- .../pig/admin/api/entity/SysUser.java | 18 +- .../pig/admin/api/entity/SysUserPost.java | 6 +- .../pig/admin/api/entity/SysUserRole.java | 6 +- .../pig4cloud/pig/admin/api/vo/RoleVo.java | 4 +- pig-upms/pig-upms-biz/pom.xml | 2 +- .../pig/admin/PigAdminApplication.java | 4 +- .../pig/admin/controller/AppController.java | 7 +- .../pig/admin/controller/DeptController.java | 7 +- .../pig/admin/controller/DictController.java | 7 +- .../pig/admin/controller/FileController.java | 17 +- .../pig/admin/controller/LogController.java | 7 +- .../pig/admin/controller/MenuController.java | 7 +- .../OauthClientDetailsController.java | 7 +- .../pig/admin/controller/PostController.java | 19 +- .../controller/PublicParamController.java | 25 +- .../pig/admin/controller/RoleController.java | 9 +- .../pig/admin/controller/TokenController.java | 7 +- .../pig/admin/controller/UserController.java | 7 +- .../pig/admin/service/SysRoleMenuService.java | 2 +- .../service/impl/SysRoleMenuServiceImpl.java | 3 +- pig-upms/pom.xml | 2 +- pig-visual/pig-codegen/pom.xml | 2 +- .../pig/codegen/PigCodeGenApplication.java | 2 + .../controller/GenDsConfController.java | 7 +- .../controller/GenFormConfController.java | 19 +- .../controller/GeneratorController.java | 6 +- .../pig/codegen/entity/GenFormConf.java | 13 +- .../resources/template/Controller.java.vm | 19 +- .../main/resources/template/Entity.java.vm | 7 +- pig-visual/pig-monitor/pom.xml | 2 +- pig-visual/pig-sentinel-dashboard/pom.xml | 2 +- pig-visual/pig-xxl-job-admin/pom.xml | 2 +- pig-visual/pom.xml | 2 +- pom.xml | 2 +- 77 files changed, 829 insertions(+), 1282 deletions(-) rename pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/{EnablePigSwagger2.java => EnablePigDoc.java} (82%) delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/GatewaySwaggerAutoConfiguration.java delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/WebFluxSwaggerConfiguration.java delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerBasicGatewayFilter.java delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProvider.java delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerResourceHandler.java delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerSecurityHandler.java delete mode 100644 pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerUiHandler.java create mode 100644 pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/SpringDocConfiguration.java create mode 100755 pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigSpringDocGlobalFilter.java diff --git a/db/pig.sql b/db/pig.sql index 0191a959..2d8a0a6a 100644 --- a/db/pig.sql +++ b/db/pig.sql @@ -178,14 +178,7 @@ CREATE TABLE `sys_public_param` ( -- Records of sys_public_param -- ---------------------------- BEGIN; -INSERT INTO `sys_public_param` VALUES (1, '租户默认来源', 'TENANT_DEFAULT_ID', '1', '0', 'TENANT_DEFAULT_ID', ' ', 'admin', '2020-05-12 04:03:46', '2022-03-25 21:05:55', '2', '0'); -INSERT INTO `sys_public_param` VALUES (2, '租户默认部门名称', 'TENANT_DEFAULT_DEPTNAME', '租户默认部门', '0', '', ' ', ' ', '2020-05-12 03:36:32', NULL, '2', '1'); -INSERT INTO `sys_public_param` VALUES (3, '租户默认账户', 'TENANT_DEFAULT_USERNAME', 'admin', '0', '', ' ', ' ', '2020-05-12 04:05:04', NULL, '2', '1'); -INSERT INTO `sys_public_param` VALUES (4, '租户默认密码', 'TENANT_DEFAULT_PASSWORD', '123456', '0', '', ' ', ' ', '2020-05-12 04:05:24', NULL, '2', '1'); -INSERT INTO `sys_public_param` VALUES (5, '租户默认角色编码', 'TENANT_DEFAULT_ROLECODE', 'ROLE_ADMIN', '0', '', ' ', ' ', '2020-05-12 04:05:57', NULL, '2', '1'); -INSERT INTO `sys_public_param` VALUES (6, '租户默认角色名称', 'TENANT_DEFAULT_ROLENAME', '租户默认角色', '0', '', ' ', ' ', '2020-05-12 04:06:19', NULL, '2', '1'); -INSERT INTO `sys_public_param` VALUES (7, '表前缀', 'GEN_TABLE_PREFIX', 'tb_', '0', '', ' ', ' ', '2020-05-12 04:23:04', NULL, '9', '1'); -INSERT INTO `sys_public_param` VALUES (8, '接口文档不显示的字段', 'GEN_HIDDEN_COLUMNS', 'tenant_id', '0', '', ' ', ' ', '2020-05-12 04:25:19', NULL, '9', '1'); +INSERT INTO `sys_public_param` VALUES (1, '接口文档不显示的字段', 'GEN_HIDDEN_COLUMNS', 'tenant_id', '0', '', ' ', ' ', '2020-05-12 04:25:19', NULL, '9', '1'); COMMIT; diff --git a/pig-auth/pom.xml b/pig-auth/pom.xml index 90fb4930..dda1116f 100755 --- a/pig-auth/pom.xml +++ b/pig-auth/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.4.7 + 3.4.8 pig-auth diff --git a/pig-common/pig-common-bom/pom.xml b/pig-common/pig-common-bom/pom.xml index 8d04e8a6..18abfa73 100644 --- a/pig-common/pig-common-bom/pom.xml +++ b/pig-common/pig-common-bom/pom.xml @@ -1,180 +1,191 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.pig4cloud - pig-common-bom - 3.4.7 - pom + com.pig4cloud + pig-common-bom + 3.4.8 + pom - pig-common-bom - pig cloud parent - pig cloud parent + pig-common-bom + pig cloud parent + pig cloud parent - - ${project.version} - 2.6.4 - UTF-8 - 2.1.8.RELEASE - 2.17.1 - 1.8 - 1.8 - 4.9.9 - 0.0.29 - 1.2.78 - 1.5.24 - 3.5.1 - 1.1.1 - 1.0.3 - 2.0.2 - 2.3.5 - + + ${project.version} + 2.6.5 + UTF-8 + 2.1.8.RELEASE + 2.17.1 + 1.8 + 1.8 + 4.9.9 + 0.0.29 + 1.2.78 + 1.6.6 + 2.1.13 + 3.5.1 + 1.1.1 + 1.0.3 + 2.0.2 + 2.3.5 + - - - - - com.pig4cloud - pig-common-core - ${pig.common.version} - - - com.pig4cloud - pig-common-datasource - ${pig.common.version} - - - com.pig4cloud - pig-common-job - ${pig.common.version} - - - com.pig4cloud - pig-common-log - ${pig.common.version} - - - com.pig4cloud - pig-common-mybatis - ${pig.common.version} - - - com.pig4cloud - pig-common-security - ${pig.common.version} - - - com.pig4cloud - pig-common-feign - ${pig.common.version} - - - com.pig4cloud - pig-common-swagger - ${pig.common.version} - - - com.pig4cloud - pig-common-test - ${pig.common.version} - - - com.pig4cloud - pig-upms-api - ${pig.common.version} - - - - org.springframework.security.oauth.boot - spring-security-oauth2-autoconfigure - ${security.oauth.version} - - - - io.swagger - swagger-models - ${swagger.core.version} - - - io.swagger - swagger-annotations - ${swagger.core.version} - - - - com.alibaba - fastjson - ${fastjson.version} - - - - com.pig4cloud.excel - excel-spring-boot-starter - ${excel.version} - - - - io.springboot.sms - aliyun-sms-spring-boot-starter - ${sms.version} - - - - com.pig4cloud.plugin - oss-spring-boot-starter - ${oss.version} - - - - com.baomidou - mybatis-plus-boot-starter - ${mybatis-plus.version} - - - - org.springframework.boot - spring-boot-starter-web - ${spring-boot.version} - - - - spring-boot-starter-tomcat - org.springframework.boot - - - - - - org.apache.logging.log4j - log4j-to-slf4j - ${log4j2.version} - - - org.apache.logging.log4j - log4j-bom - ${log4j2.version} - pom - import - - - + + + + + com.pig4cloud + pig-common-core + ${pig.common.version} + + + com.pig4cloud + pig-common-datasource + ${pig.common.version} + + + com.pig4cloud + pig-common-job + ${pig.common.version} + + + com.pig4cloud + pig-common-log + ${pig.common.version} + + + com.pig4cloud + pig-common-mybatis + ${pig.common.version} + + + com.pig4cloud + pig-common-security + ${pig.common.version} + + + com.pig4cloud + pig-common-feign + ${pig.common.version} + + + com.pig4cloud + pig-common-swagger + ${pig.common.version} + + + com.pig4cloud + pig-common-test + ${pig.common.version} + + + com.pig4cloud + pig-upms-api + ${pig.common.version} + + + + org.springframework.security.oauth.boot + spring-security-oauth2-autoconfigure + ${security.oauth.version} + + + + org.springdoc + springdoc-openapi-webmvc-core + ${springdoc.version} + + + io.swagger.core.v3 + swagger-annotations + ${swagger.core.version} + + + org.springdoc + springdoc-openapi-webflux-ui + ${springdoc.version} + + + org.springdoc + springdoc-openapi-security + ${springdoc.version} + + + + com.alibaba + fastjson + ${fastjson.version} + + + + com.pig4cloud.excel + excel-spring-boot-starter + ${excel.version} + + + + io.springboot.sms + aliyun-sms-spring-boot-starter + ${sms.version} + + + + com.pig4cloud.plugin + oss-spring-boot-starter + ${oss.version} + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.apache.logging.log4j + log4j-to-slf4j + ${log4j2.version} + + + org.apache.logging.log4j + log4j-bom + ${log4j2.version} + pom + import + + + - - - - - io.github.git-commit-id - git-commit-id-maven-plugin - ${git.commit.plugin} - - - - io.spring.javaformat - spring-javaformat-maven-plugin - ${spring.checkstyle.plugin} - - - + + + + + io.github.git-commit-id + git-commit-id-maven-plugin + ${git.commit.plugin} + + + + io.spring.javaformat + spring-javaformat-maven-plugin + ${spring.checkstyle.plugin} + + + diff --git a/pig-common/pig-common-core/pom.xml b/pig-common/pig-common-core/pom.xml index 835dfc07..619ace51 100755 --- a/pig-common/pig-common-core/pom.xml +++ b/pig-common/pig-common-core/pom.xml @@ -16,56 +16,51 @@ --> - 4.0.0 - - com.pig4cloud - pig-common - 3.4.7 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.pig4cloud + pig-common + 3.4.8 + - pig-common-core - jar + pig-common-core + jar - pig 公共工具类核心包 + pig 公共工具类核心包 - - - - cn.hutool - hutool-all - ${hutool.version} - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - javax.servlet - javax.servlet-api - - - - org.springframework.boot - spring-boot-starter-validation - - - - org.springframework.boot - spring-boot-starter-json - - - org.springframework - spring-webmvc - provided - - - - io.swagger - swagger-annotations - - + + + + cn.hutool + hutool-all + ${hutool.version} + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + javax.servlet + javax.servlet-api + + + + org.springframework.boot + spring-boot-starter-validation + + + + org.springframework.boot + spring-boot-starter-json + + + org.springframework + spring-webmvc + provided + + diff --git a/pig-common/pig-common-datasource/pom.xml b/pig-common/pig-common-datasource/pom.xml index 7cf3cc46..656b8812 100644 --- a/pig-common/pig-common-datasource/pom.xml +++ b/pig-common/pig-common-datasource/pom.xml @@ -21,7 +21,7 @@ pig-common com.pig4cloud - 3.4.7 + 3.4.8 4.0.0 diff --git a/pig-common/pig-common-feign/pom.xml b/pig-common/pig-common-feign/pom.xml index 95f6f55d..ea5cd9cb 100755 --- a/pig-common/pig-common-feign/pom.xml +++ b/pig-common/pig-common-feign/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.4.7 + 3.4.8 4.0.0 diff --git a/pig-common/pig-common-job/pom.xml b/pig-common/pig-common-job/pom.xml index 267d4560..6909a0aa 100755 --- a/pig-common/pig-common-job/pom.xml +++ b/pig-common/pig-common-job/pom.xml @@ -23,7 +23,7 @@ com.pig4cloud pig-common - 3.4.7 + 3.4.8 pig-common-job diff --git a/pig-common/pig-common-log/pom.xml b/pig-common/pig-common-log/pom.xml index 513b0c47..e42d4061 100755 --- a/pig-common/pig-common-log/pom.xml +++ b/pig-common/pig-common-log/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.4.7 + 3.4.8 pig-common-log diff --git a/pig-common/pig-common-mybatis/pom.xml b/pig-common/pig-common-mybatis/pom.xml index 0830d46a..537c848c 100755 --- a/pig-common/pig-common-mybatis/pom.xml +++ b/pig-common/pig-common-mybatis/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.4.7 + 3.4.8 pig-common-mybatis diff --git a/pig-common/pig-common-security/pom.xml b/pig-common/pig-common-security/pom.xml index 9f332cab..7ff0f658 100755 --- a/pig-common/pig-common-security/pom.xml +++ b/pig-common/pig-common-security/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-common - 3.4.7 + 3.4.8 pig-common-security diff --git a/pig-common/pig-common-swagger/pom.xml b/pig-common/pig-common-swagger/pom.xml index 844512fd..154e46c3 100644 --- a/pig-common/pig-common-swagger/pom.xml +++ b/pig-common/pig-common-swagger/pom.xml @@ -19,58 +19,55 @@ --> - 4.0.0 - - com.pig4cloud - pig-common - 3.4.7 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.pig4cloud + pig-common + 3.4.8 + - pig-common-swagger - jar + pig-common-swagger + jar - pig 接口文档 + pig 接口文档 - - - - io.springfox - springfox-swagger-ui - ${swagger.fox.version} - - - io.springfox - springfox-swagger2 - ${swagger.fox.version} - - - io.springfox - springfox-oas - ${swagger.fox.version} - - - - org.springframework - spring-webflux - provided - - - - org.springframework.cloud - spring-cloud-gateway-server - provided - - - org.springframework.cloud - spring-cloud-commons - provided - - - org.springframework - spring-webmvc - provided - - + + + + org.springdoc + springdoc-openapi-webmvc-core + + + org.springdoc + springdoc-openapi-security + + + io.swagger.core.v3 + swagger-annotations + + + + org.springframework + spring-webflux + provided + + + + org.springframework.cloud + spring-cloud-gateway-server + provided + + + org.springframework.cloud + spring-cloud-commons + provided + + + org.springframework + spring-webmvc + provided + + diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigSwagger2.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java similarity index 82% rename from pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigSwagger2.java rename to pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java index 0c138e84..cb218d0d 100644 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigSwagger2.java +++ b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/annotation/EnablePigDoc.java @@ -16,7 +16,6 @@ package com.pig4cloud.pig.common.swagger.annotation; -import com.pig4cloud.pig.common.swagger.config.GatewaySwaggerAutoConfiguration; import com.pig4cloud.pig.common.swagger.config.SwaggerAutoConfiguration; import com.pig4cloud.pig.common.swagger.support.SwaggerProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -25,17 +24,17 @@ import org.springframework.context.annotation.Import; import java.lang.annotation.*; /** - * 开启 pig swagger + * 开启 pig spring doc * * @author lengleng - * @date 2020/10/2 + * @date 2022-03-26 */ @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @EnableConfigurationProperties(SwaggerProperties.class) -@Import({ SwaggerAutoConfiguration.class, GatewaySwaggerAutoConfiguration.class }) -public @interface EnablePigSwagger2 { +@Import({ SwaggerAutoConfiguration.class }) +public @interface EnablePigDoc { } diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/GatewaySwaggerAutoConfiguration.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/GatewaySwaggerAutoConfiguration.java deleted file mode 100644 index d49bed47..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/GatewaySwaggerAutoConfiguration.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.pig4cloud.pig.common.swagger.config; - -import com.pig4cloud.pig.common.swagger.support.*; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.cloud.gateway.config.GatewayProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RequestPredicates; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; -import springfox.documentation.swagger.web.SecurityConfiguration; -import springfox.documentation.swagger.web.SecurityConfigurationBuilder; -import springfox.documentation.swagger.web.UiConfiguration; -import springfox.documentation.swagger.web.UiConfigurationBuilder; - -/** - * 网关swagger 配置类,仅在webflux 环境生效哦 - * - * @author lengleng - * @date 2020/10/2 - */ -@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) -public class GatewaySwaggerAutoConfiguration { - - @Bean - public SwaggerProvider swaggerProvider(SwaggerProperties swaggerProperties, GatewayProperties gatewayProperties) { - return new SwaggerProvider(swaggerProperties, gatewayProperties); - } - - @Bean - public SwaggerResourceHandler swaggerResourceHandler(SwaggerProvider swaggerProvider) { - return new SwaggerResourceHandler(swaggerProvider); - } - - @Bean - public WebFluxSwaggerConfiguration fluxSwaggerConfiguration() { - return new WebFluxSwaggerConfiguration(); - } - - @Bean - @ConditionalOnProperty(value = "swagger.basic.enabled", havingValue = "true") - public SwaggerBasicGatewayFilter swaggerBasicGatewayFilter(SwaggerProperties swaggerProperties) { - return new SwaggerBasicGatewayFilter(swaggerProperties); - } - - @Bean - public SwaggerSecurityHandler swaggerSecurityHandler( - ObjectProvider securityConfigurationObjectProvider) { - SecurityConfiguration securityConfiguration = securityConfigurationObjectProvider - .getIfAvailable(() -> SecurityConfigurationBuilder.builder().build()); - return new SwaggerSecurityHandler(securityConfiguration); - } - - @Bean - public SwaggerUiHandler swaggerUiHandler(ObjectProvider uiConfigurationObjectProvider) { - UiConfiguration uiConfiguration = uiConfigurationObjectProvider - .getIfAvailable(() -> UiConfigurationBuilder.builder().build()); - return new SwaggerUiHandler(uiConfiguration); - } - - @Bean - public RouterFunction swaggerRouterFunction(SwaggerProperties swaggerProperties, - SwaggerUiHandler swaggerUiHandler, SwaggerSecurityHandler swaggerSecurityHandler, - SwaggerResourceHandler swaggerResourceHandler) { - // 开启swagger 匹配路由 - if (swaggerProperties.getEnabled()) { - return RouterFunctions - .route(RequestPredicates.GET("/swagger-resources").and(RequestPredicates.accept(MediaType.ALL)), - swaggerResourceHandler) - .andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui") - .and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler) - .andRoute(RequestPredicates.GET("/swagger-resources/configuration/security") - .and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler); - } - else { - // 关闭时,返回404 - return RouterFunctions - .route(RequestPredicates.GET("/swagger-ui/**").and(RequestPredicates.accept(MediaType.ALL)), - serverRequest -> ServerResponse.notFound().build()) - .andRoute(RequestPredicates.GET("/*/v2/api-docs").and(RequestPredicates.accept(MediaType.ALL)), - serverRequest -> ServerResponse.notFound().build()); - } - } - -} diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/SwaggerAutoConfiguration.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/SwaggerAutoConfiguration.java index e7d1723c..f1277ca7 100644 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/SwaggerAutoConfiguration.java +++ b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/SwaggerAutoConfiguration.java @@ -17,33 +17,22 @@ package com.pig4cloud.pig.common.swagger.config; import com.pig4cloud.pig.common.swagger.support.SwaggerProperties; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.OAuthFlow; +import io.swagger.v3.oas.models.security.OAuthFlows; +import io.swagger.v3.oas.models.security.Scopes; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.client.ServiceInstance; import org.springframework.context.annotation.Bean; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.builders.RequestParameterBuilder; -import springfox.documentation.schema.ScalarType; -import springfox.documentation.service.*; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.ApiSelectorBuilder; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; -import springfox.documentation.swagger2.annotations.EnableSwagger2; +import org.springframework.http.HttpHeaders; -import java.lang.reflect.Field; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; /** * swagger配置 @@ -58,127 +47,39 @@ import java.util.stream.Collectors; * * @author lengleng */ -@EnableSwagger2 +@RequiredArgsConstructor @ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true) @ConditionalOnMissingClass("org.springframework.cloud.gateway.config.GatewayAutoConfiguration") public class SwaggerAutoConfiguration { - /** - * 默认的排除路径,排除Spring Boot默认的错误处理路径和端点 - */ - private static final List DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**"); + private final SwaggerProperties swaggerProperties; - private static final String BASE_PATH = "/**"; + private final ServiceInstance serviceInstance; @Bean - public Docket api(SwaggerProperties swaggerProperties) { - // base-path处理 - if (swaggerProperties.getBasePath().isEmpty()) { - swaggerProperties.getBasePath().add(BASE_PATH); - } - - // exclude-path处理 - if (swaggerProperties.getExcludePath().isEmpty()) { - swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); - } - List> excludePath = new ArrayList<>(); - swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); - - // 版本请求头处理 - List pars = new ArrayList<>(); - - RequestParameterBuilder versionPar = new RequestParameterBuilder().description("灰度路由版本信息") - .in(ParameterType.HEADER).name("VERSION").required(false) - .query(param -> param.model(model -> model.scalarModel(ScalarType.STRING))); - - pars.add(versionPar.build()); - - ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).host(swaggerProperties.getHost()) - .apiInfo(apiInfo(swaggerProperties)).globalRequestParameters(pars).select() - .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())); - - swaggerProperties.getBasePath().forEach(p -> builder.paths(PathSelectors.ant(p))); - swaggerProperties.getExcludePath().forEach(p -> builder.paths(PathSelectors.ant(p).negate())); - - return builder.build().securitySchemes(Collections.singletonList(securitySchema(swaggerProperties))) - .securityContexts(Collections.singletonList(securityContext(swaggerProperties))).pathMapping("/"); + public OpenAPI springOpenAPI() { + OpenAPI openAPI = new OpenAPI().info(new Info().title(swaggerProperties.getTitle())); + // oauth2.0 password + openAPI.schemaRequirement(HttpHeaders.AUTHORIZATION, this.securityScheme()); + // servers + List serverList = new ArrayList<>(); + String path = swaggerProperties.getServices().get(serviceInstance.getServiceId()); + serverList.add(new Server().url(swaggerProperties.getGateway() + "/" + path)); + openAPI.servers(serverList); + return openAPI; } - /** - * 配置默认的全局鉴权策略的开关,通过正则表达式进行匹配;默认匹配所有URL - * @return - */ - private static SecurityContext securityContext(SwaggerProperties swaggerProperties) { - return SecurityContext.builder().securityReferences(defaultAuth(swaggerProperties)).build(); - } + private SecurityScheme securityScheme() { + OAuthFlow clientCredential = new OAuthFlow(); + clientCredential.setTokenUrl(swaggerProperties.getTokenUrl()); + clientCredential.setScopes(new Scopes().addString(swaggerProperties.getScope(), swaggerProperties.getScope())); + OAuthFlows oauthFlows = new OAuthFlows(); + oauthFlows.password(clientCredential); - /** - * 默认的全局鉴权策略 - * @return - */ - private static List defaultAuth(SwaggerProperties swaggerProperties) { - ArrayList authorizationScopeList = new ArrayList<>(); - swaggerProperties.getAuthorization().getAuthorizationScopeList() - .forEach(authorizationScope -> authorizationScopeList.add( - new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription()))); - AuthorizationScope[] authorizationScopes = new AuthorizationScope[authorizationScopeList.size()]; - return Collections - .singletonList(SecurityReference.builder().reference(swaggerProperties.getAuthorization().getName()) - .scopes(authorizationScopeList.toArray(authorizationScopes)).build()); - } - - private static OAuth securitySchema(SwaggerProperties swaggerProperties) { - ArrayList authorizationScopeList = new ArrayList<>(); - swaggerProperties.getAuthorization().getAuthorizationScopeList() - .forEach(authorizationScope -> authorizationScopeList.add( - new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription()))); - ArrayList grantTypes = new ArrayList<>(); - swaggerProperties.getAuthorization().getTokenUrlList() - .forEach(tokenUrl -> grantTypes.add(new ResourceOwnerPasswordCredentialsGrant(tokenUrl))); - return new OAuth(swaggerProperties.getAuthorization().getName(), authorizationScopeList, grantTypes); - } - - private static ApiInfo apiInfo(SwaggerProperties swaggerProperties) { - return new ApiInfoBuilder().title(swaggerProperties.getTitle()).description(swaggerProperties.getDescription()) - .license(swaggerProperties.getLicense()).licenseUrl(swaggerProperties.getLicenseUrl()) - .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) - .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), - swaggerProperties.getContact().getEmail())) - .version(swaggerProperties.getVersion()).build(); - } - - @Bean - public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { - return new BeanPostProcessor() { - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof WebMvcRequestHandlerProvider) { - customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); - } - return bean; - } - - private void customizeSpringfoxHandlerMappings( - List mappings) { - List copy = mappings.stream().filter(mapping -> mapping.getPatternParser() == null) - .collect(Collectors.toList()); - mappings.clear(); - mappings.addAll(copy); - } - - @SuppressWarnings("unchecked") - private List getHandlerMappings(Object bean) { - try { - Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings"); - field.setAccessible(true); - return (List) field.get(bean); - } - catch (IllegalArgumentException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - } - }; + SecurityScheme securityScheme = new SecurityScheme(); + securityScheme.setType(SecurityScheme.Type.OAUTH2); + securityScheme.setFlows(oauthFlows); + return securityScheme; } } diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/WebFluxSwaggerConfiguration.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/WebFluxSwaggerConfiguration.java deleted file mode 100644 index 790de6e9..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/config/WebFluxSwaggerConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.pig4cloud.pig.common.swagger.config; - -import org.springframework.web.reactive.config.ResourceHandlerRegistry; -import org.springframework.web.reactive.config.WebFluxConfigurer; - -/** - * @author lengleng - * @date 2020/10/2 - *

- * webflux 网关 swagger 资源路径配置 - */ -public class WebFluxSwaggerConfiguration implements WebFluxConfigurer { - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/swagger-ui/**") - .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") - .resourceChain(false); - } - -} \ No newline at end of file diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerBasicGatewayFilter.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerBasicGatewayFilter.java deleted file mode 100644 index 3eef84e9..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerBasicGatewayFilter.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.pig4cloud.pig.common.swagger.support; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.util.Base64Utils; -import org.springframework.util.StringUtils; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -import java.nio.charset.StandardCharsets; - -/** - * swagger 开启basic 认证 - * - * @author Lht - * @date 2021/8/8 - */ -@Slf4j -@RequiredArgsConstructor -public class SwaggerBasicGatewayFilter implements GlobalFilter { - - private static final String API_URI = "/v2/api-docs"; - - private static final String BASIC_PREFIX = "Basic "; - - private final SwaggerProperties swaggerProperties; - - @Override - public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { - ServerHttpRequest request = exchange.getRequest(); - - if (!request.getURI().getPath().contains(API_URI)) { - return chain.filter(exchange); - } - - if (hasAuth(exchange)) { - return chain.filter(exchange); - } - else { - ServerHttpResponse response = exchange.getResponse(); - response.setStatusCode(HttpStatus.UNAUTHORIZED); - response.getHeaders().add(HttpHeaders.WWW_AUTHENTICATE, "Basic Realm=\"pig\""); - return response.setComplete(); - } - } - - /** - * 简单的basic认证 - * @param exchange 上下文 - * @return 是否有权限 - */ - private boolean hasAuth(ServerWebExchange exchange) { - ServerHttpRequest request = exchange.getRequest(); - String auth = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION); - log.info("Basic认证信息为:{}", auth); - if (!StringUtils.hasText(auth) || !auth.startsWith(BASIC_PREFIX)) { - return Boolean.FALSE; - } - - String username = swaggerProperties.getBasic().getUsername(); - String password = swaggerProperties.getBasic().getPassword(); - - String encodeToString = Base64Utils - .encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8)); - - return auth.equals(BASIC_PREFIX + encodeToString); - } - -} diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProperties.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProperties.java index d5d7d737..2247edd5 100644 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProperties.java +++ b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProperties.java @@ -17,11 +17,11 @@ package com.pig4cloud.pig.common.swagger.support; import lombok.Data; -import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * SwaggerProperties @@ -64,128 +64,20 @@ public class SwaggerProperties { private String title = ""; /** - * 描述 - **/ - private String description = ""; - - /** - * 版本 - **/ - private String version = ""; - - /** - * 许可证 - **/ - private String license = ""; - - /** - * 许可证URL - **/ - private String licenseUrl = ""; - - /** - * 服务条款URL - **/ - private String termsOfServiceUrl = ""; - - /** - * host信息 - **/ - private String host = ""; - - /** - * 联系人信息 + * 网关 */ - private Contact contact = new Contact(); + private String gateway; /** - * 全局统一鉴权配置 - **/ - private Authorization authorization = new Authorization(); - - /** - * 认证参数 + * 获取token */ - private SwaggerBasic basic = new SwaggerBasic(); + private String tokenUrl; - @Data - @NoArgsConstructor - public static class Contact { + /** + * 作用域 + */ + private String scope; - /** - * 联系人 - **/ - private String name = ""; - - /** - * 联系人url - **/ - private String url = ""; - - /** - * 联系人email - **/ - private String email = ""; - - } - - @Data - @NoArgsConstructor - public static class Authorization { - - /** - * 鉴权策略ID,需要和SecurityReferences ID保持一致 - */ - private String name = ""; - - /** - * 需要开启鉴权URL的正则 - */ - private String authRegex = "^.*$"; - - /** - * 鉴权作用域列表 - */ - private List authorizationScopeList = new ArrayList<>(); - - private List tokenUrlList = new ArrayList<>(); - - } - - @Data - @NoArgsConstructor - public static class AuthorizationScope { - - /** - * 作用域名称 - */ - private String scope = ""; - - /** - * 作用域描述 - */ - private String description = ""; - - } - - @Data - public static class SwaggerBasic { - - /** - * 是否开启 basic 认证 - */ - private Boolean enabled; - - /** - * 用户名 - */ - private String username; - - /** - * 密码 - */ - private String password; - - } + private Map services; } diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProvider.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProvider.java deleted file mode 100644 index 7c6511d8..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pig.common.swagger.support; - -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.gateway.config.GatewayProperties; -import org.springframework.cloud.gateway.route.RouteLocator; -import org.springframework.cloud.gateway.support.NameUtils; -import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; -import springfox.documentation.swagger.web.SwaggerResource; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Sywd 聚合接口文档注册,和zuul实现类似 - */ -@Primary -@RequiredArgsConstructor -public class SwaggerProvider implements SwaggerResourcesProvider { - - private static final String API_URI = "/v2/api-docs"; - - private final SwaggerProperties swaggerProperties; - - private final GatewayProperties gatewayProperties; - - @Lazy - @Autowired - private RouteLocator routeLocator; - - @Override - public List get() { - List resources = new ArrayList<>(); - List routes = new ArrayList<>(); - routeLocator.getRoutes().subscribe(route -> routes.add(route.getId())); - gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())) - .forEach(routeDefinition -> routeDefinition.getPredicates().stream() - .filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName())) - .filter(predicateDefinition -> !swaggerProperties.getIgnoreProviders() - .contains(routeDefinition.getId())) - .forEach(predicateDefinition -> resources - .add(swaggerResource(routeDefinition.getId(), predicateDefinition.getArgs() - .get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", API_URI))))); - return resources; - } - - private static SwaggerResource swaggerResource(String name, String location) { - SwaggerResource swaggerResource = new SwaggerResource(); - swaggerResource.setName(name); - swaggerResource.setLocation(location); - swaggerResource.setSwaggerVersion("2.0"); - return swaggerResource; - } - -} diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerResourceHandler.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerResourceHandler.java deleted file mode 100644 index 50e5968b..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerResourceHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pig.common.swagger.support; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -/** - * @author lengleng - * @date 2018-07-19 SwaggerResourceHandler - */ -@Slf4j -@RequiredArgsConstructor -public class SwaggerResourceHandler implements HandlerFunction { - - private final SwaggerResourcesProvider swaggerResources; - - /** - * Handle the given request. - * @param request the request to handler - * @return the response - */ - @Override - public Mono handle(ServerRequest request) { - return ServerResponse.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromValue(swaggerResources.get())); - } - -} diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerSecurityHandler.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerSecurityHandler.java deleted file mode 100644 index fed103c6..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerSecurityHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pig.common.swagger.support; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.SecurityConfiguration; - -/** - * @author lengleng - * @date 2018-07-19 SwaggerSecurityHandler - */ -@Slf4j -@RequiredArgsConstructor -public class SwaggerSecurityHandler implements HandlerFunction { - - private final SecurityConfiguration securityConfiguration; - - /** - * Handle the given request. - * @param request the request to handler - * @return the response - */ - @Override - public Mono handle(ServerRequest request) { - return ServerResponse.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromValue(securityConfiguration)); - } - -} diff --git a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerUiHandler.java b/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerUiHandler.java deleted file mode 100644 index ee1be94b..00000000 --- a/pig-common/pig-common-swagger/src/main/java/com/pig4cloud/pig/common/swagger/support/SwaggerUiHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pig.common.swagger.support; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.UiConfiguration; - -/** - * @author lengleng - * @date 2018-07-19 SwaggerUiHandler - */ -@Slf4j -@RequiredArgsConstructor -public class SwaggerUiHandler implements HandlerFunction { - - private final UiConfiguration uiConfiguration; - - /** - * Handle the given request. - * @param request the request to handler - * @return the response - */ - @Override - public Mono handle(ServerRequest request) { - return ServerResponse.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromValue(uiConfiguration)); - } - -} diff --git a/pig-common/pig-common-test/pom.xml b/pig-common/pig-common-test/pom.xml index ab3fec7f..5be17ed5 100755 --- a/pig-common/pig-common-test/pom.xml +++ b/pig-common/pig-common-test/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pig-common - 3.4.7 + 3.4.8 pig-common-test diff --git a/pig-common/pom.xml b/pig-common/pom.xml index 2f0f00ae..305d69c1 100755 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.4.7 + 3.4.8 pig-common diff --git a/pig-gateway/pom.xml b/pig-gateway/pom.xml index babb10fb..f5b6b72f 100755 --- a/pig-gateway/pom.xml +++ b/pig-gateway/pom.xml @@ -16,87 +16,87 @@ --> - 4.0.0 - - com.pig4cloud - pig - 3.4.7 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.pig4cloud + pig + 3.4.8 + - pig-gateway - jar + pig-gateway + jar - pig 服务网关,基于 spring cloud gateway + pig 服务网关,基于 spring cloud gateway - - - - org.springframework.cloud - spring-cloud-starter-gateway - - - org.springframework.boot - spring-boot-starter-data-redis-reactive - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - com.alibaba.cloud - spring-cloud-alibaba-sentinel-gateway - - - com.alibaba.cloud - spring-cloud-starter-alibaba-sentinel - - - - org.springframework.cloud - spring-cloud-starter-loadbalancer - - - - com.github.ben-manes.caffeine - caffeine - - - - com.pig4cloud.plugin - captcha-spring-boot-starter - ${captcha.version} - - - - com.pig4cloud - pig-common-core - - - - com.pig4cloud - pig-common-swagger - - + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + org.springframework.boot + spring-boot-starter-data-redis-reactive + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.alibaba.cloud + spring-cloud-alibaba-sentinel-gateway + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + com.github.ben-manes.caffeine + caffeine + + + + com.pig4cloud.plugin + captcha-spring-boot-starter + ${captcha.version} + + + + com.pig4cloud + pig-common-core + + + + org.springdoc + springdoc-openapi-webflux-ui + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - io.fabric8 - docker-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + io.fabric8 + docker-maven-plugin + + + diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java index 4b0d641b..b0b3ebba 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/PigGatewayApplication.java @@ -16,10 +16,18 @@ package com.pig4cloud.pig.gateway; -import com.pig4cloud.pig.common.swagger.annotation.EnablePigSwagger2; +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.SwaggerUiConfigParameters; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Lazy; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** * @author lengleng @@ -27,7 +35,6 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; *

* 网关应用 */ -@EnablePigSwagger2 @EnableDiscoveryClient @SpringBootApplication public class PigGatewayApplication { diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java index ceaaeed7..c7bdf353 100644 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java @@ -3,6 +3,7 @@ package com.pig4cloud.pig.gateway.config; import com.fasterxml.jackson.databind.ObjectMapper; import com.pig4cloud.pig.gateway.filter.PasswordDecoderFilter; import com.pig4cloud.pig.gateway.filter.PigRequestGlobalFilter; +import com.pig4cloud.pig.gateway.filter.PigSpringDocGlobalFilter; import com.pig4cloud.pig.gateway.filter.ValidateCodeGatewayFilter; import com.pig4cloud.pig.gateway.handler.GlobalExceptionHandler; import com.pig4cloud.pig.gateway.handler.ImageCodeHandler; @@ -30,6 +31,11 @@ public class GatewayConfiguration { return new PigRequestGlobalFilter(); } + @Bean + public PigSpringDocGlobalFilter pigSwaggerGlobalFilter() { + return new PigSpringDocGlobalFilter(); + } + @Bean public ValidateCodeGatewayFilter validateCodeGatewayFilter(GatewayConfigProperties configProperties, ObjectMapper objectMapper, RedisTemplate redisTemplate) { diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/SpringDocConfiguration.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/SpringDocConfiguration.java new file mode 100644 index 00000000..7f6b0620 --- /dev/null +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/SpringDocConfiguration.java @@ -0,0 +1,45 @@ +package com.pig4cloud.pig.gateway.config; + +import lombok.Data; +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.SwaggerUiConfigParameters; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author lengleng + * @date 2022/3/26 + * + * swagger 3.0 展示 + */ +@Configuration(proxyBeanMethods = false) +public class SpringDocConfiguration { + + @Bean + @Lazy(false) + public List apis(SwaggerUiConfigParameters swaggerUiConfigParameters, + SwaggerProperties properties) { + List groups = new ArrayList<>(); + for (String value : properties.services.values()) { + swaggerUiConfigParameters.addGroup(value); + } + return groups; + } + + @Data + @Component + @ConfigurationProperties("swagger") + class SwaggerProperties { + + private Map services; + + } + +} diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigRequestGlobalFilter.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigRequestGlobalFilter.java index fbfb434f..b0668a06 100755 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigRequestGlobalFilter.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigRequestGlobalFilter.java @@ -61,6 +61,10 @@ public class PigRequestGlobalFilter implements GlobalFilter, Ordered { String rawPath = request.getURI().getRawPath(); String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/")).skip(1L) .collect(Collectors.joining("/")); + + // if (rawPath.contains("/v3/api-docs/")) { + // newPath = "/admin/v3/api-docs"; + // } ServerHttpRequest newRequest = request.mutate().path(newPath).build(); exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI()); diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigSpringDocGlobalFilter.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigSpringDocGlobalFilter.java new file mode 100755 index 00000000..cb025246 --- /dev/null +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/PigSpringDocGlobalFilter.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.pig4cloud.pig.gateway.filter; + +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.util.StringUtils; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl; + +/** + * @author lengleng + * @date 2022-03-26 + *

+ * 支持springdoc 路径从写 + */ +public class PigSpringDocGlobalFilter implements GlobalFilter, Ordered { + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + + ServerHttpRequest request = exchange.getRequest(); + + String rawPath = request.getURI().getRawPath(); + + // 非springdoc 请求直接跳过 + if (!rawPath.contains("/api-docs/")) { + return chain.filter(exchange); + } + + // 2. 重写StripPrefix + addOriginalRequestUrl(exchange, request.getURI()); + + String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/")).skip(1L) + .collect(Collectors.joining("/")) + "/v3/api-docs"; + ServerHttpRequest newRequest = request.mutate().path(newPath).build(); + exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI()); + + return chain.filter(exchange.mutate().request(newRequest.mutate().build()).build()); + } + + @Override + public int getOrder() { + return -500; + } + +} diff --git a/pig-register/pom.xml b/pig-register/pom.xml index 132a3a05..61f531e2 100755 --- a/pig-register/pom.xml +++ b/pig-register/pom.xml @@ -18,7 +18,7 @@ com.pig4cloud pig - 3.4.7 + 3.4.8 pig-register diff --git a/pig-upms/pig-upms-api/pom.xml b/pig-upms/pig-upms-api/pom.xml index acf7de1c..ead2046d 100755 --- a/pig-upms/pig-upms-api/pom.xml +++ b/pig-upms/pig-upms-api/pom.xml @@ -16,45 +16,50 @@ --> - 4.0.0 - - com.pig4cloud - pig-upms - 3.4.7 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.pig4cloud + pig-upms + 3.4.8 + - pig-upms-api - jar + pig-upms-api + jar - pig 通用用户权限管理系统公共api模块 + pig 通用用户权限管理系统公共api模块 - - - - com.pig4cloud - pig-common-core - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - com.pig4cloud - pig-common-feign - - - - com.pig4cloud - pig-common-mybatis - - - - com.pig4cloud.excel - excel-spring-boot-starter - - + + + + com.pig4cloud + pig-common-core + + + + io.swagger.core.v3 + swagger-annotations + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + com.pig4cloud + pig-common-feign + + + + com.pig4cloud + pig-common-mybatis + + + + com.pig4cloud.excel + excel-spring-boot-starter + + diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java index 0bf75d87..5ec59e80 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/dto/SysLogDTO.java @@ -1,7 +1,6 @@ package com.pig4cloud.pig.admin.api.dto; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.time.LocalDateTime; @@ -13,19 +12,19 @@ import java.time.LocalDateTime; * 日志查询传输对象 */ @Data -@ApiModel(value = "日志查询对象") +@Schema(name = "日志查询对象") public class SysLogDTO { /** * 查询日志类型 */ - @ApiModelProperty(value = "日志类型") + @Schema(name = "日志类型") private String type; /** * 创建时间区间 [开始时间,结束时间] */ - @ApiModelProperty(value = "创建时间区间") + @Schema(name = "创建时间区间") private LocalDateTime[] createTime; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java index 0bc7fd99..bf78e8cf 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDept.java @@ -20,8 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -36,7 +35,7 @@ import javax.validation.constraints.NotNull; * @author lengleng * @since 2019/2/1 */ -@ApiModel(value = "部门") +@Schema(name = "部门") @Data @EqualsAndHashCode(callSuper = true) public class SysDept extends BaseEntity { @@ -44,27 +43,27 @@ public class SysDept extends BaseEntity { private static final long serialVersionUID = 1L; @TableId(value = "dept_id", type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "部门id") + @Schema(name = "部门id") private Long deptId; /** * 部门名称 */ @NotBlank(message = "部门名称不能为空") - @ApiModelProperty(value = "部门名称", required = true) + @Schema(name = "部门名称", required = true) private String name; /** * 排序 */ @NotNull(message = "部门排序值不能为空") - @ApiModelProperty(value = "排序值", required = true) + @Schema(name = "排序值", required = true) private Integer sortOrder; /** * 父级部门id */ - @ApiModelProperty(value = "父级部门id") + @Schema(name = "父级部门id") private Long parentId; /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java index e68e55ef..04434721 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDeptRelation.java @@ -17,8 +17,7 @@ package com.pig4cloud.pig.admin.api.entity; import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -30,7 +29,7 @@ import lombok.EqualsAndHashCode; * @author lengleng * @since 2019/2/1 */ -@ApiModel(value = "部门关系") +@Schema(name = "部门关系") @Data @EqualsAndHashCode(callSuper = true) public class SysDeptRelation extends Model { @@ -40,13 +39,13 @@ public class SysDeptRelation extends Model { /** * 祖先节点 */ - @ApiModelProperty(value = "祖先节点") + @Schema(name = "祖先节点") private Long ancestor; /** * 后代节点 */ - @ApiModelProperty(value = "后代节点") + @Schema(name = "后代节点") private Long descendant; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java index 23a5ecd6..dbfe1442 100755 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDict.java @@ -19,8 +19,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -31,7 +30,7 @@ import lombok.EqualsAndHashCode; * @date 2019/03/19 */ @Data -@ApiModel(value = "字典类型") +@Schema(name = "字典类型") @EqualsAndHashCode(callSuper = true) public class SysDict extends BaseEntity { @@ -41,38 +40,38 @@ public class SysDict extends BaseEntity { * 编号 */ @TableId(type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "字典编号") + @Schema(name = "字典编号") private Long id; /** * 类型 */ - @ApiModelProperty(value = "字典类型") + @Schema(name = "字典类型") private String type; /** * 描述 */ - @ApiModelProperty(value = "字典描述") + @Schema(name = "字典描述") private String description; /** * 是否是系统内置 */ - @ApiModelProperty(value = "是否系统内置") + @Schema(name = "是否系统内置") private String systemFlag; /** * 备注信息 */ - @ApiModelProperty(value = "备注信息") + @Schema(name = "备注信息") private String remark; /** * 删除标记 */ @TableLogic - @ApiModelProperty(value = "删除标记,1:已删除,0:正常") + @Schema(name = "删除标记,1:已删除,0:正常") private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java index decd4c20..ca130f74 100755 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysDictItem.java @@ -19,8 +19,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -31,7 +30,7 @@ import lombok.EqualsAndHashCode; * @date 2019/03/19 */ @Data -@ApiModel(value = "字典项") +@Schema(name = "字典项") @EqualsAndHashCode(callSuper = true) public class SysDictItem extends BaseEntity { @@ -41,56 +40,56 @@ public class SysDictItem extends BaseEntity { * 编号 */ @TableId(type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "字典项id") + @Schema(name = "字典项id") private Long id; /** * 所属字典类id */ - @ApiModelProperty(value = "所属字典类id") + @Schema(name = "所属字典类id") private Long dictId; /** * 数据值 */ - @ApiModelProperty(value = "数据值") + @Schema(name = "数据值") private String value; /** * 标签名 */ - @ApiModelProperty(value = "标签名") + @Schema(name = "标签名") private String label; /** * 类型 */ - @ApiModelProperty(value = "类型") + @Schema(name = "类型") private String type; /** * 描述 */ - @ApiModelProperty(value = "描述") + @Schema(name = "描述") private String description; /** * 排序(升序) */ - @ApiModelProperty(value = "排序值,默认升序") + @Schema(name = "排序值,默认升序") private Integer sortOrder; /** * 备注信息 */ - @ApiModelProperty(value = "备注信息") + @Schema(name = "备注信息") private String remark; /** * 删除标记 */ @TableLogic - @ApiModelProperty(value = "删除标记,1:已删除,0:正常") + @Schema(name = "删除标记,1:已删除,0:正常") private String delFlag; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java index df3f5839..265553ba 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysLog.java @@ -24,7 +24,7 @@ import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -49,7 +49,7 @@ public class SysLog extends BaseEntity { */ @TableId(value = "id", type = IdType.ASSIGN_ID) @ExcelProperty("日志编号") - @ApiModelProperty(value = "日志编号") + @Schema(name = "日志编号") @JsonSerialize(using = ToStringSerializer.class) private Long id; @@ -58,7 +58,7 @@ public class SysLog extends BaseEntity { */ @NotBlank(message = "日志类型不能为空") @ExcelProperty("日志类型(0-正常 9-错误)") - @ApiModelProperty(value = "日志类型") + @Schema(name = "日志类型") private String type; /** @@ -66,63 +66,63 @@ public class SysLog extends BaseEntity { */ @NotBlank(message = "日志标题不能为空") @ExcelProperty("日志标题") - @ApiModelProperty(value = "日志标题") + @Schema(name = "日志标题") private String title; /** * 操作IP地址 */ @ExcelProperty("IP") - @ApiModelProperty(value = "操作ip地址") + @Schema(name = "操作ip地址") private String remoteAddr; /** * 用户浏览器 */ @ExcelProperty("浏览器类型") - @ApiModelProperty(value = "用户代理") + @Schema(name = "用户代理") private String userAgent; /** * 请求URI */ @ExcelProperty("请求URI") - @ApiModelProperty(value = "请求uri") + @Schema(name = "请求uri") private String requestUri; /** * 操作方式 */ @ExcelProperty("操作方式") - @ApiModelProperty(value = "操作方式") + @Schema(name = "操作方式") private String method; /** * 操作提交的数据 */ @ExcelProperty("请求参数") - @ApiModelProperty(value = "数据") + @Schema(name = "数据") private String params; /** * 执行时间 */ @ExcelProperty("方法执行时间") - @ApiModelProperty(value = "方法执行时间") + @Schema(name = "方法执行时间") private Long time; /** * 异常信息 */ @ExcelProperty("异常信息") - @ApiModelProperty(value = "异常信息") + @Schema(name = "异常信息") private String exception; /** * 服务ID */ @ExcelProperty("应用标识") - @ApiModelProperty(value = "应用标识") + @Schema(name = "应用标识") private String serviceId; /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java index 8f657945..c1ba4715 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysMenu.java @@ -20,7 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -45,45 +45,45 @@ public class SysMenu extends BaseEntity { * 菜单ID */ @TableId(value = "menu_id", type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "菜单id") + @Schema(name = "菜单id") private Long menuId; /** * 菜单名称 */ @NotBlank(message = "菜单名称不能为空") - @ApiModelProperty(value = "菜单名称") + @Schema(name = "菜单名称") private String name; /** * 菜单权限标识 */ - @ApiModelProperty(value = "菜单权限标识") + @Schema(name = "菜单权限标识") private String permission; /** * 父菜单ID */ @NotNull(message = "菜单父ID不能为空") - @ApiModelProperty(value = "菜单父id") + @Schema(name = "菜单父id") private Long parentId; /** * 图标 */ - @ApiModelProperty(value = "菜单图标") + @Schema(name = "菜单图标") private String icon; /** * 前端URL */ - @ApiModelProperty(value = "前端路由标识路径") + @Schema(name = "前端路由标识路径") private String path; /** * 排序值 */ - @ApiModelProperty(value = "排序值") + @Schema(name = "排序值") private Integer sortOrder; /** @@ -95,7 +95,7 @@ public class SysMenu extends BaseEntity { /** * 路由缓冲 */ - @ApiModelProperty(value = "路由缓冲") + @Schema(name = "路由缓冲") private String keepAlive; /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java index 44ca4548..cbf55f28 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysOauthClientDetails.java @@ -19,7 +19,7 @@ package com.pig4cloud.pig.admin.api.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -44,69 +44,69 @@ public class SysOauthClientDetails extends BaseEntity { */ @NotBlank(message = "client_id 不能为空") @TableId(value = "client_id", type = IdType.INPUT) - @ApiModelProperty(value = "客户端id") + @Schema(name = "客户端id") private String clientId; /** * 客户端密钥 */ @NotBlank(message = "client_secret 不能为空") - @ApiModelProperty(value = "客户端密钥") + @Schema(name = "客户端密钥") private String clientSecret; /** * 资源ID */ - @ApiModelProperty(value = "资源id列表") + @Schema(name = "资源id列表") private String resourceIds; /** * 作用域 */ @NotBlank(message = "scope 不能为空") - @ApiModelProperty(value = "作用域") + @Schema(name = "作用域") private String scope; /** * 授权方式(A,B,C) */ - @ApiModelProperty(value = "授权方式") + @Schema(name = "授权方式") private String authorizedGrantTypes; /** * 回调地址 */ - @ApiModelProperty(value = "回调地址") + @Schema(name = "回调地址") private String webServerRedirectUri; /** * 权限 */ - @ApiModelProperty(value = "权限列表") + @Schema(name = "权限列表") private String authorities; /** * 请求令牌有效时间 */ - @ApiModelProperty(value = "请求令牌有效时间") + @Schema(name = "请求令牌有效时间") private Integer accessTokenValidity; /** * 刷新令牌有效时间 */ - @ApiModelProperty(value = "刷新令牌有效时间") + @Schema(name = "刷新令牌有效时间") private Integer refreshTokenValidity; /** * 扩展信息 */ - @ApiModelProperty(value = "扩展信息") + @Schema(name = "扩展信息") private String additionalInformation; /** * 是否自动放行 */ - @ApiModelProperty(value = "是否自动放行") + @Schema(name = "是否自动放行") private String autoapprove; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java index 785ea082..bb7338b3 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPost.java @@ -20,8 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -34,7 +33,7 @@ import lombok.EqualsAndHashCode; @Data @TableName("sys_post") @EqualsAndHashCode(callSuper = true) -@ApiModel(value = "岗位信息表") +@Schema(name = "岗位信息表") public class SysPost extends BaseEntity { private static final long serialVersionUID = -8744622014102311894L; @@ -43,37 +42,37 @@ public class SysPost extends BaseEntity { * 岗位ID */ @TableId(type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "岗位ID") + @Schema(name = "岗位ID") private Long postId; /** * 岗位编码 */ - @ApiModelProperty(value = "岗位编码") + @Schema(name = "岗位编码") private String postCode; /** * 岗位名称 */ - @ApiModelProperty(value = "岗位名称") + @Schema(name = "岗位名称") private String postName; /** * 岗位排序 */ - @ApiModelProperty(value = "岗位排序") + @Schema(name = "岗位排序") private Integer postSort; /** * 是否删除 -1:已删除 0:正常 */ - @ApiModelProperty(value = "是否删除 -1:已删除 0:正常") + @Schema(name = "是否删除 -1:已删除 0:正常") private String delFlag; /** * 备注信息 */ - @ApiModelProperty(value = "备注信息") + @Schema(name = "备注信息") private String remark; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java index dad1fca5..40fb3b6a 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysPublicParam.java @@ -17,16 +17,13 @@ package com.pig4cloud.pig.admin.api.entity; -import com.baomidou.mybatisplus.annotation.*; -import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; -import java.time.LocalDateTime; - /** * 公共参数配置 * @@ -34,7 +31,7 @@ import java.time.LocalDateTime; * @date 2019-04-29 */ @Data -@ApiModel(value = "公共参数") +@Schema(name = "公共参数") @EqualsAndHashCode(callSuper = true) public class SysPublicParam extends BaseEntity { @@ -44,49 +41,49 @@ public class SysPublicParam extends BaseEntity { * 编号 */ @TableId(type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "公共参数编号") + @Schema(name = "公共参数编号") private Long publicId; /** * 公共参数名称 */ - @ApiModelProperty(value = "公共参数名称", required = true, example = "公共参数名称") + @Schema(name = "公共参数名称", required = true, example = "公共参数名称") private String publicName; /** * 公共参数地址值,英文大写+下划线 */ - @ApiModelProperty(value = "键[英文大写+下划线]", required = true, example = "PIGX_PUBLIC_KEY") + @Schema(name = "键[英文大写+下划线]", required = true, example = "PIGX_PUBLIC_KEY") private String publicKey; /** * 值 */ - @ApiModelProperty(value = "值", required = true, example = "999") + @Schema(name = "值", required = true, example = "999") private String publicValue; /** * 状态(1有效;2无效;) */ - @ApiModelProperty(value = "标识[1有效;2无效]", example = "1") + @Schema(name = "标识[1有效;2无效]", example = "1") private String status; /** * 公共参数编码 */ - @ApiModelProperty(value = "编码", example = "^(PIG|PIGX)$") + @Schema(name = "编码", example = "^(PIG|PIGX)$") private String validateCode; /** * 是否是系统内置 */ - @ApiModelProperty(value = "是否是系统内置") + @Schema(name = "是否是系统内置") private String systemFlag; /** * 配置类型:0-默认;1-检索;2-原文;3-报表;4-安全;5-文档;6-消息;9-其他 */ - @ApiModelProperty(value = "类型[1-检索;2-原文...]", example = "1") + @Schema(name = "类型[1-检索;2-原文...]", example = "1") private String publicType; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java index 8f595532..2e863833 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRole.java @@ -20,7 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -41,19 +41,19 @@ public class SysRole extends BaseEntity { private static final long serialVersionUID = 1L; @TableId(value = "role_id", type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "角色编号") + @Schema(name = "角色编号") private Long roleId; @NotBlank(message = "角色名称 不能为空") - @ApiModelProperty(value = "角色名称") + @Schema(name = "角色名称") private String roleName; @NotBlank(message = "角色标识 不能为空") - @ApiModelProperty(value = "角色标识") + @Schema(name = "角色标识") private String roleCode; @NotBlank(message = "角色描述 不能为空") - @ApiModelProperty(value = "角色描述") + @Schema(name = "角色描述") private String roleDesc; /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java index cf83e51f..4e9d05d8 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysRoleMenu.java @@ -17,7 +17,7 @@ package com.pig4cloud.pig.admin.api.entity; import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -38,13 +38,13 @@ public class SysRoleMenu extends Model { /** * 角色ID */ - @ApiModelProperty(value = "角色id") + @Schema(name = "角色id") private Long roleId; /** * 菜单ID */ - @ApiModelProperty(value = "菜单id") + @Schema(name = "菜单id") private Long menuId; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java index 7d23faba..2a8a908d 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUser.java @@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.annotation.JsonIgnore; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -43,50 +43,50 @@ public class SysUser extends BaseEntity { * 主键ID */ @TableId(value = "user_id", type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "主键id") + @Schema(name = "主键id") private Long userId; /** * 用户名 */ - @ApiModelProperty(value = "用户名") + @Schema(name = "用户名") private String username; /** * 密码 */ - @ApiModelProperty(value = "密码") + @Schema(name = "密码") private String password; /** * 随机盐 */ @JsonIgnore - @ApiModelProperty(value = "随机盐") + @Schema(name = "随机盐") private String salt; /** * 锁定标记 */ - @ApiModelProperty(value = "锁定标记") + @Schema(name = "锁定标记") private String lockFlag; /** * 手机号 */ - @ApiModelProperty(value = "手机号") + @Schema(name = "手机号") private String phone; /** * 头像 */ - @ApiModelProperty(value = "头像地址") + @Schema(name = "头像地址") private String avatar; /** * 部门ID */ - @ApiModelProperty(value = "用户所属部门id") + @Schema(name = "用户所属部门id") private Long deptId; /** diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserPost.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserPost.java index 82e15fe0..d9b16b0c 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserPost.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserPost.java @@ -17,7 +17,7 @@ package com.pig4cloud.pig.admin.api.entity; import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -37,13 +37,13 @@ public class SysUserPost extends Model { /** * 用户ID */ - @ApiModelProperty(value = "用户id") + @Schema(name = "用户id") private Long userId; /** * 岗位ID */ - @ApiModelProperty(value = "岗位id") + @Schema(name = "岗位id") private Long postId; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java index f901efad..83b0864c 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/entity/SysUserRole.java @@ -17,7 +17,7 @@ package com.pig4cloud.pig.admin.api.entity; import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -38,13 +38,13 @@ public class SysUserRole extends Model { /** * 用户ID */ - @ApiModelProperty(value = "用户id") + @Schema(name = "用户id") private Long userId; /** * 角色ID */ - @ApiModelProperty(value = "角色id") + @Schema(name = "角色id") private Long roleId; } diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java index 0475127c..da7e286a 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleVo.java @@ -16,7 +16,7 @@ package com.pig4cloud.pig.admin.api.vo; -import io.swagger.annotations.ApiModel; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** @@ -24,7 +24,7 @@ import lombok.Data; * @date 2020/2/10 */ @Data -@ApiModel(value = "前端角色展示对象") +@Schema(name = "前端角色展示对象") public class RoleVo { /** diff --git a/pig-upms/pig-upms-biz/pom.xml b/pig-upms/pig-upms-biz/pom.xml index 745bdfe2..a210be18 100644 --- a/pig-upms/pig-upms-biz/pom.xml +++ b/pig-upms/pig-upms-biz/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-upms - 3.4.7 + 3.4.8 pig-upms-biz diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java index c2b96fa6..219f5011 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/PigAdminApplication.java @@ -18,7 +18,7 @@ package com.pig4cloud.pig.admin; import com.pig4cloud.pig.common.feign.annotation.EnablePigFeignClients; import com.pig4cloud.pig.common.security.annotation.EnablePigResourceServer; -import com.pig4cloud.pig.common.swagger.annotation.EnablePigSwagger2; +import com.pig4cloud.pig.common.swagger.annotation.EnablePigDoc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @@ -27,7 +27,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; * @author lengleng * @date 2018年06月21日 用户统一管理系统 */ -@EnablePigSwagger2 +@EnablePigDoc @EnablePigResourceServer @EnablePigFeignClients @EnableDiscoveryClient diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java index 189603e0..a80c1615 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/AppController.java @@ -7,8 +7,10 @@ import com.pig4cloud.pig.admin.service.AppService; import com.pig4cloud.pig.admin.service.SysUserService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -21,7 +23,8 @@ import org.springframework.web.bind.annotation.RestController; @RestController @AllArgsConstructor @RequestMapping("/app") -@Api(value = "app", tags = "手机管理模块") +@Tag(name = "移动端登录模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppController { private final AppService appService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java index 5e96bcde..23bd6dca 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DeptController.java @@ -22,8 +22,10 @@ import com.pig4cloud.pig.admin.service.SysDeptService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -41,7 +43,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/dept") -@Api(value = "dept", tags = "部门管理模块") +@Tag(name = "部门管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class DeptController { private final SysDeptService sysDeptService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java index e8a9b5c8..4df3486d 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/DictController.java @@ -26,10 +26,12 @@ import com.pig4cloud.pig.admin.service.SysDictService; import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -47,7 +49,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/dict") -@Api(value = "dict", tags = "字典管理模块") +@Tag(name = "字典管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class DictController { private final SysDictItemService sysDictItemService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java index aa62c83f..d97ee74b 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/FileController.java @@ -26,11 +26,13 @@ import com.pig4cloud.pig.admin.service.SysFileService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -44,9 +46,10 @@ import javax.servlet.http.HttpServletResponse; * @date 2021-09-11 */ @RestController -@AllArgsConstructor +@RequiredArgsConstructor @RequestMapping("/sys-file") -@Api(value = "sys-file", tags = "文件管理") +@Tag(name = "文件管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class FileController { private final SysFileService sysFileService; @@ -57,7 +60,7 @@ public class FileController { * @param sysFile 文件管理 * @return */ - @ApiOperation(value = "分页查询", notes = "分页查询") + @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") public R> getSysFilePage(Page page, SysFile sysFile) { return R.ok(sysFileService.page(page, Wrappers.query(sysFile))); @@ -68,7 +71,7 @@ public class FileController { * @param id id * @return R */ - @ApiOperation(value = "通过id删除文件管理", notes = "通过id删除文件管理") + @Operation(summary = "通过id删除文件管理", description = "通过id删除文件管理") @SysLog("删除文件管理") @DeleteMapping("/{id:\\d+}") @PreAuthorize("@pms.hasPermission('sys_file_del')") diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java index a6bf73d5..ff8c7f25 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/LogController.java @@ -23,8 +23,10 @@ import com.pig4cloud.pig.admin.service.SysLogService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.security.annotation.Inner; import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -42,7 +44,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/log") -@Api(value = "log", tags = "日志管理模块") +@Tag(name = "日志管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class LogController { private final SysLogService sysLogService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java index abf367c2..31d7c968 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/MenuController.java @@ -22,8 +22,10 @@ import com.pig4cloud.pig.admin.service.SysMenuService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.security.util.SecurityUtils; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -40,7 +42,8 @@ import java.util.stream.Collectors; @RestController @RequiredArgsConstructor @RequestMapping("/menu") -@Api(value = "menu", tags = "菜单管理模块") +@Tag(name = "菜单管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class MenuController { private final SysMenuService sysMenuService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java index 45e8ece4..324565d4 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/OauthClientDetailsController.java @@ -23,8 +23,10 @@ import com.pig4cloud.pig.admin.api.entity.SysOauthClientDetails; import com.pig4cloud.pig.admin.service.SysOauthClientDetailsService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -42,7 +44,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/client") -@Api(value = "client", tags = "客户端管理模块") +@Tag(name = "客户端管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class OauthClientDetailsController { private final SysOauthClientDetailsService sysOauthClientDetailsService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java index c7912bb6..e2ed6c0e 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PostController.java @@ -26,9 +26,11 @@ import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.plugin.excel.annotation.RequestExcel; import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; @@ -42,7 +44,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/post") -@Api(value = "post", tags = "岗位管理模块") +@Tag(name = "岗位管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class PostController { private final SysPostService sysPostService; @@ -61,7 +64,7 @@ public class PostController { * @param page 分页对象 * @return */ - @ApiOperation(value = "分页查询", notes = "分页查询") + @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") @PreAuthorize("@pms.hasPermission('sys_post_get')") public R getSysPostPage(Page page) { @@ -73,7 +76,7 @@ public class PostController { * @param postId id * @return R */ - @ApiOperation(value = "通过id查询", notes = "通过id查询") + @Operation(summary = "通过id查询", description = "通过id查询") @GetMapping("/{postId}") @PreAuthorize("@pms.hasPermission('sys_post_get')") public R getById(@PathVariable("postId") Long postId) { @@ -85,7 +88,7 @@ public class PostController { * @param sysPost 岗位信息表 * @return R */ - @ApiOperation(value = "新增岗位信息表", notes = "新增岗位信息表") + @Operation(summary = "新增岗位信息表", description = "新增岗位信息表") @SysLog("新增岗位信息表") @PostMapping @PreAuthorize("@pms.hasPermission('sys_post_add')") @@ -98,7 +101,7 @@ public class PostController { * @param sysPost 岗位信息表 * @return R */ - @ApiOperation(value = "修改岗位信息表", notes = "修改岗位信息表") + @Operation(summary = "修改岗位信息表", description = "修改岗位信息表") @SysLog("修改岗位信息表") @PutMapping @PreAuthorize("@pms.hasPermission('sys_post_edit')") @@ -111,7 +114,7 @@ public class PostController { * @param postId id * @return R */ - @ApiOperation(value = "通过id删除岗位信息表", notes = "通过id删除岗位信息表") + @Operation(summary = "通过id删除岗位信息表", description = "通过id删除岗位信息表") @SysLog("通过id删除岗位信息表") @DeleteMapping("/{postId}") @PreAuthorize("@pms.hasPermission('sys_post_del')") diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java index d80a5b93..53f56597 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/PublicParamController.java @@ -24,9 +24,11 @@ import com.pig4cloud.pig.admin.service.SysPublicParamService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.security.annotation.Inner; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -37,9 +39,10 @@ import org.springframework.web.bind.annotation.*; * @date 2019-04-29 */ @RestController -@AllArgsConstructor +@RequiredArgsConstructor @RequestMapping("/param") -@Api(value = "param", tags = "公共参数配置") +@Tag(name = "公共参数配置") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class PublicParamController { private final SysPublicParamService sysPublicParamService; @@ -50,7 +53,7 @@ public class PublicParamController { * @return */ @Inner(value = false) - @ApiOperation(value = "查询公共参数值", notes = "根据key查询公共参数值") + @Operation(summary = "查询公共参数值", description = "根据key查询公共参数值") @GetMapping("/publicValue/{publicKey}") public R publicKey(@PathVariable("publicKey") String publicKey) { return R.ok(sysPublicParamService.getSysPublicParamKeyToValue(publicKey)); @@ -62,7 +65,7 @@ public class PublicParamController { * @param sysPublicParam 公共参数 * @return */ - @ApiOperation(value = "分页查询", notes = "分页查询") + @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") public R getSysPublicParamPage(Page page, SysPublicParam sysPublicParam) { return R.ok(sysPublicParamService.page(page, Wrappers.query(sysPublicParam))); @@ -73,7 +76,7 @@ public class PublicParamController { * @param publicId id * @return R */ - @ApiOperation(value = "通过id查询公共参数", notes = "通过id查询公共参数") + @Operation(summary = "通过id查询公共参数", description = "通过id查询公共参数") @GetMapping("/{publicId}") public R getById(@PathVariable("publicId") Long publicId) { return R.ok(sysPublicParamService.getById(publicId)); @@ -84,7 +87,7 @@ public class PublicParamController { * @param sysPublicParam 公共参数 * @return R */ - @ApiOperation(value = "新增公共参数", notes = "新增公共参数") + @Operation(summary = "新增公共参数", description = "新增公共参数") @SysLog("新增公共参数") @PostMapping @PreAuthorize("@pms.hasPermission('sys_publicparam_add')") @@ -97,7 +100,7 @@ public class PublicParamController { * @param sysPublicParam 公共参数 * @return R */ - @ApiOperation(value = "修改公共参数", notes = "修改公共参数") + @Operation(summary = "修改公共参数", description = "修改公共参数") @SysLog("修改公共参数") @PutMapping @PreAuthorize("@pms.hasPermission('sys_publicparam_edit')") @@ -110,7 +113,7 @@ public class PublicParamController { * @param publicId id * @return R */ - @ApiOperation(value = "删除公共参数", notes = "删除公共参数") + @Operation(summary = "删除公共参数", description = "删除公共参数") @SysLog("删除公共参数") @DeleteMapping("/{publicId}") @PreAuthorize("@pms.hasPermission('sys_publicparam_del')") diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java index 461e1406..570ac8c6 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/RoleController.java @@ -28,8 +28,10 @@ import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.plugin.excel.annotation.RequestExcel; import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; @@ -44,7 +46,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/role") -@Api(value = "role", tags = "角色管理模块") +@Tag(name = "角色管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class RoleController { private final SysRoleService sysRoleService; @@ -125,7 +128,7 @@ public class RoleController { @PutMapping("/menu") @PreAuthorize("@pms.hasPermission('sys_role_perm')") public R saveRoleMenus(@RequestBody RoleVo roleVo) { - return R.ok(sysRoleMenuService.saveRoleMenus( roleVo.getRoleId(), roleVo.getMenuIds())); + return R.ok(sysRoleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds())); } /** diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java index 6d0716ba..140a1f3c 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/TokenController.java @@ -19,8 +19,10 @@ package com.pig4cloud.pig.admin.controller; import com.pig4cloud.pig.admin.api.feign.RemoteTokenService; import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.util.R; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -33,7 +35,8 @@ import java.util.Map; @RestController @RequiredArgsConstructor @RequestMapping("/token") -@Api(value = "token", tags = "令牌管理模块") +@Tag(name = "令牌管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class TokenController { private final RemoteTokenService remoteTokenService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java index 4c35750a..080e976c 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/UserController.java @@ -33,8 +33,10 @@ import com.pig4cloud.pig.common.security.annotation.Inner; import com.pig4cloud.pig.common.security.util.SecurityUtils; import com.pig4cloud.plugin.excel.annotation.RequestExcel; import com.pig4cloud.plugin.excel.annotation.ResponseExcel; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; @@ -50,7 +52,8 @@ import java.util.Set; @RestController @RequiredArgsConstructor @RequestMapping("/user") -@Api(value = "user", tags = "用户管理模块") +@Tag(name = "用户管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class UserController { private final SysUserService userService; diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java index 0430c06c..f8f5c084 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/SysRoleMenuService.java @@ -35,6 +35,6 @@ public interface SysRoleMenuService extends IService { * @param menuIds 菜单ID拼成的字符串,每个id之间根据逗号分隔 * @return */ - Boolean saveRoleMenus( Long roleId, String menuIds); + Boolean saveRoleMenus(Long roleId, String menuIds); } diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java index f598fbca..f57049a7 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleMenuServiceImpl.java @@ -48,14 +48,13 @@ public class SysRoleMenuServiceImpl extends ServiceImplquery().lambda().eq(SysRoleMenu::getRoleId, roleId)); if (StrUtil.isBlank(menuIds)) { diff --git a/pig-upms/pom.xml b/pig-upms/pom.xml index e39a84f5..d93f222e 100755 --- a/pig-upms/pom.xml +++ b/pig-upms/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.4.7 + 3.4.8 pig-upms diff --git a/pig-visual/pig-codegen/pom.xml b/pig-visual/pig-codegen/pom.xml index b8325bed..48678dbb 100755 --- a/pig-visual/pig-codegen/pom.xml +++ b/pig-visual/pig-codegen/pom.xml @@ -22,7 +22,7 @@ com.pig4cloud pig-visual - 3.4.7 + 3.4.8 pig-codegen diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java index 2fbdc72f..53135fe4 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/PigCodeGenApplication.java @@ -19,6 +19,7 @@ package com.pig4cloud.pig.codegen; import com.pig4cloud.pig.common.datasource.annotation.EnableDynamicDataSource; import com.pig4cloud.pig.common.feign.annotation.EnablePigFeignClients; import com.pig4cloud.pig.common.security.annotation.EnablePigResourceServer; +import com.pig4cloud.pig.common.swagger.annotation.EnablePigDoc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @@ -27,6 +28,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; * @author lengleng * @date 2020/03/11 代码生成模块 */ +@EnablePigDoc @EnableDynamicDataSource @EnablePigFeignClients @EnableDiscoveryClient diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java index a734be31..78092372 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenDsConfController.java @@ -22,8 +22,10 @@ import com.pig4cloud.pig.codegen.entity.GenDatasourceConf; import com.pig4cloud.pig.codegen.service.GenDatasourceConfService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -37,7 +39,8 @@ import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/dsconf") -@Api(value = "dsconf", tags = "数据源管理模块") +@Tag(name = "数据源管理模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class GenDsConfController { private final GenDatasourceConfService datasourceConfService; diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java index 4f4d63e6..23c01a28 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GenFormConfController.java @@ -23,9 +23,11 @@ import com.pig4cloud.pig.codegen.entity.GenFormConf; import com.pig4cloud.pig.codegen.service.GenFormConfService; import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.log.annotation.SysLog; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -38,7 +40,8 @@ import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @RequestMapping("/form") -@Api(value = "form", tags = "表单管理") +@Tag(name = "表单管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class GenFormConfController { private final GenFormConfService genRecordService; @@ -49,7 +52,7 @@ public class GenFormConfController { * @param formConf 生成记录 * @return */ - @ApiOperation(value = "分页查询", notes = "分页查询") + @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") public R> getGenFormConfPage(Page page, GenFormConf formConf) { return R.ok(genRecordService.page(page, Wrappers.query(formConf))); @@ -60,7 +63,7 @@ public class GenFormConfController { * @param id id * @return R */ - @ApiOperation(value = "通过id查询", notes = "通过id查询") + @Operation(summary = "通过id查询", description = "通过id查询") @GetMapping("/{id}") public R getById(@PathVariable("id") Integer id) { return R.ok(genRecordService.getById(id)); @@ -72,7 +75,7 @@ public class GenFormConfController { * @param tableName tableName * @return R */ - @ApiOperation(value = "通过tableName查询表单信息") + @Operation(summary = "通过tableName查询表单信息") @GetMapping("/info") public R form(String dsName, String tableName) { return R.ok(genRecordService.getForm(dsName, tableName)); @@ -83,7 +86,7 @@ public class GenFormConfController { * @param formConf 生成记录 * @return R */ - @ApiOperation(value = "新增生成记录", notes = "新增生成记录") + @Operation(summary = "新增生成记录", description = "新增生成记录") @SysLog("新增生成记录") @PostMapping @PreAuthorize("@pms.hasPermission('gen_form_add')") @@ -96,7 +99,7 @@ public class GenFormConfController { * @param id id * @return R */ - @ApiOperation(value = "通过id删除生成记录", notes = "通过id删除生成记录") + @Operation(summary = "通过id删除生成记录", description = "通过id删除生成记录") @SysLog("通过id删除生成记录") @DeleteMapping("/{id}") @PreAuthorize("@pms.hasPermission('gen_form_del')") diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java index d9850d77..978e8d30 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/controller/GeneratorController.java @@ -22,7 +22,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pig.codegen.entity.GenConfig; import com.pig4cloud.pig.codegen.service.GeneratorService; import com.pig4cloud.pig.common.core.util.R; -import io.swagger.annotations.Api; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import org.springframework.http.HttpHeaders; @@ -41,7 +42,8 @@ import java.util.Map; @RestController @RequiredArgsConstructor @RequestMapping("/generator") -@Api(value = "generator", tags = "代码生成模块") +@Tag(name = "代码生成模块") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class GeneratorController { private final GeneratorService generatorService; diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java index f51aecf0..d815dd4d 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenFormConf.java @@ -20,8 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -33,33 +32,33 @@ import lombok.EqualsAndHashCode; */ @Data @TableName("gen_form_conf") +@Schema(name = "生成记录") @EqualsAndHashCode(callSuper = true) -@ApiModel(value = "生成记录") public class GenFormConf extends BaseEntity { /** * ID */ @TableId(type = IdType.ASSIGN_ID) - @ApiModelProperty(value = "ID") + @Schema(name = "ID") private Long id; /** * 表名称 */ - @ApiModelProperty(value = "表名称") + @Schema(name = "表名称") private String tableName; /** * 表单信息 */ - @ApiModelProperty(value = "表单信息") + @Schema(name = "表单信息") private String formInfo; /** * 删除标记 */ - @ApiModelProperty(value = "删除标记") + @Schema(name = "删除标记") private String delFlag; } diff --git a/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm index b6fe635b..deae73b0 100755 --- a/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm +++ b/pig-visual/pig-codegen/src/main/resources/template/Controller.java.vm @@ -24,9 +24,11 @@ import com.pig4cloud.pig.common.log.annotation.SysLog; import ${package}.${moduleName}.entity.${className}; import ${package}.${moduleName}.service.${className}Service; import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.*; @@ -39,7 +41,8 @@ import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @RequestMapping("/${pathName}" ) -@Api(value = "${pathName}", tags = "${comments}管理") +@Tag(name = "${comments}管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class ${className}Controller { private final ${className}Service ${classname}Service; @@ -50,7 +53,7 @@ public class ${className}Controller { * @param ${classname} ${comments} * @return */ - @ApiOperation(value = "分页查询", notes = "分页查询") + @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page" ) @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" ) public R get${className}Page(Page page, ${className} ${classname}) { @@ -63,7 +66,7 @@ public class ${className}Controller { * @param ${pk.lowerAttrName} id * @return R */ - @ApiOperation(value = "通过id查询", notes = "通过id查询") + @Operation(summary = "通过id查询", description = "通过id查询") @GetMapping("/{${pk.lowerAttrName}}" ) @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" ) public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) { @@ -75,7 +78,7 @@ public class ${className}Controller { * @param ${classname} ${comments} * @return R */ - @ApiOperation(value = "新增${comments}", notes = "新增${comments}") + @Operation(summary = "新增${comments}", description = "新增${comments}") @SysLog("新增${comments}" ) @PostMapping @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" ) @@ -88,7 +91,7 @@ public class ${className}Controller { * @param ${classname} ${comments} * @return R */ - @ApiOperation(value = "修改${comments}", notes = "修改${comments}") + @Operation(summary = "修改${comments}", description = "修改${comments}") @SysLog("修改${comments}" ) @PutMapping @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" ) @@ -101,7 +104,7 @@ public class ${className}Controller { * @param ${pk.lowerAttrName} id * @return R */ - @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}") + @Operation(summary = "通过id删除${comments}", description = "通过id删除${comments}") @SysLog("通过id删除${comments}" ) @DeleteMapping("/{${pk.lowerAttrName}}" ) @PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" ) diff --git a/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm index ffef6066..4d22d631 100755 --- a/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm +++ b/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm @@ -21,8 +21,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.pig4cloud.pig.common.mybatis.base.BaseEntity; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; #if(${hasBigDecimal}) @@ -38,7 +37,7 @@ import java.math.BigDecimal; @Data @TableName("${tableName}") @EqualsAndHashCode(callSuper = true) -@ApiModel(value = "${comments}") +@Schema(name = "${comments}") public class ${className} extends BaseEntity { #foreach ($column in $columns) @@ -50,7 +49,7 @@ public class ${className} extends BaseEntity { #if($column.columnName == $pk.columnName) @TableId(type = IdType.ASSIGN_ID) #end - @ApiModelProperty(value="$column.comments"#if($column.hidden),hidden=$column.hidden#end) + @Schema(name="$column.comments"#if($column.hidden),hidden=$column.hidden#end) private $column.attrType $column.lowerAttrName; #end diff --git a/pig-visual/pig-monitor/pom.xml b/pig-visual/pig-monitor/pom.xml index 52e38bd5..58c701db 100755 --- a/pig-visual/pig-monitor/pom.xml +++ b/pig-visual/pig-monitor/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig-visual - 3.4.7 + 3.4.8 pig-monitor diff --git a/pig-visual/pig-sentinel-dashboard/pom.xml b/pig-visual/pig-sentinel-dashboard/pom.xml index b781a0b7..137f51aa 100755 --- a/pig-visual/pig-sentinel-dashboard/pom.xml +++ b/pig-visual/pig-sentinel-dashboard/pom.xml @@ -6,7 +6,7 @@ com.pig4cloud pig-visual - 3.4.7 + 3.4.8 pig-sentinel-dashboard diff --git a/pig-visual/pig-xxl-job-admin/pom.xml b/pig-visual/pig-xxl-job-admin/pom.xml index 8c684a89..831103fb 100644 --- a/pig-visual/pig-xxl-job-admin/pom.xml +++ b/pig-visual/pig-xxl-job-admin/pom.xml @@ -4,7 +4,7 @@ com.pig4cloud pig-visual - 3.4.7 + 3.4.8 pig-xxl-job-admin diff --git a/pig-visual/pom.xml b/pig-visual/pom.xml index ca0dc869..7b272bba 100755 --- a/pig-visual/pom.xml +++ b/pig-visual/pom.xml @@ -21,7 +21,7 @@ com.pig4cloud pig - 3.4.7 + 3.4.8 pig-visual diff --git a/pom.xml b/pom.xml index 7e523153..98826b54 100755 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ com.pig4cloud pig ${project.artifactId} - 3.4.7 + 3.4.8 pom https://www.pig4cloud.com From 343581534697b6fb3ef6190f1710a44369c47cef Mon Sep 17 00:00:00 2001 From: qraddx Date: Sun, 27 Mar 2022 23:20:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:card=5Ffile=5Fbox:=20=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9B=B8=E5=85=B3=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=20=E6=B7=BB=E5=8A=A0springdoc=20=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/pig_config.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/pig_config.sql b/db/pig_config.sql index af68559d..8aae8c27 100644 --- a/db/pig_config.sql +++ b/db/pig_config.sql @@ -36,10 +36,10 @@ CREATE TABLE `config_info` ( -- Records of config_info -- ---------------------------- BEGIN; -INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', '# 加解密根密码\njasypt:\n encryptor:\n password: pig #根密码\n\n# Spring 相关\n\nspring:\n mvc:\n pathmatch:\n matching-strategy: ant_path_matcher\n redis:\n host: pig-redis\n cloud:\n sentinel:\n eager: true\n transport:\n dashboard: pig-sentinel:5003\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \"*\" \n endpoint:\n health:\n show-details: ALWAYS\n\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# mybaits-plus配置\nmybatis-plus:\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n table-underline: true\n logic-delete-value: 1\n logic-not-delete-value: 0\n configuration:\n map-underscore-to-camel-case: true\n\n# spring security 配置\nsecurity:\n oauth2:\n resource:\n loadBalanced: true\n token-info-uri: http://pig-auth/oauth/check_token\n # 通用放行URL,服务个性化,请在对应配置文件覆盖\n ignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n# swagger 配置\nswagger:\n enabled: true\n title: Pig Swagger API\n license: Powered By pig4cloud\n licenseUrl: https://pig4cloud.com\n terms-of-service-url: https://pig4cloud.com\n contact:\n email: wangiegie@gmail.com\n url: https://pig4cloud.com\n authorization:\n name: pig4cloud OAuth\n auth-regex: ^.*$\n authorization-scope-list:\n - scope: server\n description: server all\n token-url-list:\n - http://${GATEWAY_HOST:pig-gateway}:${GATEWAY-PORT:9999}/auth/oauth/token', 'e9998245e4edea8eab9713df40639d45', '2019-11-29 16:31:20', '2022-03-20 21:16:50', 'nacos', '127.0.0.1', '', '', '通用配置', 'null', 'null', 'yaml', 'null'); +INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', '# 加解密根密码\njasypt:\n encryptor:\n password: pig #根密码\n\n# Spring 相关\n\nspring:\n mvc:\n pathmatch:\n matching-strategy: ant_path_matcher\n redis:\n host: pig-redis\n cloud:\n sentinel:\n eager: true\n transport:\n dashboard: pig-sentinel:5003\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \"*\" \n endpoint:\n health:\n show-details: ALWAYS\n\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# mybaits-plus配置\nmybatis-plus:\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n table-underline: true\n logic-delete-value: 1\n logic-not-delete-value: 0\n configuration:\n map-underscore-to-camel-case: true\n\n# spring security 配置\nsecurity:\n oauth2:\n resource:\n loadBalanced: true\n token-info-uri: http://pig-auth/oauth/check_token\n # 通用放行URL,服务个性化,请在对应配置文件覆盖\n ignore:\n urls:\n - /v3/api-docs\n - /v2/api-docs\n - /actuator/**\n# swagger 配置\nswagger:\n enabled: true\n title: Pig Swagger API\n gateway: http://${GATEWAY_HOST:pig-gateway}:${GATEWAY-PORT:9999}\n token-url: ${swagger.gateway}/auth/oauth/token\n services:\n pig-upms-biz: admin\n pig-codegen: gen', 'fe841b616618e0d7dfdfbb78ff08dc93', '2019-11-29 16:31:20', '2022-03-27 23:19:22', '', '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (2, 'pig-auth-dev.yml', 'DEFAULT_GROUP', '# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n freemarker:\n allow-request-override: false\n allow-session-override: false\n cache: true\n charset: UTF-8\n check-template-location: true\n content-type: text/html\n enabled: true\n expose-request-attributes: false\n expose-session-attributes: false\n expose-spring-macro-helpers: true\n prefer-file-system-access: true\n suffix: .ftl\n template-loader-path: classpath:/templates/', '58b1b48a2888f49e667864be32edf9c1', '2019-11-29 16:31:48', '2020-01-01 18:30:58', NULL, '127.0.0.1', '', '', '认证中心配置', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (3, 'pig-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(27v1agvAug87ANOVnbKdsw==)\n client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)\n scope: server\n\n# 数据源配置\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\n# 直接放行URL\nignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n', 'abc702838b34d11b46e96143ccd9f367', '2019-11-29 16:32:12', '2019-11-29 16:32:12', NULL, '127.0.0.1', '', '', '代码生成配置', NULL, NULL, 'yaml', NULL); -INSERT INTO `config_info` VALUES (4, 'pig-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n locator:\n enabled: true\n routes:\n # 认证中心\n - id: pig-auth\n uri: lb://pig-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - ValidateCodeGatewayFilter\n # 前端密码解密\n - PasswordDecoderFilter\n #UPMS 模块\n - id: pig-upms-biz\n uri: lb://pig-upms-biz\n predicates:\n - Path=/admin/**\n filters:\n # 限流配置\n - name: RequestRateLimiter\n args:\n key-resolver: \'#{@remoteAddrKeyResolver}\'\n redis-rate-limiter.replenishRate: 100\n redis-rate-limiter.burstCapacity: 200\n # 代码生成模块\n - id: pig-codegen\n uri: lb://pig-codegen\n predicates:\n - Path=/gen/**\n\n\ngateway:\n encode-key: \'thanks,pig4cloud\'\n ignore-clients:\n - test\n\nswagger:\n ignore-providers:\n - pig-auth\n - pig-codegen\n', '5cd71b235930c78e700819b944a14446', '2019-11-29 16:32:42', '2020-10-09 17:10:45', NULL, '0:0:0:0:0:0:0:1', '', '', '网关配置', '', '', 'yaml', ''); +INSERT INTO `config_info` VALUES (4, 'pig-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n locator:\n enabled: true\n routes:\n # 认证中心\n - id: pig-auth\n uri: lb://pig-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - ValidateCodeGatewayFilter\n # 前端密码解密\n - PasswordDecoderFilter\n #UPMS 模块\n - id: pig-upms-biz\n uri: lb://pig-upms-biz\n predicates:\n - Path=/admin/**\n filters:\n # 限流配置\n - name: RequestRateLimiter\n args:\n key-resolver: \'#{@remoteAddrKeyResolver}\'\n redis-rate-limiter.replenishRate: 100\n redis-rate-limiter.burstCapacity: 200\n # 代码生成模块\n - id: pig-codegen\n uri: lb://pig-codegen\n predicates:\n - Path=/gen/**\n # demo模块\n - id: pig-demo\n uri: lb://demo-biz\n predicates:\n - Path=/demo/**\n - id: openapi\n uri: http://localhost:${server.port}\n predicates:\n - Path=/v3/api-docs/**\n filters:\n - RewritePath=/v3/api-docs/(?.*), /$\\{path}/v3/api-docs\n\ngateway:\n encode-key: \'thanks,pig4cloud\'\n ignore-clients:\n - test', 'dbf00e83f80de7f011d244ea1ce5686e', '2019-11-29 16:32:42', '2022-03-27 23:19:33', '', '0:0:0:0:0:0:0:1', '', '', '网关配置', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (5, 'pig-monitor-dev.yml', 'DEFAULT_GROUP', 'spring:\n autoconfigure:\n exclude: com.pig4cloud.pig.common.core.config.JacksonConfiguration\n # 安全配置\n security:\n user:\n name: ENC(8Hk2ILNJM8UTOuW/Xi75qg==) # pig\n password: ENC(o6cuPFfUevmTbkmBnE67Ow====) # pig\n', '650bdfa15f60f3faa84dfe6e6878b8cf', '2019-11-29 16:33:05', '2022-03-22 17:50:52', 'nacos', '127.0.0.1', '', '', '监控配置', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (6, 'pig-upms-biz-dev.yml', 'DEFAULT_GROUP', 'security:\n oauth2:\n client:\n client-id: ENC(imENTO7M8bLO38LFSIxnzw==)\n client-secret: ENC(i3cDFhs26sa2Ucrfz2hnQw==)\n scope: server\n\n# 数据源\nspring:\n datasource:\n type: com.zaxxer.hikari.HikariDataSource\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: root\n password: root\n url: jdbc:mysql://pig-mysql:3306/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n\n# 文件上传相关 支持阿里云、华为云、腾讯、minio\noss:\n endpoint: http://minio.pig4cloud.com\n accessKey: lengleng\n secretKey: lengleng\n bucket-name: tmp', '5041ac486e18aa0dd0bf624bb83806de', '2019-11-29 16:52:32', '2021-09-11 14:19:55', '', '127.0.0.1', '', '', '统一权限', 'null', 'null', 'yaml', 'null'); COMMIT; From 1f7d79f00681e4c46d84a5a6c63d0f59c34c3339 Mon Sep 17 00:00:00 2001 From: qraddx Date: Wed, 30 Mar 2022 08:46:33 +0800 Subject: [PATCH 3/3] :sparkles: Introducing new features. pig-common-seata --- README.md | 1 + pig-common/pig-common-bom/pom.xml | 12 ++ .../factory/YamlPropertySourceFactory.java | 44 +++++ pig-common/pig-common-seata/pom.xml | 51 +++++ .../seata/config/SeataAutoConfiguration.java | 19 ++ .../seata/spring/util/SpringProxyUtils.java | 177 ++++++++++++++++++ .../main/resources/META-INF/spring.factories | 5 + .../src/main/resources/seata-config.yml | 56 ++++++ pig-common/pom.xml | 43 ++--- 9 files changed, 387 insertions(+), 21 deletions(-) create mode 100644 pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/factory/YamlPropertySourceFactory.java create mode 100755 pig-common/pig-common-seata/pom.xml create mode 100644 pig-common/pig-common-seata/src/main/java/com/pig4cloud/pig/common/seata/config/SeataAutoConfiguration.java create mode 100644 pig-common/pig-common-seata/src/main/java/io/seata/spring/util/SpringProxyUtils.java create mode 100644 pig-common/pig-common-seata/src/main/resources/META-INF/spring.factories create mode 100644 pig-common/pig-common-seata/src/main/resources/seata-config.yml diff --git a/README.md b/README.md index 19102829..a134c9a7 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ pig ├── pig-common-job -- xxl-job 封装 ├── pig-common-log -- 日志服务 ├── pig-common-mybatis -- mybatis 扩展封装 + ├── pig-common-seata -- 分布式事务 ├── pig-common-security -- 安全工具类 ├── pig-common-swagger -- 接口文档 ├── pig-common-feign -- feign 扩展封装 diff --git a/pig-common/pig-common-bom/pom.xml b/pig-common/pig-common-bom/pom.xml index 18abfa73..05de023d 100644 --- a/pig-common/pig-common-bom/pom.xml +++ b/pig-common/pig-common-bom/pom.xml @@ -27,6 +27,7 @@ 1.6.6 2.1.13 3.5.1 + 1.4.2 1.1.1 1.0.3 2.0.2 @@ -76,6 +77,11 @@ pig-common-swagger ${pig.common.version} + + com.pig4cloud + pig-common-seata + ${pig.common.version} + com.pig4cloud pig-common-test @@ -137,6 +143,12 @@ oss-spring-boot-starter ${oss.version} + + + io.seata + seata-serializer-kryo + ${seata.version} + com.baomidou diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/factory/YamlPropertySourceFactory.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/factory/YamlPropertySourceFactory.java new file mode 100644 index 00000000..e59ae6b6 --- /dev/null +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/factory/YamlPropertySourceFactory.java @@ -0,0 +1,44 @@ +package com.pig4cloud.pig.common.core.factory; + +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; +import org.springframework.core.env.PropertiesPropertySource; +import org.springframework.core.env.PropertySource; +import org.springframework.core.io.support.EncodedResource; +import org.springframework.core.io.support.PropertySourceFactory; +import org.springframework.lang.Nullable; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +/** + * @author lengleng + * @date 2022/3/29 + * + * 读取自定义 yaml 文件工厂类 + */ +public class YamlPropertySourceFactory implements PropertySourceFactory { + + @Override + public PropertySource createPropertySource(@Nullable String name, EncodedResource resource) throws IOException { + Properties propertiesFromYaml = loadYamlIntoProperties(resource); + String sourceName = name != null ? name : resource.getResource().getFilename(); + return new PropertiesPropertySource(sourceName, propertiesFromYaml); + } + + private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException { + try { + YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); + factory.setResources(resource.getResource()); + factory.afterPropertiesSet(); + return factory.getObject(); + } + catch (IllegalStateException e) { + Throwable cause = e.getCause(); + if (cause instanceof FileNotFoundException) + throw (FileNotFoundException) e.getCause(); + throw e; + } + } + +} diff --git a/pig-common/pig-common-seata/pom.xml b/pig-common/pig-common-seata/pom.xml new file mode 100755 index 00000000..230b0130 --- /dev/null +++ b/pig-common/pig-common-seata/pom.xml @@ -0,0 +1,51 @@ + + + + + 4.0.0 + + com.pig4cloud + pig-common + 3.4.8 + + + pig-common-seata + jar + + pig 分布式事务处理模块 + + + + + com.pig4cloud + pig-common-core + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-seata + + + + io.seata + seata-serializer-kryo + + + diff --git a/pig-common/pig-common-seata/src/main/java/com/pig4cloud/pig/common/seata/config/SeataAutoConfiguration.java b/pig-common/pig-common-seata/src/main/java/com/pig4cloud/pig/common/seata/config/SeataAutoConfiguration.java new file mode 100644 index 00000000..1efe7cf3 --- /dev/null +++ b/pig-common/pig-common-seata/src/main/java/com/pig4cloud/pig/common/seata/config/SeataAutoConfiguration.java @@ -0,0 +1,19 @@ +package com.pig4cloud.pig.common.seata.config; + +import com.pig4cloud.pig.common.core.factory.YamlPropertySourceFactory; +import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +/** + * Seata 配置类 + * + * @author lengleng + * @date 2022/3/29 + */ +@PropertySource(value = "classpath:seata-config.yml", factory = YamlPropertySourceFactory.class) +@EnableAutoDataSourceProxy +@Configuration(proxyBeanMethods = false) +public class SeataAutoConfiguration { + +} diff --git a/pig-common/pig-common-seata/src/main/java/io/seata/spring/util/SpringProxyUtils.java b/pig-common/pig-common-seata/src/main/java/io/seata/spring/util/SpringProxyUtils.java new file mode 100644 index 00000000..36650572 --- /dev/null +++ b/pig-common/pig-common-seata/src/main/java/io/seata/spring/util/SpringProxyUtils.java @@ -0,0 +1,177 @@ +/** + * @author lengleng + * @date 2022/3/29 + */ +package io.seata.spring.util; + +import io.seata.common.util.CollectionUtils; +import io.seata.rm.tcc.remoting.parser.DubboUtil; +import org.springframework.aop.TargetSource; +import org.springframework.aop.framework.Advised; +import org.springframework.aop.framework.AdvisedSupport; +import org.springframework.aop.support.AopUtils; + +import java.lang.reflect.Field; +import java.lang.reflect.Proxy; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * Proxy tools base on spring 主要解决 v1.4.2 兼容性问题 https://github.com/seata/seata/issues/3709 + * + * @author zhangsen + */ +public class SpringProxyUtils { + + private SpringProxyUtils() { + } + + /** + * Find target class class. + * @param proxy the proxy + * @return the class + * @throws Exception the exception + */ + public static Class findTargetClass(Object proxy) throws Exception { + if (proxy == null) { + return null; + } + if (AopUtils.isAopProxy(proxy) && proxy instanceof Advised) { + // #issue 3709 + final TargetSource targetSource = ((Advised) proxy).getTargetSource(); + if (!targetSource.isStatic()) { + return targetSource.getTargetClass(); + } + return findTargetClass(targetSource.getTarget()); + } + return proxy.getClass(); + } + + public static Class[] findInterfaces(Object proxy) throws Exception { + if (AopUtils.isJdkDynamicProxy(proxy)) { + AdvisedSupport advised = getAdvisedSupport(proxy); + return getInterfacesByAdvised(advised); + } + else { + return new Class[] {}; + } + } + + private static Class[] getInterfacesByAdvised(AdvisedSupport advised) { + Class[] interfaces = advised.getProxiedInterfaces(); + if (interfaces.length > 0) { + return interfaces; + } + else { + throw new IllegalStateException("Find the jdk dynamic proxy class that does not implement the interface"); + } + } + + /** + * Gets advised support. + * @param proxy the proxy + * @return the advised support + * @throws Exception the exception + */ + public static AdvisedSupport getAdvisedSupport(Object proxy) throws Exception { + Field h; + if (AopUtils.isJdkDynamicProxy(proxy)) { + h = proxy.getClass().getSuperclass().getDeclaredField("h"); + } + else { + h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); + } + h.setAccessible(true); + Object dynamicAdvisedInterceptor = h.get(proxy); + Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); + advised.setAccessible(true); + return (AdvisedSupport) advised.get(dynamicAdvisedInterceptor); + } + + /** + * Is proxy boolean. + * @param bean the bean + * @return the boolean + */ + public static boolean isProxy(Object bean) { + if (bean == null) { + return false; + } + // check dubbo proxy ? + return DubboUtil.isDubboProxyName(bean.getClass().getName()) + || (Proxy.class.isAssignableFrom(bean.getClass()) || AopUtils.isAopProxy(bean)); + } + + /** + * Get the target class , get the interface of its agent if it is a Proxy + * @param proxy the proxy + * @return target interface + * @throws Exception the exception + */ + public static Class getTargetInterface(Object proxy) throws Exception { + if (proxy == null) { + throw new java.lang.IllegalArgumentException("proxy can not be null"); + } + + // jdk proxy + if (Proxy.class.isAssignableFrom(proxy.getClass())) { + Proxy p = (Proxy) proxy; + return p.getClass().getInterfaces()[0]; + } + + return getTargetClass(proxy); + } + + /** + * Get the class type of the proxy target object, if hadn't a target object, return + * the interface of the proxy + * @param proxy the proxy + * @return target interface + * @throws Exception the exception + */ + protected static Class getTargetClass(Object proxy) throws Exception { + if (proxy == null) { + throw new java.lang.IllegalArgumentException("proxy can not be null"); + } + // not proxy + if (!AopUtils.isAopProxy(proxy)) { + return proxy.getClass(); + } + AdvisedSupport advisedSupport = getAdvisedSupport(proxy); + Object target = advisedSupport.getTargetSource().getTarget(); + /* + * the Proxy of sofa:reference has no target + */ + if (target == null) { + if (CollectionUtils.isNotEmpty(advisedSupport.getProxiedInterfaces())) { + return advisedSupport.getProxiedInterfaces()[0]; + } + else { + return proxy.getClass(); + } + } + else { + return getTargetClass(target); + } + } + + /** + * get the all interfaces of bean, if the bean is null, then return empty array + * @param bean the bean + * @return target interface + */ + public static Class[] getAllInterfaces(Object bean) { + Set> interfaces = new HashSet<>(); + if (bean != null) { + Class clazz = bean.getClass(); + while (!Object.class.getName().equalsIgnoreCase(clazz.getName())) { + Class[] clazzInterfaces = clazz.getInterfaces(); + interfaces.addAll(Arrays.asList(clazzInterfaces)); + clazz = clazz.getSuperclass(); + } + } + return interfaces.toArray(new Class[0]); + } + +} diff --git a/pig-common/pig-common-seata/src/main/resources/META-INF/spring.factories b/pig-common/pig-common-seata/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..a1f9ebfe --- /dev/null +++ b/pig-common/pig-common-seata/src/main/resources/META-INF/spring.factories @@ -0,0 +1,5 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pig.common.seata.config.SeataAutoConfiguration + + + diff --git a/pig-common/pig-common-seata/src/main/resources/seata-config.yml b/pig-common/pig-common-seata/src/main/resources/seata-config.yml new file mode 100644 index 00000000..e5cd4015 --- /dev/null +++ b/pig-common/pig-common-seata/src/main/resources/seata-config.yml @@ -0,0 +1,56 @@ +seata: + enabled: true + tx-service-group: pig_tx_group # 事务群组(可以每个应用独立取名,也可以使用相同的名字) + client: + rm-report-success-enable: true + rm-table-meta-check-enable: false # 自动刷新缓存中的表结构(默认false) + rm-report-retry-count: 5 # 一阶段结果上报TC重试次数(默认5) + rm-async-commit-buffer-limit: 10000 # 异步提交缓存队列长度(默认10000) + rm: + lock: + lock-retry-internal: 10 # 校验或占用全局锁重试间隔(默认10ms) + lock-retry-times: 30 # 校验或占用全局锁重试次数(默认30) + lock-retry-policy-branch-rollback-on-conflict: true # 分支事务与其它全局回滚事务冲突时锁策略(优先释放本地锁让回滚成功) + tm-commit-retry-count: 3 # 一阶段全局提交结果上报TC重试次数(默认1次,建议大于1) + tm-rollback-retry-count: 3 # 一阶段全局回滚结果上报TC重试次数(默认1次,建议大于1) + undo: + undo-data-validation: true # 二阶段回滚镜像校验(默认true开启) + undo-log-serialization: kryo # undo序列化方式(默认jackson 不支持 LocalDateTime) + undo-log-table: undo_log # 自定义undo表名(默认undo_log) + log: + exceptionRate: 100 # 日志异常输出概率(默认100) + support: + spring: + datasource-autoproxy: true + service: + vgroup-mapping: + pig_tx_group: default # TC 集群(必须与seata-server保持一致) + enable-degrade: false # 降级开关 + disable-global-transaction: false # 禁用全局事务(默认false) + grouplist: + default: pig-seata:8091 + transport: + shutdown: + wait: 3 + thread-factory: + boss-thread-prefix: NettyBoss + worker-thread-prefix: NettyServerNIOWorker + server-executor-thread-prefix: NettyServerBizHandler + share-boss-worker: false + client-selector-thread-prefix: NettyClientSelector + client-selector-thread-size: 1 + client-worker-thread-prefix: NettyClientWorkerThread + type: TCP + server: NIO + heartbeat: true + serialization: seata + compressor: none + enable-client-batch-send-request: true # 客户端事务消息请求是否批量合并发送(默认true) + registry: + file: + name: file.conf + type: file + config: + file: + name: file.conf + type: file diff --git a/pig-common/pom.xml b/pig-common/pom.xml index 305d69c1..7e9b5f55 100755 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -16,29 +16,30 @@ --> - 4.0.0 - - com.pig4cloud - pig - 3.4.8 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + com.pig4cloud + pig + 3.4.8 + - pig-common - pom + pig-common + pom - pig 公共聚合模块 + pig 公共聚合模块 - - pig-common-bom - pig-common-core - pig-common-datasource - pig-common-job - pig-common-log - pig-common-mybatis - pig-common-security - pig-common-feign - pig-common-swagger - pig-common-test + + pig-common-bom + pig-common-core + pig-common-datasource + pig-common-job + pig-common-log + pig-common-mybatis + pig-common-seata + pig-common-security + pig-common-feign + pig-common-swagger + pig-common-test