From e28d73a76cdd9d91d52b37d311672d27ff6c29a6 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Fri, 10 Feb 2023 15:42:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-dependencies/pom.xml | 11 +++--- yudao-framework/yudao-common/pom.xml | 4 +-- .../yudao-spring-boot-starter-web/pom.xml | 14 +++----- ...ot.autoconfigure.AutoConfiguration.imports | 3 +- yudao-gateway/pom.xml | 22 ++++++++---- .../config/SpringDocConfiguration.java | 35 +++++++++++++++++++ .../yudao-module-infra-api/pom.xml | 6 +--- .../module/infra/InfraServerApplication.java | 4 ++- .../yudao-module-system-api/pom.xml | 6 +--- .../system/api/errorcode/ErrorCodeApi.java | 2 +- .../module/system/api/tenant/TenantApi.java | 2 +- .../system/api/user/AdminUserApiImpl.java | 8 ++--- .../controller/admin/user/UserController.java | 6 ++-- 13 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/config/SpringDocConfiguration.java diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 3c3e70b1b..a8e4ec365 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -199,14 +199,15 @@ - com.github.xiaoymin - knife4j-openapi3-spring-boot-starter - ${knife4j.version} + org.springdoc + springdoc-openapi-webflux-ui + 1.6.14 + org.springdoc - springdoc-openapi-ui - ${springdoc.version} + springdoc-openapi-webmvc-core + 1.6.14 diff --git a/yudao-framework/yudao-common/pom.xml b/yudao-framework/yudao-common/pom.xml index 77638edd6..06a793ec8 100644 --- a/yudao-framework/yudao-common/pom.xml +++ b/yudao-framework/yudao-common/pom.xml @@ -60,8 +60,8 @@ org.springdoc - springdoc-openapi-ui - provided + springdoc-openapi-webmvc-core + compile diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml index 91a1d7c56..d397a66c1 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml @@ -21,6 +21,11 @@ yudao-common + + org.springdoc + springdoc-openapi-webmvc-core + + org.springframework.boot @@ -33,15 +38,6 @@ true - - com.github.xiaoymin - knife4j-openapi3-spring-boot-starter - - - org.springdoc - springdoc-openapi-ui - - org.springframework.boot spring-boot-starter-validation diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 93b2afc3a..5e14783a4 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,6 +1,5 @@ cn.iocoder.yudao.framework.apilog.config.YudaoApiLogAutoConfiguration cn.iocoder.yudao.framework.jackson.config.YudaoJacksonAutoConfiguration -com.github.xiaoymin.knife4j.spring.configuration.Knife4jAutoConfiguration cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration -cn.iocoder.yudao.framework.xss.config.YudaoXssAutoConfiguration +cn.iocoder.yudao.framework.apilog.config.YudaoApiLogRpcAutoConfiguration diff --git a/yudao-gateway/pom.xml b/yudao-gateway/pom.xml index a2e13af96..2b1b27e69 100644 --- a/yudao-gateway/pom.xml +++ b/yudao-gateway/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> yudao cn.iocoder.cloud @@ -26,11 +26,23 @@ cn.iocoder.cloud yudao-spring-boot-starter-banner + + + org.springdoc + springdoc-openapi-webmvc-core + + cn.iocoder.cloud yudao-module-system-api ${revision} + + + org.springdoc + springdoc-openapi-webmvc-core + + @@ -44,13 +56,9 @@ javax.servlet-api - - com.github.xiaoymin - knife4j-openapi3-spring-boot-starter - org.springdoc - springdoc-openapi-ui + springdoc-openapi-webflux-ui diff --git a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/config/SpringDocConfiguration.java b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/config/SpringDocConfiguration.java new file mode 100644 index 000000000..ea54f01de --- /dev/null +++ b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/config/SpringDocConfiguration.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.gateway.config; + +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.GroupedOpenApi; +import org.springframework.cloud.gateway.route.RouteDefinition; +import org.springframework.cloud.gateway.route.RouteDefinitionLocator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Configuration +public class SpringDocConfiguration { + private static final String SERVER_NAME_SUFFIX = "-api"; + + @Bean + @Lazy(false) + public List apis(RouteDefinitionLocator locator) { + List groups = new ArrayList<>(); + List definitions = locator.getRouteDefinitions().collectList().block(); + for (RouteDefinition definition : definitions) { + log.info("id: " + definition.getId() + " " + definition.getUri().toString()); + } + definitions.stream() + .filter(routeDefinition -> routeDefinition.getId().matches(".*"+SERVER_NAME_SUFFIX)) + .forEach(routeDefinition -> { + String name = routeDefinition.getId().replaceAll(SERVER_NAME_SUFFIX, ""); + GroupedOpenApi.builder().pathsToMatch("/" + name + "/**").group(name).build(); + }); + return groups; + } +} diff --git a/yudao-module-infra/yudao-module-infra-api/pom.xml b/yudao-module-infra/yudao-module-infra-api/pom.xml index 86fcbd037..2765503d8 100644 --- a/yudao-module-infra/yudao-module-infra-api/pom.xml +++ b/yudao-module-infra/yudao-module-infra-api/pom.xml @@ -23,13 +23,9 @@ - - com.github.xiaoymin - knife4j-openapi3-spring-boot-starter - org.springdoc - springdoc-openapi-ui + springdoc-openapi-webmvc-core diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java index 6e4f4d0bc..17a1a4950 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.infra; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * 项目的启动类 - * + *

* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 diff --git a/yudao-module-system/yudao-module-system-api/pom.xml b/yudao-module-system/yudao-module-system-api/pom.xml index fafb194c0..1dab1e188 100644 --- a/yudao-module-system/yudao-module-system-api/pom.xml +++ b/yudao-module-system/yudao-module-system-api/pom.xml @@ -23,13 +23,9 @@ - - com.github.xiaoymin - knife4j-openapi3-spring-boot-starter - org.springdoc - springdoc-openapi-ui + springdoc-openapi-webmvc-core diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java index 9280ff538..202fee02a 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java @@ -27,7 +27,7 @@ public interface ErrorCodeApi { @PostMapping(PREFIX + "/auto-generate") @Operation(summary = "自动创建错误码") - CommonResult autoGenerateErrorCodes(@Valid @RequestBody List autoGenerateDTOs); + CommonResult autoGenerateErrorCodeList(@Valid @RequestBody List autoGenerateDTOs); @GetMapping(PREFIX + "/list") @Operation(summary = "增量获得错误码数组", description = "如果 minUpdateTime 为空时,则获取所有错误码") diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java index cefe6f70c..213926392 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java @@ -19,7 +19,7 @@ public interface TenantApi { @GetMapping(PREFIX + "/id-list") @Operation(summary = "获得所有租户编号") - CommonResult> getTenantIds(); + CommonResult> getTenantIdList(); @GetMapping(PREFIX + "/valid") @Operation(summary = "校验租户是否合法") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java index eb9adba11..3745263c8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java @@ -33,25 +33,25 @@ public class AdminUserApiImpl implements AdminUserApi { } @Override - public CommonResult> getUserList(Collection ids) { + public CommonResult> getUsers(Collection ids) { List users = userService.getUserList(ids); return success(UserConvert.INSTANCE.convertList4(users)); } @Override - public CommonResult> getUserListByDeptIds(Collection deptIds) { + public CommonResult> getUsersByDeptIds(Collection deptIds) { List users = userService.getUserListByDeptIds(deptIds); return success(UserConvert.INSTANCE.convertList4(users)); } @Override - public CommonResult> getUserListByPostIds(Collection postIds) { + public CommonResult> getUsersByPostIds(Collection postIds) { List users = userService.getUserListByPostIds(postIds); return success(UserConvert.INSTANCE.convertList4(users)); } @Override - public CommonResult validUserList(Set ids) { + public CommonResult validUsers(Set ids) { userService.validateUserList(ids); return success(true); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java index 05a90f528..7cf54ac25 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java @@ -113,7 +113,7 @@ public class UserController { @Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项") public CommonResult> getSimpleUsers() { // 获用户门列表,只要开启状态的 - List list = userService.getUsersByStatus(CommonStatusEnum.ENABLE.getStatus()); + List list = userService.getUserListByStatus(CommonStatusEnum.ENABLE.getStatus()); // 排序后,返回给前端 return success(UserConvert.INSTANCE.convertList04(list)); } @@ -133,7 +133,7 @@ public class UserController { public void exportUsers(@Validated UserExportReqVO reqVO, HttpServletResponse response) throws IOException { // 获得用户列表 - List users = userService.getUsers(reqVO); + List users = userService.getUserList(reqVO); // 获得拼接需要的数据 Collection deptIds = convertList(users, AdminUserDO::getDeptId); @@ -183,7 +183,7 @@ public class UserController { public CommonResult importExcel(@RequestParam("file") MultipartFile file, @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception { List list = ExcelUtils.read(file, UserImportExcelVO.class); - return success(userService.importUsers(list, updateSupport)); + return success(userService.importUserList(list, updateSupport)); } } \ No newline at end of file