diff --git a/README.md b/README.md index b0277fd54..8b72f5c1f 100644 --- a/README.md +++ b/README.md @@ -157,27 +157,27 @@ ps:核心功能已经实现,正在对接微信小程序中... | 框架 | 说明 | 版本 | 学习指南 | |---------------------------------------------------------------------------------------------|------------------|----------|----------------------------------------------------------------| -| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.5.12 | [文档](https://github.com/YunaiV/SpringBoot-Labs) | +| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.6.8 | [文档](https://github.com/YunaiV/SpringBoot-Labs) | | [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.7 | | | [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.2.8 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) | -| [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.5.1 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) | +| [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.5.2 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) | | [Dynamic Datasource](https://dynamic-datasource.com/) | 动态数据源 | 3.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) | | [Redis](https://redis.io/) | key-value 数据库 | 5.0 | | -| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 3.16.8 | [文档](http://www.iocoder.cn/Spring-Boot/Redis/?yudao) | -| [Spring MVC](https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc) | MVC 框架 | 5.3.16 | [文档](http://www.iocoder.cn/SpringMVC/MVC/?yudao) | -| [Spring Security](https://github.com/spring-projects/spring-security) | Spring 安全框架 | 5.5.5 | [文档](http://www.iocoder.cn/Spring-Boot/Spring-Security/?yudao) | -| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.2.2 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) | +| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 3.17.3 | [文档](http://www.iocoder.cn/Spring-Boot/Redis/?yudao) | +| [Spring MVC](https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc) | MVC 框架 | 5.3.20 | [文档](http://www.iocoder.cn/SpringMVC/MVC/?yudao) | +| [Spring Security](https://github.com/spring-projects/spring-security) | Spring 安全框架 | 5.6.5 | [文档](http://www.iocoder.cn/Spring-Boot/Spring-Security/?yudao) | +| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.2.3 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) | | [Activiti](https://github.com/Activiti/Activiti) | 工作流引擎 | 7.1.0.M6 | [文档](TODO) | | [Quartz](https://github.com/quartz-scheduler) | 任务调度组件 | 2.3.2 | [文档](http://www.iocoder.cn/Spring-Boot/Job/?yudao) | -| [Knife4j](https://gitee.com/xiaoym/knife4j) | Swagger 增强 UI 实现 | 3.0.2 | [文档](http://www.iocoder.cn/Spring-Boot/Swagger/?yudao) | -| [Resilience4j](https://github.com/resilience4j/resilience4j) | 服务保障组件 | 1.7.0 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) | +| [Knife4j](https://gitee.com/xiaoym/knife4j) | Swagger 增强 UI 实现 | 3.0.3 | [文档](http://www.iocoder.cn/Spring-Boot/Swagger/?yudao) | +| [Resilience4j](https://github.com/resilience4j/resilience4j) | 服务保障组件 | 1.7.1 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) | | [SkyWalking](https://skywalking.apache.org/) | 分布式应用追踪系统 | 8.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/SkyWalking/?yudao) | -| [Spring Boot Admin](https://github.com/codecentric/spring-boot-admin) | Spring Boot 监控平台 | 2.4.2 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) | -| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.12.6 | | +| [Spring Boot Admin](https://github.com/codecentric/spring-boot-admin) | Spring Boot 监控平台 | 2.6.7 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) | +| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.13.3 | | | [MapStruct](https://mapstruct.org/) | Java Bean 转换 | 1.4.1 | [文档](http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao) | | [Lombok](https://projectlombok.org/) | 消除冗长的 Java 代码 | 1.16.14 | [文档](http://www.iocoder.cn/Spring-Boot/Lombok/?yudao) | -| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.7.2 | - | -| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 3.9.0 | - | +| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.8.2 | - | +| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 4.0.0 | - | ### 前端 @@ -192,42 +192,41 @@ ps:核心功能已经实现,正在对接微信小程序中... | 模块 | biu | biu | biu | |----------|--------------------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------| -| 登录 & 首页 | ![登录](https://static.iocoder.cn/images/ruoyi-vue-pro/登录.jpg) | ![首页](https://static.iocoder.cn/images/ruoyi-vue-pro/首页.jpg) | ![个人中心](https://static.iocoder.cn/images/ruoyi-vue-pro/个人中心.jpg) | -| 用户 | ![用户管理](https://static.iocoder.cn/images/ruoyi-vue-pro/用户管理.jpg) | ![在线用户](https://static.iocoder.cn/images/ruoyi-vue-pro/在线用户.jpg) | - | -| 租户 & 套餐 | ![租户管理](https://static.iocoder.cn/images/ruoyi-vue-pro/租户管理.jpg) | ![租户套餐](https://static.iocoder.cn/images/ruoyi-vue-pro/租户套餐.png) | - | -| 部门 & 岗位 | ![部门管理](https://static.iocoder.cn/images/ruoyi-vue-pro/部门管理.jpg) | ![岗位管理](https://static.iocoder.cn/images/ruoyi-vue-pro/岗位管理.jpg) | - | -| 菜单 & 角色 | ![菜单管理](https://static.iocoder.cn/images/ruoyi-vue-pro/菜单管理.jpg) | ![角色管理](https://static.iocoder.cn/images/ruoyi-vue-pro/角色管理.jpg) | - | -| 审计日志 | ![操作日志](https://static.iocoder.cn/images/ruoyi-vue-pro/操作日志.jpg) | ![登录日志](https://static.iocoder.cn/images/ruoyi-vue-pro/登录日志.jpg) | - | -| 短信 | ![短信渠道](https://static.iocoder.cn/images/ruoyi-vue-pro/短信渠道.jpg) | ![短信模板](https://static.iocoder.cn/images/ruoyi-vue-pro/短信模板.jpg) | ![短信日志](https://static.iocoder.cn/images/ruoyi-vue-pro/短信日志.jpg) | -| 字典 | ![字典类型](https://static.iocoder.cn/images/ruoyi-vue-pro/字典类型.jpg) | ![字典数据](https://static.iocoder.cn/images/ruoyi-vue-pro/字典数据.jpg) | - | -| 错误码 & 通知 | ![错误码管理](https://static.iocoder.cn/images/ruoyi-vue-pro/错误码管理.jpg) | ![通知公告](https://static.iocoder.cn/images/ruoyi-vue-pro/通知公告.jpg) | - | +| 登录 & 首页 | ![登录](https://static.iocoder.cn/images/ruoyi-vue-pro/登录.jpg?imageView2/2/format/webp/w/1280) | ![首页](https://static.iocoder.cn/images/ruoyi-vue-pro/首页.jpg?imageView2/2/format/webp/w/1280) | ![个人中心](https://static.iocoder.cn/images/ruoyi-vue-pro/个人中心.jpg?imageView2/2/format/webp/w/1280) | +| 用户 | ![用户管理](https://static.iocoder.cn/images/ruoyi-vue-pro/用户管理.jpg?imageView2/2/format/webp/w/1280) | ![在线用户](https://static.iocoder.cn/images/ruoyi-vue-pro/在线用户.jpg?imageView2/2/format/webp/w/1280) | - | +| 租户 & 套餐 | ![租户管理](https://static.iocoder.cn/images/ruoyi-vue-pro/租户管理.jpg?imageView2/2/format/webp/w/1280) | ![租户套餐](https://static.iocoder.cn/images/ruoyi-vue-pro/租户套餐.png) | - | +| 部门 & 岗位 | ![部门管理](https://static.iocoder.cn/images/ruoyi-vue-pro/部门管理.jpg?imageView2/2/format/webp/w/1280) | ![岗位管理](https://static.iocoder.cn/images/ruoyi-vue-pro/岗位管理.jpg?imageView2/2/format/webp/w/1280) | - | +| 菜单 & 角色 | ![菜单管理](https://static.iocoder.cn/images/ruoyi-vue-pro/菜单管理.jpg?imageView2/2/format/webp/w/1280) | ![角色管理](https://static.iocoder.cn/images/ruoyi-vue-pro/角色管理.jpg?imageView2/2/format/webp/w/1280) | - | +| 审计日志 | ![操作日志](https://static.iocoder.cn/images/ruoyi-vue-pro/操作日志.jpg?imageView2/2/format/webp/w/1280) | ![登录日志](https://static.iocoder.cn/images/ruoyi-vue-pro/登录日志.jpg?imageView2/2/format/webp/w/1280) | - | +| 短信 | ![短信渠道](https://static.iocoder.cn/images/ruoyi-vue-pro/短信渠道.jpg?imageView2/2/format/webp/w/1280) | ![短信模板](https://static.iocoder.cn/images/ruoyi-vue-pro/短信模板.jpg?imageView2/2/format/webp/w/1280) | ![短信日志](https://static.iocoder.cn/images/ruoyi-vue-pro/短信日志.jpg?imageView2/2/format/webp/w/1280) | +| 字典 | ![字典类型](https://static.iocoder.cn/images/ruoyi-vue-pro/字典类型.jpg?imageView2/2/format/webp/w/1280) | ![字典数据](https://static.iocoder.cn/images/ruoyi-vue-pro/字典数据.jpg?imageView2/2/format/webp/w/1280) | - | +| 错误码 & 通知 | ![错误码管理](https://static.iocoder.cn/images/ruoyi-vue-pro/错误码管理.jpg?imageView2/2/format/webp/w/1280) | ![通知公告](https://static.iocoder.cn/images/ruoyi-vue-pro/通知公告.jpg?imageView2/2/format/webp/w/1280) | - | ### 工作流程 | 模块 | biu | biu | biu | |---------|------------------------------------------------------------------------|------------------------------------------------------------------------|------------------------------------------------------------------------| -| 流程模型 | ![流程模型-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-列表.jpg) | ![流程模型-设计](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-设计.jpg) | ![流程模型-定义](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-定义.jpg) | -| 表单 & 分组 | ![流程表单](https://static.iocoder.cn/images/ruoyi-vue-pro/流程表单.jpg) | ![用户分组](https://static.iocoder.cn/images/ruoyi-vue-pro/用户分组.jpg) | - | -| 我的流程 | ![我的流程-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-列表.jpg) | ![我的流程-发起](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-发起.jpg) | ![我的流程-详情](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-详情.jpg) | -| 待办 & 已办 | ![任务列表-审批](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-审批.jpg) | ![任务列表-待办](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-待办.jpg) | ![任务列表-已办](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-已办.jpg) | -| OA 请假 | ![OA请假-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-列表.jpg) | ![OA请假-发起](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-发起.jpg) | ![OA请假-详情](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-详情.jpg) | - -### 支付系统 - -| 模块 | biu | biu | biu | -|---------|------------------------------------------------------------------|------------------------------------------------------------------------|------------------------------------------------------------------------| -| 商家 & 应用 | ![商户信息](https://static.iocoder.cn/images/ruoyi-vue-pro/商户信息.jpg) | ![应用信息-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/应用信息-列表.jpg) | ![应用信息-编辑](https://static.iocoder.cn/images/ruoyi-vue-pro/应用信息-编辑.jpg) | -| 支付 & 退款 | ![支付订单](https://static.iocoder.cn/images/ruoyi-vue-pro/支付订单.jpg) | ![退款订单](https://static.iocoder.cn/images/ruoyi-vue-pro/退款订单.jpg) | --- | +| 流程模型 | ![流程模型-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-列表.jpg?imageView2/2/format/webp/w/1280) | ![流程模型-设计](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-设计.jpg?imageView2/2/format/webp/w/1280) | ![流程模型-定义](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-定义.jpg?imageView2/2/format/webp/w/1280) | +| 表单 & 分组 | ![流程表单](https://static.iocoder.cn/images/ruoyi-vue-pro/流程表单.jpg?imageView2/2/format/webp/w/1280) | ![用户分组](https://static.iocoder.cn/images/ruoyi-vue-pro/用户分组.jpg?imageView2/2/format/webp/w/1280) | - | +| 我的流程 | ![我的流程-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-列表.jpg?imageView2/2/format/webp/w/1280) | ![我的流程-发起](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-发起.jpg?imageView2/2/format/webp/w/1280) | ![我的流程-详情](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-详情.jpg?imageView2/2/format/webp/w/1280) | +| 待办 & 已办 | ![任务列表-审批](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-审批.jpg?imageView2/2/format/webp/w/1280) | ![任务列表-待办](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-待办.jpg?imageView2/2/format/webp/w/1280) | ![任务列表-已办](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-已办.jpg?imageView2/2/format/webp/w/1280) | +| OA 请假 | ![OA请假-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-列表.jpg?imageView2/2/format/webp/w/1280) | ![OA请假-发起](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-发起.jpg?imageView2/2/format/webp/w/1280) | ![OA请假-详情](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-详情.jpg?imageView2/2/format/webp/w/1280) | ### 基础设施 | 模块 | biu | biu | biu | |---------------|----------------------------------------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------| -| 代码生成 | ![代码生成](https://static.iocoder.cn/images/ruoyi-vue-pro/代码生成.jpg) | ![生成效果](https://static.iocoder.cn/images/ruoyi-vue-pro/生成效果.jpg) | - | -| 文档 | ![系统接口](https://static.iocoder.cn/images/ruoyi-vue-pro/系统接口.jpg) | ![数据库文档](https://static.iocoder.cn/images/ruoyi-vue-pro/数据库文档.jpg) | - | -| 文件 & 配置 | ![文件配置](https://static.iocoder.cn/images/ruoyi-vue-pro/文件配置.jpg) | ![文件管理](https://static.iocoder.cn/images/ruoyi-vue-pro/文件管理2.jpg) | ![配置管理](https://static.iocoder.cn/images/ruoyi-vue-pro/配置管理.jpg) | -| 定时任务 | ![定时任务](https://static.iocoder.cn/images/ruoyi-vue-pro/定时任务.jpg) | ![任务日志](https://static.iocoder.cn/images/ruoyi-vue-pro/任务日志.jpg) | - | -| API 日志 | ![访问日志](https://static.iocoder.cn/images/ruoyi-vue-pro/访问日志.jpg) | ![错误日志](https://static.iocoder.cn/images/ruoyi-vue-pro/错误日志.jpg) | - | -| MySQL & Redis | ![MySQL](https://static.iocoder.cn/images/ruoyi-vue-pro/MySQL.jpg) | ![Redis](https://static.iocoder.cn/images/ruoyi-vue-pro/Redis.jpg) | - | -| 监控平台 | ![Java监控](https://static.iocoder.cn/images/ruoyi-vue-pro/Java监控.jpg) | ![链路追踪](https://static.iocoder.cn/images/ruoyi-vue-pro/链路追踪.jpg) | ![日志中心](https://static.iocoder.cn/images/ruoyi-vue-pro/日志中心.jpg) | +| 代码生成 | ![代码生成](https://static.iocoder.cn/images/ruoyi-vue-pro/代码生成.jpg?imageView2/2/format/webp/w/1280) | ![生成效果](https://static.iocoder.cn/images/ruoyi-vue-pro/生成效果.jpg?imageView2/2/format/webp/w/1280) | - | +| 文档 | ![系统接口](https://static.iocoder.cn/images/ruoyi-vue-pro/系统接口.jpg?imageView2/2/format/webp/w/1280) | ![数据库文档](https://static.iocoder.cn/images/ruoyi-vue-pro/数据库文档.jpg?imageView2/2/format/webp/w/1280) | - | +| 文件 & 配置 | ![文件配置](https://static.iocoder.cn/images/ruoyi-vue-pro/文件配置.jpg?imageView2/2/format/webp/w/1280) | ![文件管理](https://static.iocoder.cn/images/ruoyi-vue-pro/文件管理2.jpg?imageView2/2/format/webp/w/1280) | ![配置管理](https://static.iocoder.cn/images/ruoyi-vue-pro/配置管理.jpg?imageView2/2/format/webp/w/1280) | +| 定时任务 | ![定时任务](https://static.iocoder.cn/images/ruoyi-vue-pro/定时任务.jpg?imageView2/2/format/webp/w/1280) | ![任务日志](https://static.iocoder.cn/images/ruoyi-vue-pro/任务日志.jpg?imageView2/2/format/webp/w/1280) | - | +| API 日志 | ![访问日志](https://static.iocoder.cn/images/ruoyi-vue-pro/访问日志.jpg?imageView2/2/format/webp/w/1280) | ![错误日志](https://static.iocoder.cn/images/ruoyi-vue-pro/错误日志.jpg?imageView2/2/format/webp/w/1280) | - | +| MySQL & Redis | ![MySQL](https://static.iocoder.cn/images/ruoyi-vue-pro/MySQL.jpg?imageView2/2/format/webp/w/1280) | ![Redis](https://static.iocoder.cn/images/ruoyi-vue-pro/Redis.jpg?imageView2/2/format/webp/w/1280) | - | +| 监控平台 | ![Java监控](https://static.iocoder.cn/images/ruoyi-vue-pro/Java监控.jpg?imageView2/2/format/webp/w/1280) | ![链路追踪](https://static.iocoder.cn/images/ruoyi-vue-pro/链路追踪.jpg?imageView2/2/format/webp/w/1280) | ![日志中心](https://static.iocoder.cn/images/ruoyi-vue-pro/日志中心.jpg?imageView2/2/format/webp/w/1280) | +### 支付系统 + +| 模块 | biu | biu | biu | +|---------|------------------------------------------------------------------|------------------------------------------------------------------------|------------------------------------------------------------------------| +| 商家 & 应用 | ![商户信息](https://static.iocoder.cn/images/ruoyi-vue-pro/商户信息.jpg?imageView2/2/format/webp/w/1280) | ![应用信息-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/应用信息-列表.jpg?imageView2/2/format/webp/w/1280) | ![应用信息-编辑](https://static.iocoder.cn/images/ruoyi-vue-pro/应用信息-编辑.jpg?imageView2/2/format/webp/w/1280) | +| 支付 & 退款 | ![支付订单](https://static.iocoder.cn/images/ruoyi-vue-pro/支付订单.jpg?imageView2/2/format/webp/w/1280) | ![退款订单](https://static.iocoder.cn/images/ruoyi-vue-pro/退款订单.jpg?imageView2/2/format/webp/w/1280) | --- | diff --git a/http-client.env.json b/http-client.env.json index 2f18d251c..d2ad9e7c2 100644 --- a/http-client.env.json +++ b/http-client.env.json @@ -7,5 +7,14 @@ "appApi": "http://127.0.0.1:48080/app-api", "appToken": "test1", "appTenentId": "1" + }, + "gateway": { + "baseUrl": "http://127.0.0.1:8888/admin-api", + "token": "test1", + "adminTenentId": "1", + + "appApi": "http://127.0.0.1:8888/app-api", + "appToken": "test1", + "appTenentId": "1" } } diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 959045186..a014a1b8c 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -11,7 +11,7 @@ Target Server Version : 80026 File Encoding : 65001 - Date: 25/05/2022 23:28:25 + Date: 15/06/2022 08:11:25 */ SET NAMES utf8mb4; @@ -300,7 +300,7 @@ CREATE TABLE `bpm_form` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的表单定义'; +) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的表单定义'; -- ---------------------------- -- Records of bpm_form @@ -359,7 +359,7 @@ CREATE TABLE `bpm_process_definition_ext` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 104 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Bpm 流程定义的拓展表\n'; +) ENGINE = InnoDB AUTO_INCREMENT = 119 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Bpm 流程定义的拓展表\n'; -- ---------------------------- -- Records of bpm_process_definition_ext @@ -389,7 +389,7 @@ CREATE TABLE `bpm_process_instance_ext` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 204 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的流程实例的拓展'; +) ENGINE = InnoDB AUTO_INCREMENT = 256 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的流程实例的拓展'; -- ---------------------------- -- Records of bpm_process_instance_ext @@ -415,7 +415,7 @@ CREATE TABLE `bpm_task_assign_rule` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 201 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Bpm 任务规则表'; +) ENGINE = InnoDB AUTO_INCREMENT = 225 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Bpm 任务规则表'; -- ---------------------------- -- Records of bpm_task_assign_rule @@ -431,6 +431,7 @@ CREATE TABLE `bpm_task_ext` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `assignee_user_id` bigint NULL DEFAULT NULL COMMENT '任务的审批人', `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '任务的名字', + `task_def_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '流程任务key', `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '任务的编号', `result` tinyint NOT NULL COMMENT '任务的结果', `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批建议', @@ -444,7 +445,7 @@ CREATE TABLE `bpm_task_ext` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 217 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的流程任务的拓展表'; +) ENGINE = InnoDB AUTO_INCREMENT = 295 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的流程任务的拓展表'; -- ---------------------------- -- Records of bpm_task_ext @@ -504,7 +505,7 @@ CREATE TABLE `infra_api_access_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 33232 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'API 访问日志表'; +) ENGINE = InnoDB AUTO_INCREMENT = 35150 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'API 访问日志表'; -- ---------------------------- -- Records of infra_api_access_log @@ -546,7 +547,7 @@ CREATE TABLE `infra_api_error_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 454 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志'; +) ENGINE = InnoDB AUTO_INCREMENT = 627 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志'; -- ---------------------------- -- Records of infra_api_error_log @@ -688,6 +689,7 @@ DROP TABLE IF EXISTS `infra_file`; CREATE TABLE `infra_file` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '文件编号', `config_id` bigint NULL DEFAULT NULL COMMENT '配置编号', + `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '文件名', `path` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件路径', `url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件 URL', `type` varchar(63) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '文件类型', @@ -698,7 +700,7 @@ CREATE TABLE `infra_file` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 83 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; +) ENGINE = InnoDB AUTO_INCREMENT = 85 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; -- ---------------------------- -- Records of infra_file @@ -723,7 +725,7 @@ CREATE TABLE `infra_file_config` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件配置表'; +) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件配置表'; -- ---------------------------- -- Records of infra_file_config @@ -732,6 +734,9 @@ BEGIN; INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (4, '数据库', 1, '我是数据库', b'0', '{\"@class\":\"cn.iocoder.yudao.framework.file.core.client.db.DBFileClientConfig\",\"domain\":\"http://127.0.0.1:48080\"}', '1', '2022-03-15 23:56:24', '1', '2022-03-26 21:39:26', b'0'); INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (5, '本地磁盘', 10, '测试下本地存储', b'0', '{\"@class\":\"cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig\",\"basePath\":\"/Users/yunai/file_test\",\"domain\":\"http://127.0.0.1:48080\"}', '1', '2022-03-15 23:57:00', '1', '2022-03-26 21:39:26', b'0'); INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (11, 'S3 - 七牛云', 20, NULL, b'1', '{\"@class\":\"cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"s3-cn-south-1.qiniucs.com\",\"domain\":\"http://test.yudao.iocoder.cn\",\"bucket\":\"ruoyi-vue-pro\",\"accessKey\":\"b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8\",\"accessSecret\":\"kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP\"}', '1', '2022-03-19 18:00:03', '1', '2022-03-26 21:39:26', b'0'); +INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (15, 'S3 - 七牛云', 20, '', b'0', '{\"@class\":\"cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"s3-cn-south-1.qiniucs.com\",\"domain\":\"http://test.yudao.iocoder.cn\",\"bucket\":\"ruoyi-vue-pro\",\"accessKey\":\"b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8\",\"accessSecret\":\"kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP\"}', '1', '2022-06-10 20:50:41', '1', '2022-06-10 20:50:41', b'0'); +INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (16, 'S3 - 七牛云', 20, '', b'0', '{\"@class\":\"cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"s3-cn-south-1.qiniucs.com\",\"domain\":\"http://test.yudao.iocoder.cn\",\"bucket\":\"ruoyi-vue-pro\",\"accessKey\":\"b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8\",\"accessSecret\":\"kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP\"}', '1', '2022-06-11 20:32:08', '1', '2022-06-11 20:32:08', b'0'); +INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (17, 'S3 - 七牛云', 20, '', b'0', '{\"@class\":\"cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"s3-cn-south-1.qiniucs.com\",\"domain\":\"http://test.yudao.iocoder.cn\",\"bucket\":\"ruoyi-vue-pro\",\"accessKey\":\"b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8\",\"accessSecret\":\"kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP\"}', '1', '2022-06-11 20:32:47', '1', '2022-06-11 20:32:47', b'0'); COMMIT; -- ---------------------------- @@ -862,7 +867,7 @@ CREATE TABLE `member_user` ( `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `uk_mobile`(`mobile` ASC) USING BTREE COMMENT '手机号' -) ENGINE = InnoDB AUTO_INCREMENT = 247 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户'; +) ENGINE = InnoDB AUTO_INCREMENT = 248 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户'; -- ---------------------------- -- Records of member_user @@ -1258,7 +1263,6 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (79, 2, '手动编辑', '2', 'system_error_code_type', 0, 'primary', '', NULL, '1', '2021-04-21 00:07:14', '1', '2022-02-16 13:57:24', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (80, 100, '账号登录', '100', 'system_login_type', 0, 'primary', '', '账号登录', '1', '2021-10-06 00:52:02', '1', '2022-02-16 13:11:34', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (81, 101, '社交登录', '101', 'system_login_type', 0, 'info', '', '社交登录', '1', '2021-10-06 00:52:17', '1', '2022-02-16 13:11:40', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (82, 102, 'Mock 登录', '102', 'system_login_type', 0, 'danger', '', 'Mock 登录', '1', '2021-10-06 00:52:32', '1', '2022-02-16 13:11:44', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (83, 200, '主动登出', '200', 'system_login_type', 0, 'primary', '', '主动登出', '1', '2021-10-06 00:52:58', '1', '2022-02-16 13:11:49', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (85, 202, '强制登出', '202', 'system_login_type', 0, 'danger', '', '强制退出', '1', '2021-10-06 00:53:41', '1', '2022-02-16 13:11:57', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (86, 0, '病假', '1', 'bpm_oa_leave_type', 0, 'primary', '', NULL, '1', '2021-09-21 22:35:28', '1', '2022-02-16 10:00:41', b'0'); @@ -1411,7 +1415,7 @@ CREATE TABLE `system_error_code` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 5829 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '错误码表'; +) ENGINE = InnoDB AUTO_INCREMENT = 5832 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '错误码表'; -- ---------------------------- -- Records of system_error_code @@ -1440,7 +1444,7 @@ CREATE TABLE `system_login_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1416 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 1489 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录'; -- ---------------------------- -- Records of system_login_log @@ -1757,7 +1761,7 @@ CREATE TABLE `system_oauth2_access_token` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 172 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌'; +) ENGINE = InnoDB AUTO_INCREMENT = 231 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌'; -- ---------------------------- -- Records of system_oauth2_access_token @@ -1877,7 +1881,7 @@ CREATE TABLE `system_oauth2_refresh_token` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '刷新令牌'; +) ENGINE = InnoDB AUTO_INCREMENT = 165 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '刷新令牌'; -- ---------------------------- -- Records of system_oauth2_refresh_token @@ -1917,7 +1921,7 @@ CREATE TABLE `system_operate_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2214 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 2432 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录'; -- ---------------------------- -- Records of system_operate_log @@ -1983,7 +1987,7 @@ CREATE TABLE `system_role` ( BEGIN; INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '超级管理员', 'super_admin', 1, 1, '', 0, 1, '超级管理员', 'admin', '2021-01-05 17:03:48', '', '2022-02-22 05:08:21', b'0', 1); INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, '普通角色', 'common', 2, 2, '', 0, 1, '普通角色', 'admin', '2021-01-05 17:03:48', '', '2022-02-22 05:08:20', b'0', 1); -INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (101, '测试账号', 'test', 0, 1, '[]', 0, 2, '132', '', '2021-01-06 13:49:35', '1', '2022-04-01 21:37:13', b'0', 1); +INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (101, '测试账号', 'test', 0, 1, '[]', 0, 2, '132', '', '2021-01-06 13:49:35', '1', '2022-05-28 16:11:05', b'0', 1); INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (109, '租户管理员', 'tenant_admin', 0, 1, '', 0, 1, '系统自动生成', '1', '2022-02-22 00:56:14', '1', '2022-02-22 00:56:14', b'0', 121); INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (110, '测试角色', 'test', 0, 1, '[]', 0, 2, '嘿嘿', '110', '2022-02-23 00:14:34', '110', '2022-02-23 13:14:58', b'0', 121); INSERT INTO `system_role` (`id`, `name`, `code`, `sort`, `data_scope`, `data_scope_dept_ids`, `status`, `type`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (111, '租户管理员', 'tenant_admin', 0, 1, '', 0, 1, '系统自动生成', '1', '2022-03-07 21:37:58', '1', '2022-03-07 21:37:58', b'0', 122); @@ -2253,7 +2257,7 @@ COMMIT; DROP TABLE IF EXISTS `system_sms_channel`; CREATE TABLE `system_sms_channel` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', - `signature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '短信签名', + `signature` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '短信签名', `code` varchar(63) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '渠道编码', `status` tinyint NOT NULL COMMENT '开启状态', `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', @@ -2300,7 +2304,7 @@ CREATE TABLE `system_sms_code` ( `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE, INDEX `idx_mobile`(`mobile` ASC) USING BTREE COMMENT '手机号' -) ENGINE = InnoDB AUTO_INCREMENT = 468 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '手机验证码'; +) ENGINE = InnoDB AUTO_INCREMENT = 469 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '手机验证码'; -- ---------------------------- -- Records of system_sms_code @@ -2343,7 +2347,7 @@ CREATE TABLE `system_sms_log` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 144 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信日志'; +) ENGINE = InnoDB AUTO_INCREMENT = 242 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信日志'; -- ---------------------------- -- Records of system_sms_log @@ -2413,7 +2417,7 @@ CREATE TABLE `system_social_user` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交用户表'; +) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交用户表'; -- ---------------------------- -- Records of system_social_user @@ -2438,7 +2442,7 @@ CREATE TABLE `system_social_user_bind` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交绑定表'; +) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交绑定表'; -- ---------------------------- -- Records of system_social_user_bind @@ -2545,7 +2549,7 @@ CREATE TABLE `system_user_role` ( `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户和角色关联表'; +) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户和角色关联表'; -- ---------------------------- -- Records of system_user_role @@ -2556,7 +2560,6 @@ INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_t INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 100, 101, '', '2022-01-11 13:19:45', '', '2022-05-12 12:35:13', b'0', 1); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, 100, 1, '', '2022-01-11 13:19:45', '', '2022-05-12 12:35:12', b'0', 1); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (6, 100, 2, '', '2022-01-11 13:19:45', '', '2022-05-12 12:35:11', b'0', 1); -INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 104, 101, '', '2022-01-11 13:19:45', '', '2022-05-12 12:35:11', b'0', 1); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (10, 103, 1, '1', '2022-01-11 13:19:45', '1', '2022-01-11 13:19:45', b'0', 1); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (11, 107, 106, '1', '2022-02-20 22:59:33', '1', '2022-02-20 22:59:33', b'0', 118); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (12, 108, 107, '1', '2022-02-20 23:00:50', '1', '2022-02-20 23:00:50', b'0', 119); @@ -2567,6 +2570,7 @@ INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_t INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (17, 114, 101, '1', '2022-03-19 21:51:13', '1', '2022-03-19 21:51:13', b'0', 1); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (18, 1, 2, '1', '2022-05-12 20:39:29', '1', '2022-05-12 20:39:29', b'0', 1); INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (19, 116, 113, '1', '2022-05-17 10:07:10', '1', '2022-05-17 10:07:10', b'0', 124); +INSERT INTO `system_user_role` (`id`, `user_id`, `role_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (20, 104, 101, '1', '2022-05-28 15:43:57', '1', '2022-05-28 15:43:57', b'0', 1); COMMIT; -- ---------------------------- @@ -2630,10 +2634,10 @@ CREATE TABLE `system_users` ( -- Records of system_users -- ---------------------------- BEGIN; -INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$0acJOIk2D25/oC87nyclE..0lzeu9DtQ/n3geP4fkun/zIVRhHJIO', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://test.yudao.iocoder.cn/48934f2f-92d4-4250-b917-d10d2b262c6a', 0, '127.0.0.1', '2022-05-23 20:27:29', 'admin', '2021-01-05 17:03:47', NULL, '2022-05-23 20:27:29', b'0', 1); +INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$0acJOIk2D25/oC87nyclE..0lzeu9DtQ/n3geP4fkun/zIVRhHJIO', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://test.yudao.iocoder.cn/48934f2f-92d4-4250-b917-d10d2b262c6a', 0, '127.0.0.1', '2022-06-15 08:03:23', 'admin', '2021-01-05 17:03:47', NULL, '2022-06-15 08:03:23', b'0', 1); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-05-22 19:35:33', '', '2021-01-07 09:07:17', NULL, '2022-05-22 19:35:33', b'0', 1); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$wWoPT7sqriM2O1YXRL.je.GiL538OR6ZTN8aQZr9JAGdnpCH2tpYe', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-01-18 00:33:40', '', '2021-01-13 23:50:35', NULL, '2022-01-18 00:33:40', b'0', 1); -INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$e5RpuDCC0GYSt0Hvd2.CjujIXwgGct4SnXi6dVGxdgFsnqgEryk5a', '测试号', NULL, 107, '[1]', '111@qq.com', '15601691200', 1, '', 0, '127.0.0.1', '2022-03-19 21:46:19', '', '2021-01-21 02:13:53', '1', '2022-05-16 19:36:28', b'0', 1); +INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1]', '111@qq.com', '15601691200', 1, '', 0, '127.0.0.1', '2022-05-28 15:43:17', '', '2021-01-21 02:13:53', NULL, '2022-05-28 15:43:17', b'0', 1); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (107, 'admin107', '$2a$10$dYOOBKMO93v/.ReCqzyFg.o67Tqk.bbc2bhrpyBGkIw9aypCtr2pm', '芋艿', NULL, NULL, NULL, '', '15601691300', 0, '', 0, '', NULL, '1', '2022-02-20 22:59:33', '1', '2022-02-27 08:26:51', b'0', 118); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (108, 'admin108', '$2a$10$y6mfvKoNYL1GXWak8nYwVOH.kCWqjactkzdoIDgiKl93WN3Ejg.Lu', '芋艿', NULL, NULL, NULL, '', '15601691300', 0, '', 0, '', NULL, '1', '2022-02-20 23:00:50', '1', '2022-02-27 08:26:53', b'0', 119); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (109, 'admin109', '$2a$10$JAqvH0tEc0I7dfDVBI7zyuB4E3j.uH6daIjV53.vUS6PknFkDJkuK', '芋艿', NULL, NULL, NULL, '', '15601691300', 0, '', 0, '', NULL, '1', '2022-02-20 23:11:50', '1', '2022-02-27 08:26:56', b'0', 120); diff --git a/sql/oracle/ruoyi-vue-pro.sql b/sql/oracle/ruoyi-vue-pro.sql index 2137292ef..1f4908645 100644 --- a/sql/oracle/ruoyi-vue-pro.sql +++ b/sql/oracle/ruoyi-vue-pro.sql @@ -11,7 +11,7 @@ Target Server Version : 110200 File Encoding : 65001 - Date: 26/05/2022 00:38:28 + Date: 15/06/2022 08:20:08 */ @@ -884,7 +884,8 @@ CREATE TABLE "INFRA_FILE" ( "CREATE_TIME" DATE NOT NULL, "UPDATER" NVARCHAR2(64), "UPDATE_TIME" DATE NOT NULL, - "DELETED" NUMBER(1,0) DEFAULT 0 + "DELETED" NUMBER(1,0) DEFAULT 0, + "NAME" NVARCHAR2(512) ) LOGGING NOCOMPRESS @@ -913,6 +914,7 @@ COMMENT ON COLUMN "INFRA_FILE"."CREATOR" IS '创建者'; COMMENT ON COLUMN "INFRA_FILE"."CREATE_TIME" IS '创建时间'; COMMENT ON COLUMN "INFRA_FILE"."UPDATER" IS '更新者'; COMMENT ON COLUMN "INFRA_FILE"."UPDATE_TIME" IS '更新时间'; +COMMENT ON COLUMN "INFRA_FILE"."NAME" IS '文件名'; COMMENT ON TABLE "INFRA_FILE" IS '文件表'; -- ---------------------------- @@ -3196,7 +3198,7 @@ COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."STATUS" IS '状态'; COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."ACCESS_TOKEN_VALIDITY_SECONDS" IS '访问令牌的有效期'; COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."REFRESH_TOKEN_VALIDITY_SECONDS" IS '刷新令牌的有效期'; COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."REDIRECT_URIS" IS '可重定向的 URI 地址'; -COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."AUTO_APPROVE_SCOPES" IS '是否自动授权'; +COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."AUTO_APPROVE_SCOPES" IS '自动通过的授权范围'; COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."AUTHORIZED_GRANT_TYPES" IS '授权类型'; COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."SCOPES" IS '授权范围'; COMMENT ON COLUMN "SYSTEM_OAUTH2_CLIENT"."AUTHORITIES" IS '权限'; @@ -3795,7 +3797,7 @@ COMMIT; DROP TABLE "SYSTEM_SMS_CHANNEL"; CREATE TABLE "SYSTEM_SMS_CHANNEL" ( "ID" NUMBER(20,0) NOT NULL, - "SIGNATURE" NVARCHAR2(10), + "SIGNATURE" NVARCHAR2(12), "CODE" NVARCHAR2(63), "STATUS" NUMBER(4,0) NOT NULL, "REMARK" NVARCHAR2(255), @@ -5393,10 +5395,8 @@ ALTER TABLE "QRTZ_FIRED_TRIGGERS" ADD CONSTRAINT "SYS_C008671" CHECK ("STATE" IS -- Indexes structure for table QRTZ_FIRED_TRIGGERS -- ---------------------------- CREATE INDEX "IDX_QRTZ_FT_INST_JOB_REQ_RCVRY" - ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "INSTANCE_NAME" ASC, "REQUESTS_RECOVERY" ASC) LOCAL + ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "INSTANCE_NAME" ASC, "REQUESTS_RECOVERY" ASC) LOGGING - ONLINE - NOSORT VISIBLE PCTFREE 10 INITRANS 2 @@ -5410,7 +5410,7 @@ STORAGE ( BUFFER_POOL DEFAULT ); CREATE INDEX "IDX_QRTZ_FT_JG" - ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "JOB_GROUP" ASC) LOCAL + ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "JOB_GROUP" ASC) LOGGING ONLINE NOSORT @@ -5427,10 +5427,8 @@ STORAGE ( BUFFER_POOL DEFAULT ); CREATE INDEX "IDX_QRTZ_FT_J_G" - ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "JOB_NAME" ASC, "JOB_GROUP" ASC) LOCAL + ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "JOB_NAME" ASC, "JOB_GROUP" ASC) LOGGING - ONLINE - NOSORT VISIBLE PCTFREE 10 INITRANS 2 @@ -5446,7 +5444,6 @@ STORAGE ( CREATE INDEX "IDX_QRTZ_FT_TG" ON "QRTZ_FIRED_TRIGGERS" ("SCHED_NAME" ASC, "TRIGGER_GROUP" ASC) LOCAL LOGGING - ONLINE NOSORT VISIBLE PCTFREE 10 @@ -5499,8 +5496,6 @@ STORAGE ( CREATE INDEX "IDX_QRTZ_J_REQ_RECOVERY" ON "QRTZ_JOB_DETAILS" ("SCHED_NAME" ASC, "REQUESTS_RECOVERY" ASC) LOCAL LOGGING - ONLINE - NOSORT VISIBLE PCTFREE 10 INITRANS 2 @@ -5622,8 +5617,10 @@ ALTER TABLE "QRTZ_TRIGGERS" ADD CONSTRAINT "SYS_C008696" CHECK ("START_TIME" IS -- Indexes structure for table QRTZ_TRIGGERS -- ---------------------------- CREATE INDEX "IDX_QRTZ_T_C" - ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "CALENDAR_NAME" ASC) + ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "CALENDAR_NAME" ASC) LOCAL LOGGING + ONLINE + NOSORT VISIBLE PCTFREE 10 INITRANS 2 @@ -5637,10 +5634,8 @@ STORAGE ( BUFFER_POOL DEFAULT ); CREATE INDEX "IDX_QRTZ_T_J" - ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "JOB_NAME" ASC, "JOB_GROUP" ASC) LOCAL + ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "JOB_NAME" ASC, "JOB_GROUP" ASC) LOGGING - ONLINE - NOSORT VISIBLE PCTFREE 10 INITRANS 2 @@ -5654,8 +5649,10 @@ STORAGE ( BUFFER_POOL DEFAULT ); CREATE INDEX "IDX_QRTZ_T_JG" - ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "JOB_GROUP" ASC) + ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "JOB_GROUP" ASC) LOCAL LOGGING + ONLINE + NOSORT VISIBLE PCTFREE 10 INITRANS 2 @@ -5669,10 +5666,8 @@ STORAGE ( BUFFER_POOL DEFAULT ); CREATE INDEX "IDX_QRTZ_T_NEXT_FIRE_TIME" - ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "NEXT_FIRE_TIME" ASC) LOCAL + ON "QRTZ_TRIGGERS" ("SCHED_NAME" ASC, "NEXT_FIRE_TIME" ASC) LOGGING - ONLINE - NOSORT VISIBLE PCTFREE 10 INITRANS 2 diff --git a/sql/postgresql/ruoyi-vue-pro.sql b/sql/postgresql/ruoyi-vue-pro.sql index 719ae312a..9e80ce70d 100644 --- a/sql/postgresql/ruoyi-vue-pro.sql +++ b/sql/postgresql/ruoyi-vue-pro.sql @@ -12,7 +12,7 @@ Target Server Version : 140002 File Encoding : 65001 - Date: 26/05/2022 00:10:12 + Date: 15/06/2022 08:13:44 */ @@ -364,17 +364,6 @@ MAXVALUE 9223372036854775807 START 1 CACHE 1; --- ---------------------------- --- Sequence structure for system_oauth2_approve_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "system_oauth2_approve_seq"; -CREATE SEQUENCE "system_oauth2_approve_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - -- ---------------------------- -- Sequence structure for system_oauth2_client_seq -- ---------------------------- @@ -386,17 +375,6 @@ MAXVALUE 9223372036854775807 START 1 CACHE 1; --- ---------------------------- --- Sequence structure for system_oauth2_code_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "system_oauth2_code_seq"; -CREATE SEQUENCE "system_oauth2_code_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - -- ---------------------------- -- Sequence structure for system_oauth2_refresh_token_seq -- ---------------------------- @@ -1745,7 +1723,8 @@ CREATE TABLE "infra_file" ( "create_time" timestamp(6) NOT NULL, "updater" varchar(64) COLLATE "pg_catalog"."default", "update_time" timestamp(6) NOT NULL, - "deleted" int2 NOT NULL DEFAULT 0 + "deleted" int2 NOT NULL DEFAULT 0, + "name" varchar(255) COLLATE "pg_catalog"."default" ) ; COMMENT ON COLUMN "infra_file"."id" IS '文件编号'; @@ -1759,6 +1738,7 @@ COMMENT ON COLUMN "infra_file"."create_time" IS '创建时间'; COMMENT ON COLUMN "infra_file"."updater" IS '更新者'; COMMENT ON COLUMN "infra_file"."update_time" IS '更新时间'; COMMENT ON COLUMN "infra_file"."deleted" IS '是否删除'; +COMMENT ON COLUMN "infra_file"."name" IS '文件名'; COMMENT ON TABLE "infra_file" IS '文件表'; -- ---------------------------- @@ -3412,47 +3392,6 @@ COMMENT ON TABLE "system_oauth2_access_token" IS '刷新令牌'; BEGIN; COMMIT; --- ---------------------------- --- Table structure for system_oauth2_approve --- ---------------------------- -DROP TABLE IF EXISTS "system_oauth2_approve"; -CREATE TABLE "system_oauth2_approve" ( - "id" int8 NOT NULL, - "user_id" int8 NOT NULL, - "user_type" int2 NOT NULL, - "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, - "scope" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, - "approved" bool NOT NULL, - "expires_time" timestamp(6) NOT NULL, - "creator" varchar(64) COLLATE "pg_catalog"."default", - "create_time" timestamp(6) NOT NULL, - "updater" varchar(64) COLLATE "pg_catalog"."default", - "update_time" timestamp(6) NOT NULL, - "deleted" int2 NOT NULL DEFAULT 0, - "tenant_id" int8 NOT NULL -) -; -COMMENT ON COLUMN "system_oauth2_approve"."id" IS '编号'; -COMMENT ON COLUMN "system_oauth2_approve"."user_id" IS '用户编号'; -COMMENT ON COLUMN "system_oauth2_approve"."user_type" IS '用户类型'; -COMMENT ON COLUMN "system_oauth2_approve"."client_id" IS '客户端编号'; -COMMENT ON COLUMN "system_oauth2_approve"."scope" IS '授权范围'; -COMMENT ON COLUMN "system_oauth2_approve"."approved" IS '是否接受'; -COMMENT ON COLUMN "system_oauth2_approve"."expires_time" IS '过期时间'; -COMMENT ON COLUMN "system_oauth2_approve"."creator" IS '创建者'; -COMMENT ON COLUMN "system_oauth2_approve"."create_time" IS '创建时间'; -COMMENT ON COLUMN "system_oauth2_approve"."updater" IS '更新者'; -COMMENT ON COLUMN "system_oauth2_approve"."update_time" IS '更新时间'; -COMMENT ON COLUMN "system_oauth2_approve"."deleted" IS '是否删除'; -COMMENT ON COLUMN "system_oauth2_approve"."tenant_id" IS '租户编号'; -COMMENT ON TABLE "system_oauth2_approve" IS 'OAuth2 批准表'; - --- ---------------------------- --- Records of system_oauth2_approve --- ---------------------------- -BEGIN; -COMMIT; - -- ---------------------------- -- Table structure for system_oauth2_client -- ---------------------------- @@ -3512,51 +3451,6 @@ INSERT INTO "system_oauth2_client" ("id", "client_id", "secret", "name", "logo", INSERT INTO "system_oauth2_client" ("id", "client_id", "secret", "name", "logo", "description", "status", "access_token_validity_seconds", "refresh_token_validity_seconds", "redirect_uris", "authorized_grant_types", "scopes", "authorities", "resource_ids", "additional_information", "creator", "create_time", "updater", "update_time", "deleted", "auto_approve_scopes") VALUES (40, 'test', 'test2', 'biubiu', 'http://test.yudao.iocoder.cn/277a899d573723f1fcdfb57340f00379.png', NULL, 0, 1800, 43200, '["https://www.iocoder.cn"]', '["password","authorization_code","implicit"]', '[]', '[]', '[]', '{}', '1', '2022-05-12 00:28:20', '1', '2022-05-25 23:45:33.005', 0, '[]'); COMMIT; --- ---------------------------- --- Table structure for system_oauth2_code --- ---------------------------- -DROP TABLE IF EXISTS "system_oauth2_code"; -CREATE TABLE "system_oauth2_code" ( - "id" int8 NOT NULL, - "user_id" int8 NOT NULL, - "user_type" int2 NOT NULL, - "code" varchar(32) COLLATE "pg_catalog"."default" NOT NULL, - "client_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, - "scopes" varchar(255) COLLATE "pg_catalog"."default", - "expires_time" timestamp(6) NOT NULL, - "redirect_uri" varchar(255) COLLATE "pg_catalog"."default", - "state" varchar(255) COLLATE "pg_catalog"."default", - "creator" varchar(64) COLLATE "pg_catalog"."default", - "create_time" timestamp(6) NOT NULL, - "updater" varchar(64) COLLATE "pg_catalog"."default", - "update_time" timestamp(6) NOT NULL, - "deleted" int2 NOT NULL DEFAULT 0, - "tenant_id" int8 NOT NULL -) -; -COMMENT ON COLUMN "system_oauth2_code"."id" IS '编号'; -COMMENT ON COLUMN "system_oauth2_code"."user_id" IS '用户编号'; -COMMENT ON COLUMN "system_oauth2_code"."user_type" IS '用户类型'; -COMMENT ON COLUMN "system_oauth2_code"."code" IS '授权码'; -COMMENT ON COLUMN "system_oauth2_code"."client_id" IS '客户端编号'; -COMMENT ON COLUMN "system_oauth2_code"."scopes" IS '授权范围'; -COMMENT ON COLUMN "system_oauth2_code"."expires_time" IS '过期时间'; -COMMENT ON COLUMN "system_oauth2_code"."redirect_uri" IS '可重定向的 URI 地址'; -COMMENT ON COLUMN "system_oauth2_code"."state" IS '状态'; -COMMENT ON COLUMN "system_oauth2_code"."creator" IS '创建者'; -COMMENT ON COLUMN "system_oauth2_code"."create_time" IS '创建时间'; -COMMENT ON COLUMN "system_oauth2_code"."updater" IS '更新者'; -COMMENT ON COLUMN "system_oauth2_code"."update_time" IS '更新时间'; -COMMENT ON COLUMN "system_oauth2_code"."deleted" IS '是否删除'; -COMMENT ON COLUMN "system_oauth2_code"."tenant_id" IS '租户编号'; -COMMENT ON TABLE "system_oauth2_code" IS 'OAuth2 授权码表'; - --- ---------------------------- --- Records of system_oauth2_code --- ---------------------------- -BEGIN; -COMMIT; - -- ---------------------------- -- Table structure for system_oauth2_refresh_token -- ---------------------------- @@ -4025,7 +3919,7 @@ COMMIT; DROP TABLE IF EXISTS "system_sms_channel"; CREATE TABLE "system_sms_channel" ( "id" int8 NOT NULL, - "signature" varchar(10) COLLATE "pg_catalog"."default" NOT NULL, + "signature" varchar(12) COLLATE "pg_catalog"."default" NOT NULL, "code" varchar(63) COLLATE "pg_catalog"."default" NOT NULL, "status" int2 NOT NULL, "remark" varchar(255) COLLATE "pg_catalog"."default", @@ -4726,21 +4620,11 @@ SELECT setval('"system_login_log_seq"', 23, true); -- ---------------------------- SELECT setval('"system_oauth2_access_token_seq"', 11, true); --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -SELECT setval('"system_oauth2_approve_seq"', 4, true); - -- ---------------------------- -- Alter sequences owned by -- ---------------------------- SELECT setval('"system_oauth2_client_seq"', 1, false); --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -SELECT setval('"system_oauth2_code_seq"', 4, true); - -- ---------------------------- -- Alter sequences owned by -- ---------------------------- @@ -5168,21 +5052,11 @@ ALTER TABLE "system_notice" ADD CONSTRAINT "system_notice_pkey" PRIMARY KEY ("id -- ---------------------------- ALTER TABLE "system_oauth2_access_token" ADD CONSTRAINT "system_oauth2_access_token_pkey" PRIMARY KEY ("id"); --- ---------------------------- --- Primary Key structure for table system_oauth2_approve --- ---------------------------- -ALTER TABLE "system_oauth2_approve" ADD CONSTRAINT "system_oauth2_approve_pkey" PRIMARY KEY ("id"); - -- ---------------------------- -- Primary Key structure for table system_oauth2_client -- ---------------------------- ALTER TABLE "system_oauth2_client" ADD CONSTRAINT "system_oauth2_client_pkey" PRIMARY KEY ("id"); --- ---------------------------- --- Primary Key structure for table system_oauth2_code --- ---------------------------- -ALTER TABLE "system_oauth2_code" ADD CONSTRAINT "system_oauth2_code_pkey" PRIMARY KEY ("id"); - -- ---------------------------- -- Primary Key structure for table system_oauth2_refresh_token -- ---------------------------- diff --git a/sql/sqlserver/ruoyi-vue-pro.sql b/sql/sqlserver/ruoyi-vue-pro.sql index 0b649b12c..d6bd1847c 100644 --- a/sql/sqlserver/ruoyi-vue-pro.sql +++ b/sql/sqlserver/ruoyi-vue-pro.sql @@ -12,7 +12,7 @@ Target Server Version : 15004198 File Encoding : 65001 - Date: 26/05/2022 01:01:02 + Date: 15/06/2022 08:15:45 */ @@ -2640,7 +2640,8 @@ CREATE TABLE [dbo].[infra_file] ( [create_time] datetime2(7) NOT NULL, [updater] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [update_time] datetime2(7) NOT NULL, - [deleted] bit DEFAULT 0 NOT NULL + [deleted] bit DEFAULT 0 NOT NULL, + [name] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) GO @@ -2724,6 +2725,13 @@ EXEC sp_addextendedproperty 'COLUMN', N'deleted' GO +EXEC sp_addextendedproperty +'MS_Description', N'文件路径', +'SCHEMA', N'dbo', +'TABLE', N'infra_file', +'COLUMN', N'name' +GO + EXEC sp_addextendedproperty 'MS_Description', N'文件表', 'SCHEMA', N'dbo', @@ -9490,7 +9498,7 @@ GO CREATE TABLE [dbo].[system_sms_channel] ( [id] bigint IDENTITY(1,1) NOT NULL, - [signature] nvarchar(10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, + [signature] nvarchar(12) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [code] nvarchar(63) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [status] tinyint NOT NULL, [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 37a2c8a1b..c5e0630be 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -16,31 +16,31 @@ 1.6.2-snapshot - 2.5.12 + 2.6.8 - 3.0.2 - 1.5.22 + 3.0.3 + 1.6.6 2.5 1.2.8 - 3.4.3.4 + 3.5.2 3.5.2 3.5.0 - 3.17.0 + 3.17.3 1.9.2 2.2.0 - 1.7.0 + 1.7.1 8.7.0 - 2.6.2 + 2.6.7 0.31.0 7.2.6.RELEASE 0.1.16 - 3.9.0 + 4.0.0 7.1.0.M6 6.7.0 @@ -52,6 +52,7 @@ 2.2.7 2.2 1.0.5 + 2.0.5 30.1.1-jre 5.1.0 2.12.2 @@ -78,6 +79,11 @@ + + cn.iocoder.boot + yudao-spring-boot-starter-banner + ${revision} + cn.iocoder.boot yudao-spring-boot-starter-biz-operatelog @@ -118,6 +124,11 @@ yudao-spring-boot-starter-biz-social ${revision} + + cn.iocoder.boot + yudao-spring-boot-starter-biz-error-code + ${revision} + @@ -475,6 +486,12 @@ ${velocity.version} + + com.alibaba + fastjson + ${fastjson.version} + + cn.smallbun.screw screw-core @@ -483,6 +500,10 @@ org.freemarker freemarker + + + com.alibaba + fastjson diff --git a/yudao-framework/pom.xml b/yudao-framework/pom.xml index 73bb614cd..ed8f6719f 100644 --- a/yudao-framework/pom.xml +++ b/yudao-framework/pom.xml @@ -11,6 +11,7 @@ pom yudao-common + yudao-spring-boot-starter-banner yudao-spring-boot-starter-mybatis yudao-spring-boot-starter-redis yudao-spring-boot-starter-web @@ -25,17 +26,19 @@ yudao-spring-boot-starter-excel yudao-spring-boot-starter-test - yudao-spring-boot-starter-extension yudao-spring-boot-starter-biz-operatelog yudao-spring-boot-starter-biz-dict yudao-spring-boot-starter-biz-sms - yudao-spring-boot-starter-activiti + yudao-spring-boot-starter-biz-pay yudao-spring-boot-starter-biz-weixin yudao-spring-boot-starter-biz-social yudao-spring-boot-starter-biz-tenant yudao-spring-boot-starter-biz-data-permission + yudao-spring-boot-starter-biz-error-code + + yudao-spring-boot-starter-activiti yudao-spring-boot-starter-flowable diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/WebFilterOrderEnum.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/WebFilterOrderEnum.java index 2e4d9ab95..54d4be9d9 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/WebFilterOrderEnum.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/WebFilterOrderEnum.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.framework.common.enums; /** * Web 过滤器顺序的枚举类,保证过滤器按照符合我们的预期 * - * 考虑到每个 starter 都需要用到该工具类,所以放到 common 模块下的 util 包下 + * 考虑到每个 starter 都需要用到该工具类,所以放到 common 模块下的 enums 包下 * * @author 芋道源码 */ diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/ServerException.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/ServerException.java new file mode 100644 index 000000000..fac56d5e2 --- /dev/null +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/ServerException.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.framework.common.exception; + +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 服务器异常 Exception + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class ServerException extends RuntimeException { + + /** + * 全局错误码 + * + * @see GlobalErrorCodeConstants + */ + private Integer code; + /** + * 错误提示 + */ + private String message; + + /** + * 空构造方法,避免反序列化问题 + */ + public ServerException() { + } + + public ServerException(ErrorCode errorCode) { + this.code = errorCode.getCode(); + this.message = errorCode.getMsg(); + } + + public ServerException(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public ServerException setCode(Integer code) { + this.code = code; + return this; + } + + @Override + public String getMessage() { + return message; + } + + public ServerException setMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java index 69b97e5ae..a132e63d7 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java @@ -36,9 +36,15 @@ public interface GlobalErrorCodeConstants { ErrorCode UNKNOWN = new ErrorCode(999, "未知错误"); - static boolean isMatch(Integer code) { + /** + * 是否为服务端错误,参考 HTTP 5XX 错误码段 + * + * @param code 错误码 + * @return 是否 + */ + static boolean isServerErrorCode(Integer code) { return code != null - && code >= SUCCESS.getCode() && code <= UNKNOWN.getCode(); + && code >= INTERNAL_SERVER_ERROR.getCode() && code <= INTERNAL_SERVER_ERROR.getCode() + 99; } } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java index 0b66179ad..e3cfc453f 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java @@ -29,6 +29,10 @@ package cn.iocoder.yudao.framework.common.exception.enums; */ public class ServiceErrorCodeRange { - // 模块 system 错误码区间 [1-000-001-000 ~ 1-000-002-000] + // 模块 infra 错误码区间 [1-001-000-000 ~ 1-002-000-000) + // 模块 system 错误码区间 [1-002-000-000 ~ 1-003-000-000) + // 模块 member 错误码区间 [1-004-000-000 ~ 1-005-000-000) + // 模块 pay 错误码区间 [1-007-000-000 ~ 1-008-000-000) + // 模块 bpm 错误码区间 [1-009-000-000 ~ 1-010-000-000) } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java index eb6124b8b..cb82d301a 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.framework.common.pojo; import cn.iocoder.yudao.framework.common.exception.ErrorCode; +import cn.iocoder.yudao.framework.common.exception.ServerException; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -91,10 +92,24 @@ public class CommonResult implements Serializable { if (isSuccess()) { return; } + // 服务端异常 + if (GlobalErrorCodeConstants.isServerErrorCode(code)) { + throw new ServerException(code, msg); + } // 业务异常 throw new ServiceException(code, msg); } + /** + * 判断是否有异常。如果有,则抛出 {@link ServiceException} 异常 + * 如果没有,则返回 {@link #data} 数据 + */ + @JsonIgnore // 避免 jackson 序列化 + public T getCheckedData() { + checkError(); + return data; + } + public static CommonResult error(ServiceException serviceException) { return error(serviceException.getCode(), serviceException.getMessage()); } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java index 6a4c28e72..80029703b 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java @@ -23,8 +23,8 @@ public class PageParam implements Serializable { @ApiModelProperty(value = "每页条数,最大值为 100", required = true, example = "10") @NotNull(message = "每页条数不能为空") - @Min(value = 1, message = "页码最小值为 1") - @Max(value = 100, message = "页码最大值为 100") + @Min(value = 1, message = "每页条数最小值为 1") + @Max(value = 100, message = "每页条数最大值为 100") private Integer pageSize = PAGE_SIZE; } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/cache/CacheUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/cache/CacheUtils.java new file mode 100644 index 000000000..7f7318487 --- /dev/null +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/cache/CacheUtils.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.framework.common.util.cache; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; + +import java.time.Duration; +import java.util.concurrent.Executors; + +/** + * Cache 工具类 + * + * @author 芋道源码 + */ +public class CacheUtils { + + public static LoadingCache buildAsyncReloadingCache(Duration duration, CacheLoader loader) { + return CacheBuilder.newBuilder() + // 只阻塞当前数据加载线程,其他线程返回旧值 + .refreshAfterWrite(duration) + // 通过 asyncReloading 实现全异步加载,包括 refreshAfterWrite 被阻塞的加载线程 + .build(CacheLoader.asyncReloading(loader, Executors.newCachedThreadPool())); // TODO 芋艿:可能要思考下,未来要不要做成可配置 + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-banner/pom.xml b/yudao-framework/yudao-spring-boot-starter-banner/pom.xml new file mode 100644 index 000000000..e740fce5f --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-banner/pom.xml @@ -0,0 +1,30 @@ + + + + yudao-framework + cn.iocoder.boot + ${revision} + + 4.0.0 + yudao-spring-boot-starter-banner + jar + + ${project.artifactId} + Banner 用于在 console 控制台,打印开发文档、接口文档等 + https://github.com/YunaiV/ruoyi-vue-pro + + + + cn.iocoder.boot + yudao-common + + + + org.springframework.boot + spring-boot-starter + + + + diff --git a/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/config/YudaoBannerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/config/YudaoBannerAutoConfiguration.java new file mode 100644 index 000000000..2ae83f3f8 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/config/YudaoBannerAutoConfiguration.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.framework.banner.config; + +import cn.iocoder.yudao.framework.banner.core.BannerApplicationRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Banner 的自动配置类 + * + * @author 芋道源码 + */ +@Configuration +public class YudaoBannerAutoConfiguration { + + @Bean + public BannerApplicationRunner bannerApplicationRunner() { + return new BannerApplicationRunner(); + } + +} diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/tip/core/TipApplicationRunner.java b/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/core/BannerApplicationRunner.java similarity index 87% rename from yudao-server/src/main/java/cn/iocoder/yudao/server/framework/tip/core/TipApplicationRunner.java rename to yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/core/BannerApplicationRunner.java index db71c5079..27e2f70eb 100644 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/tip/core/TipApplicationRunner.java +++ b/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/core/BannerApplicationRunner.java @@ -1,19 +1,19 @@ -package cn.iocoder.yudao.server.framework.tip.core; +package cn.iocoder.yudao.framework.banner.core; import cn.hutool.core.thread.ThreadUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; -import org.springframework.stereotype.Component; import java.util.concurrent.TimeUnit; /** * 项目启动成功后,提供文档相关的地址 + * + * @author 芋道源码 */ -@Component @Slf4j -public class TipApplicationRunner implements ApplicationRunner { +public class BannerApplicationRunner implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { diff --git a/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/package-info.java b/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/package-info.java new file mode 100644 index 000000000..aba726853 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/package-info.java @@ -0,0 +1,6 @@ +/** + * Banner 用于在 console 控制台,打印开发文档、接口文档等 + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.framework.banner; diff --git a/yudao-framework/yudao-spring-boot-starter-banner/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-banner/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..416b89477 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-banner/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + cn.iocoder.yudao.framework.banner.config.YudaoBannerAutoConfiguration diff --git a/yudao-server/src/main/resources/banner.txt b/yudao-framework/yudao-spring-boot-starter-banner/src/main/resources/banner.txt similarity index 100% rename from yudao-server/src/main/resources/banner.txt rename to yudao-framework/yudao-spring-boot-starter-banner/src/main/resources/banner.txt diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDataPermissionAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDataPermissionAutoConfiguration.java index 609e8a34b..62534ed63 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDataPermissionAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDataPermissionAutoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import java.util.List; /** - * 数据全新啊的自动配置类 + * 数据权限的自动配置类 * * @author 芋道源码 */ diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java index 36bf5c076..4c1494aca 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java @@ -62,7 +62,7 @@ public class DataPermissionDatabaseInterceptorTest extends BaseMockitoUnitTest { // 调用 interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); // 断言 - pluginUtilsMock.verify(never(), () -> PluginUtils.mpBoundSql(boundSql)); + pluginUtilsMock.verify(() -> PluginUtils.mpBoundSql(boundSql), never()); } } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml index d2299efff..26e057d28 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml @@ -26,5 +26,18 @@ org.springframework.boot spring-boot-starter + + + + cn.iocoder.boot + yudao-module-system-api + ${revision} + + + + + com.google.guava + guava + diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java index 1828585c0..01f7aba78 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.framework.dict.config; -import cn.iocoder.yudao.framework.dict.core.service.DictDataFrameworkService; import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -10,8 +10,8 @@ public class YudaoDictAutoConfiguration { @Bean @SuppressWarnings("InstantiationOfUtilityClass") - public DictFrameworkUtils dictUtils(DictDataFrameworkService service) { - DictFrameworkUtils.init(service); + public DictFrameworkUtils dictUtils(DictDataApi dictDataApi) { + DictFrameworkUtils.init(dictDataApi); return new DictFrameworkUtils(); } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/package-info.java new file mode 100644 index 000000000..7ba720a9d --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.framework.dict.core; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/service/DictDataFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/service/DictDataFrameworkService.java deleted file mode 100644 index 6ff51c33e..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/service/DictDataFrameworkService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.framework.dict.core.service; - -import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO; - -import java.util.List; - -public interface DictDataFrameworkService { - - /** - * 获得指定的字典数据,从缓存中 - * - * @param type 字典类型 - * @param value 字典数据值 - * @return 字典数据 - */ - DictDataRespDTO getDictDataFromCache(String type, String value); - - /** - * 解析获得指定的字典数据,从缓存中 - * - * @param type 字典类型 - * @param label 字典数据标签 - * @return 字典数据 - */ - DictDataRespDTO parseDictDataFromCache(String type, String label); - - /** - * 获得指定类型的字典数据,从缓存中 - * - * @param type 字典类型 - * @return 字典数据列表 - */ - List listDictDatasFromCache(String type); - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtils.java index 976f81c79..866dcb46d 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtils.java @@ -1,28 +1,70 @@ package cn.iocoder.yudao.framework.dict.core.util; -import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO; -import cn.iocoder.yudao.framework.dict.core.service.DictDataFrameworkService; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.core.KeyValue; +import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import java.time.Duration; + /** * 字典工具类 + * + * @author 芋道源码 */ @Slf4j public class DictFrameworkUtils { - private static DictDataFrameworkService service; + private static DictDataApi dictDataApi; - public static void init(DictDataFrameworkService service) { - DictFrameworkUtils.service = service; + private static final DictDataRespDTO DICT_DATA_NULL = new DictDataRespDTO(); + + /** + * 针对 {@link #getDictDataLabel(String, String)} 的缓存 + */ + private static final LoadingCache, DictDataRespDTO> getDictDataCache = CacheUtils.buildAsyncReloadingCache( + Duration.ofMinutes(1L), // 过期时间 1 分钟 + new CacheLoader, DictDataRespDTO>() { + + @Override + public DictDataRespDTO load(KeyValue key) { + return ObjectUtil.defaultIfNull(dictDataApi.getDictData(key.getKey(), key.getValue()), DICT_DATA_NULL); + } + + }); + + /** + * 针对 {@link #parseDictDataValue(String, String)} 的缓存 + */ + private static final LoadingCache, DictDataRespDTO> parseDictDataCache = CacheUtils.buildAsyncReloadingCache( + Duration.ofMinutes(1L), // 过期时间 1 分钟 + new CacheLoader, DictDataRespDTO>() { + + @Override + public DictDataRespDTO load(KeyValue key) { + return ObjectUtil.defaultIfNull(dictDataApi.parseDictData(key.getKey(), key.getValue()), DICT_DATA_NULL); + } + + }); + + public static void init(DictDataApi dictDataApi) { + DictFrameworkUtils.dictDataApi = dictDataApi; log.info("[init][初始化 DictFrameworkUtils 成功]"); } - public static DictDataRespDTO getDictDataFromCache(String type, String value) { - return service.getDictDataFromCache(type, value); + @SneakyThrows + public static String getDictDataLabel(String dictType, String value) { + return getDictDataCache.get(new KeyValue<>(dictType, value)).getLabel(); } - public static DictDataRespDTO parseDictDataFromCache(String type, String label) { - return service.parseDictDataFromCache(type, label); + @SneakyThrows + public static String parseDictDataValue(String dictType, String label) { + return parseDictDataCache.get(new KeyValue<>(dictType, label)).getValue(); } } diff --git a/yudao-framework/yudao-spring-boot-starter-extension/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml similarity index 50% rename from yudao-framework/yudao-spring-boot-starter-extension/pom.xml rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml index 3da9572c4..ff3c32d97 100644 --- a/yudao-framework/yudao-spring-boot-starter-extension/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml @@ -8,61 +8,42 @@ ${revision} 4.0.0 - - yudao-spring-boot-starter-extension + yudao-spring-boot-starter-biz-error-code jar ${project.artifactId} - 扩展点组件 + + 错误码 ErrorCode 的自动配置功能,提供如下功能: + 1. 远程读取:项目启动时,从 system-server 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提水可配置; + 2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-server 服务加载最新的 ErrorCode 错误码; + 3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑; + https://github.com/YunaiV/ruoyi-vue-pro - - - - cn.iocoder.boot yudao-common - - - org.springframework - spring-context - provided - - - - org.springframework - spring-beans - provided - - org.springframework.boot - spring-boot-starter-aop + spring-boot-starter - + - org.springframework.boot - spring-boot-starter-test - test + cn.iocoder.boot + yudao-module-system-api + ${revision} - - - junit - junit - test - - - jakarta.validation jakarta.validation-api + provided - \ No newline at end of file + + diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/config/ErrorCodeProperties.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/config/ErrorCodeProperties.java similarity index 81% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/config/ErrorCodeProperties.java rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/config/ErrorCodeProperties.java index 686f03e2c..1c1d1b8a5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/config/ErrorCodeProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/config/ErrorCodeProperties.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.config; +package cn.iocoder.yudao.framework.errorcode.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -17,6 +17,10 @@ import java.util.List; @Validated public class ErrorCodeProperties { + /** + * 是否开启 + */ + private Boolean enable = true; /** * 错误码枚举类 */ diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/config/ErrorCodeConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/config/YudaoErrorCodeConfiguration.java similarity index 54% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/config/ErrorCodeConfiguration.java rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/config/YudaoErrorCodeConfiguration.java index 4c72ccec7..e74be61ed 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/config/ErrorCodeConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/config/YudaoErrorCodeConfiguration.java @@ -1,37 +1,39 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.config; +package cn.iocoder.yudao.framework.errorcode.config; -import cn.iocoder.yudao.module.system.framework.errorcode.core.generator.ErrorCodeAutoGenerator; -import cn.iocoder.yudao.module.system.framework.errorcode.core.loader.ErrorCodeLoader; -import cn.iocoder.yudao.module.system.framework.errorcode.core.service.ErrorCodeFrameworkService; -import cn.iocoder.yudao.module.system.framework.errorcode.core.loader.ErrorCodeLoaderImpl; -import cn.iocoder.yudao.module.system.framework.errorcode.core.generator.ErrorCodeAutoGeneratorImpl; +import cn.iocoder.yudao.framework.errorcode.core.generator.ErrorCodeAutoGenerator; +import cn.iocoder.yudao.framework.errorcode.core.generator.ErrorCodeAutoGeneratorImpl; +import cn.iocoder.yudao.framework.errorcode.core.loader.ErrorCodeLoader; +import cn.iocoder.yudao.framework.errorcode.core.loader.ErrorCodeLoaderImpl; +import cn.iocoder.yudao.module.system.api.errorcode.ErrorCodeApi; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; -// TODO 芋艿:貌似放的位置有问题 /** * 错误码配置类 + * + * @author 芋道源码 */ @Configuration +@ConditionalOnProperty(prefix = "yudao.error-code", value = "enable", matchIfMissing = true) // 允许使用 yudao.error-code.enable=false 禁用访问日志 @EnableConfigurationProperties(ErrorCodeProperties.class) @EnableScheduling // 开启调度任务的功能,因为 ErrorCodeRemoteLoader 通过定时刷新错误码 -public class ErrorCodeConfiguration { +public class YudaoErrorCodeConfiguration { @Bean public ErrorCodeAutoGenerator errorCodeAutoGenerator(@Value("${spring.application.name}") String applicationName, ErrorCodeProperties errorCodeProperties, - ErrorCodeFrameworkService errorCodeFrameworkService) { - return new ErrorCodeAutoGeneratorImpl(applicationName, errorCodeProperties.getConstantsClassList(), - errorCodeFrameworkService); + ErrorCodeApi errorCodeApi) { + return new ErrorCodeAutoGeneratorImpl(applicationName, errorCodeProperties.getConstantsClassList(), errorCodeApi); } @Bean public ErrorCodeLoader errorCodeLoader(@Value("${spring.application.name}") String applicationName, - ErrorCodeFrameworkService errorCodeFrameworkService) { - return new ErrorCodeLoaderImpl(applicationName, errorCodeFrameworkService); + ErrorCodeApi errorCodeApi) { + return new ErrorCodeLoaderImpl(applicationName, errorCodeApi); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/generator/ErrorCodeAutoGenerator.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/generator/ErrorCodeAutoGenerator.java similarity index 71% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/generator/ErrorCodeAutoGenerator.java rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/generator/ErrorCodeAutoGenerator.java index 6fb2abc02..b13cacaa2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/generator/ErrorCodeAutoGenerator.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/generator/ErrorCodeAutoGenerator.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.generator; +package cn.iocoder.yudao.framework.errorcode.core.generator; /** * 错误码的自动生成器 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java similarity index 89% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java index db75aaa7c..a7f6c2835 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java @@ -1,12 +1,12 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.generator; +package cn.iocoder.yudao.framework.errorcode.core.generator; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.ClassUtil; import cn.hutool.core.util.ReflectUtil; import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.service.ErrorCodeFrameworkService; +import cn.iocoder.yudao.module.system.api.errorcode.ErrorCodeApi; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -36,9 +36,9 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator { */ private final List constantsClassList; /** - * 错误码 Service + * 错误码 Api */ - private final ErrorCodeFrameworkService errorCodeService; + private final ErrorCodeApi errorCodeApi; @Override @EventListener(ApplicationReadyEvent.class) @@ -49,7 +49,7 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator { log.info("[execute][解析到错误码数量为 ({}) 个]", autoGenerateDTOs.size()); // 第二步,写入到 system 服务 - errorCodeService.autoGenerateErrorCodes(autoGenerateDTOs); + errorCodeApi.autoGenerateErrorCodes(autoGenerateDTOs); log.info("[execute][写入到 system 组件完成]"); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/loader/ErrorCodeLoader.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/loader/ErrorCodeLoader.java similarity index 87% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/loader/ErrorCodeLoader.java rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/loader/ErrorCodeLoader.java index 6712c33e9..26fb060d2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/loader/ErrorCodeLoader.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/loader/ErrorCodeLoader.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.loader; +package cn.iocoder.yudao.framework.errorcode.core.loader; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java similarity index 81% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java rename to yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java index 1641f520f..5f327424a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java @@ -1,9 +1,9 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.loader; +package cn.iocoder.yudao.framework.errorcode.core.loader; import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeRespDTO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.service.ErrorCodeFrameworkService; import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.module.system.api.errorcode.ErrorCodeApi; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -34,9 +34,9 @@ public class ErrorCodeLoaderImpl implements ErrorCodeLoader { */ private final String applicationName; /** - * 错误码 Service + * 错误码 Api */ - private final ErrorCodeFrameworkService errorCodeService; + private final ErrorCodeApi errorCodeApi; /** * 缓存错误码的最大更新时间,用于后续的增量轮询,判断是否有更新 @@ -55,7 +55,7 @@ public class ErrorCodeLoaderImpl implements ErrorCodeLoader { private void loadErrorCodes0() { // 加载错误码 - List errorCodeRespDTOs = errorCodeService.getErrorCodeList(applicationName, maxUpdateTime); + List errorCodeRespDTOs = errorCodeApi.getErrorCodeList(applicationName, maxUpdateTime); if (CollUtil.isEmpty(errorCodeRespDTOs)) { return; } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/package-info.java new file mode 100644 index 000000000..ddba4f78a --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/java/cn/iocoder/yudao/framework/errorcode/package-info.java @@ -0,0 +1,10 @@ +/** + * 错误码 ErrorCode 的自动配置功能,提供如下功能: + * + * 1. 远程读取:项目启动时,从 system-service 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提水可配置; + * 2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-service 服务加载最新的 ErrorCode 错误码; + * 3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑; + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.framework.errorcode; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..ab9528c6e --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + cn.iocoder.yudao.framework.errorcode.config.YudaoErrorCodeConfiguration diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/pom.xml index a35c51365..01deef06f 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/pom.xml @@ -34,6 +34,13 @@ provided + + + cn.iocoder.boot + yudao-module-system-api + ${revision} + + com.google.guava diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogAutoConfiguration.java index c4e784bf0..bd78d2464 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogAutoConfiguration.java @@ -1,6 +1,9 @@ package cn.iocoder.yudao.framework.operatelog.config; import cn.iocoder.yudao.framework.operatelog.core.aop.OperateLogAspect; +import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkService; +import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkServiceImpl; +import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -12,4 +15,9 @@ public class YudaoOperateLogAutoConfiguration { return new OperateLogAspect(); } + @Bean + public OperateLogFrameworkService operateLogFrameworkService(OperateLogApi operateLogApi) { + return new OperateLogFrameworkServiceImpl(operateLogApi); + } + } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java index ee26efbb2..d3b94d25a 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java @@ -9,9 +9,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; +import cn.iocoder.yudao.framework.operatelog.core.service.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkService; import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import com.google.common.collect.Maps; @@ -45,7 +44,7 @@ import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeC * 满足如下任一条件,则会进行记录: * 1. 使用 @ApiOperation + 非 @GetMapping * 2. 使用 @OperateLog 注解 - * + *

* 但是,如果声明 @OperateLog 注解时,将 enable 属性设置为 false 时,强制不记录。 * * @author 芋道源码 @@ -57,13 +56,13 @@ public class OperateLogAspect { /** * 用于记录操作内容的上下文 * - * @see OperateLogCreateReqDTO#getContent() + * @see OperateLog#getContent() */ private static final ThreadLocal CONTENT = new ThreadLocal<>(); /** * 用于记录拓展字段的上下文 * - * @see OperateLogCreateReqDTO#getExts() + * @see OperateLog#getExts() */ private static final ThreadLocal> EXTS = new ThreadLocal<>(); @@ -73,16 +72,21 @@ public class OperateLogAspect { @Around("@annotation(apiOperation)") public Object around(ProceedingJoinPoint joinPoint, ApiOperation apiOperation) throws Throwable { // 可能也添加了 @ApiOperation 注解 - OperateLog operateLog = getMethodAnnotation(joinPoint, OperateLog.class); + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog = getMethodAnnotation(joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog.class); return around0(joinPoint, operateLog, apiOperation); } - @Around("!@annotation(io.swagger.annotations.ApiOperation) && @annotation(operateLog)") // 兼容处理,只添加 @OperateLog 注解的情况 - public Object around(ProceedingJoinPoint joinPoint, OperateLog operateLog) throws Throwable { + @Around("!@annotation(io.swagger.annotations.ApiOperation) && @annotation(operateLog)") + // 兼容处理,只添加 @OperateLog 注解的情况 + public Object around(ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog) throws Throwable { return around0(joinPoint, operateLog, null); } - private Object around0(ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation) throws Throwable { + private Object around0(ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog, + ApiOperation apiOperation) throws Throwable { // 目前,只有管理员,才记录操作日志!所以非管理员,直接调用,不进行记录 Integer userType = WebFrameworkUtils.getLoginUserType(); if (!Objects.equals(userType, UserTypeEnum.ADMIN.getValue())) { @@ -121,7 +125,9 @@ public class OperateLogAspect { EXTS.remove(); } - private void log(ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation, + private void log(ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog, + ApiOperation apiOperation, Date startTime, Object result, Throwable exception) { try { // 判断不记录的情况 @@ -136,113 +142,117 @@ public class OperateLogAspect { } } - private void log0(ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation, + private void log0(ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog, + ApiOperation apiOperation, Date startTime, Object result, Throwable exception) { - OperateLogCreateReqDTO operateLogDTO = new OperateLogCreateReqDTO(); + OperateLog operateLogObj = new OperateLog(); // 补全通用字段 - operateLogDTO.setTraceId(TracerUtils.getTraceId()); - operateLogDTO.setStartTime(startTime); + operateLogObj.setTraceId(TracerUtils.getTraceId()); + operateLogObj.setStartTime(startTime); // 补充用户信息 - fillUserFields(operateLogDTO); + fillUserFields(operateLogObj); // 补全模块信息 - fillModuleFields(operateLogDTO, joinPoint, operateLog, apiOperation); + fillModuleFields(operateLogObj, joinPoint, operateLog, apiOperation); // 补全请求信息 - fillRequestFields(operateLogDTO); + fillRequestFields(operateLogObj); // 补全方法信息 - fillMethodFields(operateLogDTO, joinPoint, operateLog, startTime, result, exception); + fillMethodFields(operateLogObj, joinPoint, operateLog, startTime, result, exception); // 异步记录日志 - operateLogFrameworkService.createOperateLogAsync(operateLogDTO); + operateLogFrameworkService.createOperateLog(operateLogObj); } - private static void fillUserFields(OperateLogCreateReqDTO operateLogDTO) { - operateLogDTO.setUserId(WebFrameworkUtils.getLoginUserId()); - operateLogDTO.setUserType(WebFrameworkUtils.getLoginUserType()); + private static void fillUserFields(OperateLog operateLogObj) { + operateLogObj.setUserId(WebFrameworkUtils.getLoginUserId()); + operateLogObj.setUserType(WebFrameworkUtils.getLoginUserType()); } - private static void fillModuleFields(OperateLogCreateReqDTO operateLogDTO, - ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation) { + private static void fillModuleFields(OperateLog operateLogObj, + ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog, + ApiOperation apiOperation) { // module 属性 if (operateLog != null) { - operateLogDTO.setModule(operateLog.module()); + operateLogObj.setModule(operateLog.module()); } - if (StrUtil.isEmpty(operateLogDTO.getModule())) { + if (StrUtil.isEmpty(operateLogObj.getModule())) { Api api = getClassAnnotation(joinPoint, Api.class); if (api != null) { // 优先读取 @API 的 name 属性 if (StrUtil.isNotEmpty(api.value())) { - operateLogDTO.setModule(api.value()); + operateLogObj.setModule(api.value()); } // 没有的话,读取 @API 的 tags 属性 - if (StrUtil.isEmpty(operateLogDTO.getModule()) && ArrayUtil.isNotEmpty(api.tags())) { - operateLogDTO.setModule(api.tags()[0]); + if (StrUtil.isEmpty(operateLogObj.getModule()) && ArrayUtil.isNotEmpty(api.tags())) { + operateLogObj.setModule(api.tags()[0]); } } } // name 属性 if (operateLog != null) { - operateLogDTO.setName(operateLog.name()); + operateLogObj.setName(operateLog.name()); } - if (StrUtil.isEmpty(operateLogDTO.getName()) && apiOperation != null) { - operateLogDTO.setName(apiOperation.value()); + if (StrUtil.isEmpty(operateLogObj.getName()) && apiOperation != null) { + operateLogObj.setName(apiOperation.value()); } // type 属性 if (operateLog != null && ArrayUtil.isNotEmpty(operateLog.type())) { - operateLogDTO.setType(operateLog.type()[0].getType()); + operateLogObj.setType(operateLog.type()[0].getType()); } - if (operateLogDTO.getType() == null) { + if (operateLogObj.getType() == null) { RequestMethod requestMethod = obtainFirstMatchRequestMethod(obtainRequestMethod(joinPoint)); OperateTypeEnum operateLogType = convertOperateLogType(requestMethod); - operateLogDTO.setType(operateLogType != null ? operateLogType.getType() : null); + operateLogObj.setType(operateLogType != null ? operateLogType.getType() : null); } // content 和 exts 属性 - operateLogDTO.setContent(CONTENT.get()); - operateLogDTO.setExts(EXTS.get()); + operateLogObj.setContent(CONTENT.get()); + operateLogObj.setExts(EXTS.get()); } - private static void fillRequestFields(OperateLogCreateReqDTO operateLogDTO) { + private static void fillRequestFields(OperateLog operateLogObj) { // 获得 Request 对象 HttpServletRequest request = ServletUtils.getRequest(); if (request == null) { return; } // 补全请求信息 - operateLogDTO.setRequestMethod(request.getMethod()); - operateLogDTO.setRequestUrl(request.getRequestURI()); - operateLogDTO.setUserIp(ServletUtil.getClientIP(request)); - operateLogDTO.setUserAgent(ServletUtils.getUserAgent(request)); + operateLogObj.setRequestMethod(request.getMethod()); + operateLogObj.setRequestUrl(request.getRequestURI()); + operateLogObj.setUserIp(ServletUtil.getClientIP(request)); + operateLogObj.setUserAgent(ServletUtils.getUserAgent(request)); } - private static void fillMethodFields(OperateLogCreateReqDTO operateLogDTO, - ProceedingJoinPoint joinPoint, OperateLog operateLog, + private static void fillMethodFields(OperateLog operateLogObj, + ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog, Date startTime, Object result, Throwable exception) { MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); - operateLogDTO.setJavaMethod(methodSignature.toString()); + operateLogObj.setJavaMethod(methodSignature.toString()); if (operateLog == null || operateLog.logArgs()) { - operateLogDTO.setJavaMethodArgs(obtainMethodArgs(joinPoint)); + operateLogObj.setJavaMethodArgs(obtainMethodArgs(joinPoint)); } if (operateLog == null || operateLog.logResultData()) { - operateLogDTO.setResultData(obtainResultData(result)); + operateLogObj.setResultData(obtainResultData(result)); } - operateLogDTO.setDuration((int) (System.currentTimeMillis() - startTime.getTime())); + operateLogObj.setDuration((int) (System.currentTimeMillis() - startTime.getTime())); // (正常)处理 resultCode 和 resultMsg 字段 - if (result != null) { - if (result instanceof CommonResult) { - CommonResult commonResult = (CommonResult) result; - operateLogDTO.setResultCode(commonResult.getCode()); - operateLogDTO.setResultMsg(commonResult.getMsg()); - } else { - operateLogDTO.setResultCode(SUCCESS.getCode()); - } + if (result instanceof CommonResult) { + CommonResult commonResult = (CommonResult) result; + operateLogObj.setResultCode(commonResult.getCode()); + operateLogObj.setResultMsg(commonResult.getMsg()); + } else { + operateLogObj.setResultCode(SUCCESS.getCode()); } // (异常)处理 resultCode 和 resultMsg 字段 if (exception != null) { - operateLogDTO.setResultCode(INTERNAL_SERVER_ERROR.getCode()); - operateLogDTO.setResultMsg(ExceptionUtil.getRootCauseMessage(exception)); + operateLogObj.setResultCode(INTERNAL_SERVER_ERROR.getCode()); + operateLogObj.setResultMsg(ExceptionUtil.getRootCauseMessage(exception)); } } - private static boolean isLogEnable(ProceedingJoinPoint joinPoint, OperateLog operateLog) { + private static boolean isLogEnable(ProceedingJoinPoint joinPoint, + cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog operateLog) { // 有 @OperateLog 注解的情况下 if (operateLog != null) { return operateLog.enable(); @@ -256,7 +266,7 @@ public class OperateLogAspect { return null; } return Arrays.stream(requestMethods).filter(requestMethod -> - requestMethod == RequestMethod.POST + requestMethod == RequestMethod.POST || requestMethod == RequestMethod.PUT || requestMethod == RequestMethod.DELETE) .findFirst().orElse(null); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/dto/OperateLogCreateReqDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/dto/OperateLogCreateReqDTO.java deleted file mode 100644 index d676001f2..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/dto/OperateLogCreateReqDTO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.framework.operatelog.core.dto; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Date; -import java.util.Map; - -/** - * 操作日志创建 Request DTO - */ -@Data -public class OperateLogCreateReqDTO { - - @ApiModelProperty(value = "链路追踪编号", required = true, example = "89aca178-a370-411c-ae02-3f0d672be4ab") - @NotEmpty(message = "链路追踪编号不能为空") - private String traceId; - - @ApiModelProperty(value = "用户编号", required = true, example = "1024") - @NotNull(message = "用户编号不能为空") - private Long userId; - @ApiModelProperty(value = "用户类型", required = true, example = "1") - @NotNull(message = "用户类型不能为空") - private Integer userType; - - @ApiModelProperty(value = "操作模块", required = true, example = "订单") - @NotEmpty(message = "操作模块不能为空") - private String module; - - @ApiModelProperty(value = "操作名", required = true, example = "创建订单") - @NotEmpty(message = "操作名") - private String name; - - @ApiModelProperty(value = "操作分类", required = true, example = "1", notes = "参见 SysOperateLogTypeEnum 枚举类") - @NotNull(message = "操作分类不能为空") - private Integer type; - - @ApiModelProperty(value = "操作明细", example = "修改编号为 1 的用户信息,将性别从男改成女,将姓名从芋道改成源码。") - private String content; - - @ApiModelProperty(value = "拓展字段", example = "{'orderId': 1}") - private Map exts; - - @ApiModelProperty(value = "请求方法名", required = true, example = "GET") - @NotEmpty(message = "请求方法名不能为空") - private String requestMethod; - - @ApiModelProperty(value = "请求地址", required = true, example = "/xxx/yyy") - @NotEmpty(message = "请求地址不能为空") - private String requestUrl; - - @ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1") - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - @ApiModelProperty(value = "浏览器 UserAgent", required = true, example = "Mozilla/5.0") - @NotEmpty(message = "浏览器 UserAgent 不能为空") - private String userAgent; - - @ApiModelProperty(value = "Java 方法名", required = true, example = "cn.iocoder.yudao.UserController.save(...)") - @NotEmpty(message = "Java 方法名不能为空") - private String javaMethod; - - @ApiModelProperty(value = "Java 方法的参数") - private String javaMethodArgs; - - @ApiModelProperty(value = "开始时间", required = true) - @NotNull(message = "开始时间不能为空") - private Date startTime; - - @ApiModelProperty(value = "执行时长,单位:毫秒", required = true) - @NotNull(message = "执行时长不能为空") - private Integer duration; - - @ApiModelProperty(value = "结果码", required = true) - @NotNull(message = "结果码不能为空") - private Integer resultCode; - - @ApiModelProperty(value = "结果提示") - private String resultMsg; - - @ApiModelProperty(value = "结果数据") - private String resultData; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLog.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLog.java new file mode 100644 index 000000000..7bce1c6bd --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLog.java @@ -0,0 +1,110 @@ +package cn.iocoder.yudao.framework.operatelog.core.service; + +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +/** + * 操作日志 + * + * @author 芋道源码 + */ +@Data +public class OperateLog { + + /** + * 链路追踪编号 + */ + private String traceId; + + /** + * 用户编号 + */ + private Long userId; + /** + * 用户类型 + */ + private Integer userType; + + /** + * 操作模块 + */ + private String module; + + /** + * 操作名 + */ + private String name; + + /** + * 操作分类 + */ + private Integer type; + + /** + * 操作明细 + */ + private String content; + + /** + * 拓展字段 + */ + private Map exts; + + /** + * 请求方法名 + */ + private String requestMethod; + + /** + * 请求地址 + */ + private String requestUrl; + + /** + * 用户 IP + */ + private String userIp; + + /** + * 浏览器 UserAgent + */ + private String userAgent; + + /** + * Java 方法名 + */ + private String javaMethod; + + /** + * Java 方法的参数 + */ + private String javaMethodArgs; + + /** + * 开始时间 + */ + private Date startTime; + + /** + * 执行时长,单位:毫秒 + */ + private Integer duration; + + /** + * 结果码 + */ + private Integer resultCode; + + /** + * 结果提示 + */ + private String resultMsg; + + /** + * 结果数据 + */ + private String resultData; + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java index ef20e2ece..235616244 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java @@ -1,17 +1,17 @@ package cn.iocoder.yudao.framework.operatelog.core.service; -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; - -import java.util.concurrent.Future; - +/** + * 操作日志 Framework Service 接口 + * + * @author 芋道源码 + */ public interface OperateLogFrameworkService { /** - * 异步记录操作日志 + * 记录操作日志 * - * @param reqVO 操作日志请求 - * @return true: 记录成功,false: 记录失败 + * @param operateLog 操作日志请求 */ - Future createOperateLogAsync(OperateLogCreateReqDTO reqVO); + void createOperateLog(OperateLog operateLog); } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java new file mode 100644 index 000000000..a636c4bdf --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.framework.operatelog.core.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Async; + +/** + * 操作日志 Framework Service 实现类 + * + * 基于 {@link OperateLogApi} 实现,记录操作日志 + * + * @author 芋道源码 + */ +@RequiredArgsConstructor +public class OperateLogFrameworkServiceImpl implements OperateLogFrameworkService { + + private final OperateLogApi operateLogApi; + + @Override + @Async + public void createOperateLog(OperateLog operateLog) { + OperateLogCreateReqDTO reqDTO = BeanUtil.copyProperties(operateLog, OperateLogCreateReqDTO.class); + operateLogApi.createOperateLog(reqDTO); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java index ffe40bc3d..aefb3ba3b 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; +import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXLitePayClient; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXNativePayClient; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient; @@ -62,7 +63,7 @@ public class PayClientFactoryImpl implements PayClientFactory { // TODO @芋艿 WX_LITE WX_APP 如果不添加在 项目启动的时候去初始化会报错无法启动。所以我手动加了两个,具体需要你来配 switch (channelEnum) { case WX_PUB: return (AbstractPayClient) new WXPubPayClient(channelId, (WXPayClientConfig) config); - case WX_LITE: return (AbstractPayClient) new WXPubPayClient(channelId, (WXPayClientConfig) config); + case WX_LITE: return (AbstractPayClient) new WXLitePayClient(channelId, (WXPayClientConfig) config); //微信小程序请求支付 case WX_APP: return (AbstractPayClient) new WXPubPayClient(channelId, (WXPayClientConfig) config); case WX_NATIVE: return (AbstractPayClient) new WXNativePayClient(channelId, (WXPayClientConfig) config); case ALIPAY_WAP: return (AbstractPayClient) new AlipayWapPayClient(channelId, (AlipayPayClientConfig) config); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java index 913e29c50..41c473be7 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.http.HttpUtil; import cn.iocoder.yudao.framework.pay.core.client.AbstractPayCodeMapping; import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult; import cn.iocoder.yudao.framework.pay.core.client.dto.*; @@ -130,11 +131,20 @@ public abstract class AbstractAlipayClient extends AbstractPayClient strToMap(String s) { + // TODO @zxy:这个可以使用 hutool 的 HttpUtil decodeParams 方法么? Map stringStringMap = new HashMap<>(); - //调整时间格式 + // 调整时间格式 String s3 = s.replaceAll("%3A", ":"); - //获取map + // 获取 map String s4 = s3.replace("+", " "); String[] split = s4.split("&"); for (String s1 : split) { @@ -143,4 +153,5 @@ public abstract class AbstractAlipayClient extends AbstractPayClient { + + private WxPayService client; + + public WXLitePayClient(Long channelId, WXPayClientConfig config) { + super(channelId, PayChannelEnum.WX_LITE.getCode(), config, new WXCodeMapping()); + } + + @Override + protected void doInit() { + WxPayConfig payConfig = new WxPayConfig(); + BeanUtil.copyProperties(config, payConfig, "keyContent"); + payConfig.setTradeType(WxPayConstants.TradeType.JSAPI); // 设置使用 JS API 支付方式 +// if (StrUtil.isNotEmpty(config.getKeyContent())) { +// payConfig.setKeyContent(config.getKeyContent().getBytes(StandardCharsets.UTF_8)); +// } + if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { + // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 + payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); + } + if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { + // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 + payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); + } + // 真实客户端 + this.client = new WxPayServiceImpl(); + client.setConfig(payConfig); + } + + @Override + public PayCommonResult doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { + WxPayMpOrderResult response; + try { + switch (config.getApiVersion()) { + case WXPayClientConfig.API_VERSION_V2: + response = this.unifiedOrderV2(reqDTO); + break; + case WXPayClientConfig.API_VERSION_V3: + WxPayUnifiedOrderV3Result.JsapiResult responseV3 = this.unifiedOrderV3(reqDTO); + // 将 V3 的结果,统一转换成 V2。返回的字段是一致的 + response = new WxPayMpOrderResult(); + BeanUtil.copyProperties(responseV3, response, true); + break; + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } catch (WxPayException e) { + log.error("[unifiedOrder][request({}) 发起支付失败,原因({})]", toJsonString(reqDTO), e); + return PayCommonResult.build(ObjectUtils.defaultIfNull(e.getErrCode(), e.getReturnCode(), "CustomErrorCode"), + ObjectUtils.defaultIfNull(e.getErrCodeDes(), e.getCustomErrorMsg()), null, codeMapping); + } + return PayCommonResult.build(CODE_SUCCESS, MESSAGE_SUCCESS, response, codeMapping); + } + + private WxPayMpOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 构建 WxPayUnifiedOrderRequest 对象 + WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder() + .outTradeNo(reqDTO.getMerchantOrderId()) + .body(reqDTO.getBody()) + .totalFee(reqDTO.getAmount().intValue()) // 单位分 + .timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyyMMddHHmmss")) // v2的时间格式 + .spbillCreateIp(reqDTO.getUserIp()) + .openid(getOpenid(reqDTO)) + .notifyUrl(reqDTO.getNotifyUrl()) + .build(); + // 执行请求 + return client.createOrder(request); + } + + private WxPayUnifiedOrderV3Result.JsapiResult unifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 构建 WxPayUnifiedOrderRequest 对象 + WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); + request.setOutTradeNo(reqDTO.getMerchantOrderId()); + + request.setDescription(reqDTO.getBody()); + request.setAmount(new WxPayUnifiedOrderV3Request + .Amount() + .setTotal(reqDTO + .getAmount() + .intValue())); // 单位分 + request.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")); // v3的时间格式 + request.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); + request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); + request.setNotifyUrl(reqDTO.getNotifyUrl()); + // 执行请求 + return client.createOrderV3(TradeTypeEnum.JSAPI, request); + } + + private static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { + String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); + if (StrUtil.isEmpty(openid)) { + throw new IllegalArgumentException("支付请求的 openid 不能为空!"); + } + return openid; + } + + /** + * + * 微信支付回调 分 v2 和v3 的处理方式 + * + * @param data 通知结果 + * @return 支付回调对象 + * @throws WxPayException 微信异常类 + */ + @Override + public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException { + log.info("[parseOrderNotify][微信支付回调data数据:{}]", data.getBody()); + // 微信支付 v2 回调结果处理 + switch (config.getApiVersion()) { + case WXPayClientConfig.API_VERSION_V2: + return parseOrderNotifyV2(data); + case WXPayClientConfig.API_VERSION_V3: + return parseOrderNotifyV3(data); + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } + + private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException { + WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null); + WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult(); + // 转换结果 + Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), + "支付结果非 SUCCESS"); + + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(result.getOutTradeNo()) + .channelOrderNo(result.getTradeState()) + .successTime(DateUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) + .data(data.getBody()) + .build(); + } + + private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyDataDTO data) throws WxPayException { + WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); + Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); + // 转换结果 + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(notifyResult.getOutTradeNo()) + .channelOrderNo(notifyResult.getTransactionId()) + .channelUserId(notifyResult.getOpenid()) + .successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss")) + .data(data.getBody()) + .build(); + + } + + @Override + public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) { + //TODO 需要实现 + throw new UnsupportedOperationException("需要实现"); + } + + + @Override + protected PayCommonResult doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { + //TODO 需要实现 + throw new UnsupportedOperationException(); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java index f0074c044..20ad91c82 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java @@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.*; import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result; import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; @@ -28,9 +29,14 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString import static cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXCodeMapping.CODE_SUCCESS; import static cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXCodeMapping.MESSAGE_SUCCESS; - +/** + * 微信 App 支付 + * + * @author zwy + */ @Slf4j public class WXNativePayClient extends AbstractPayClient { + private WxPayService client; public WXNativePayClient(Long channelId, WXPayClientConfig config) { @@ -61,7 +67,7 @@ public class WXNativePayClient extends AbstractPayClient { @Override public PayCommonResult doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { // 这里原生的返回的是支付的 url 所以直接使用string接收 - //"invokeResponse": "weixin://wxpay/bizpayurl?pr=EGYAem7zz" + // "invokeResponse": "weixin://wxpay/bizpayurl?pr=EGYAem7zz" String responseV3; try { switch (config.getApiVersion()) { @@ -84,7 +90,7 @@ public class WXNativePayClient extends AbstractPayClient { private WxPayNativeOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { //前端 - String trade_type = reqDTO.getChannelExtras().get("trade_type"); + String tradeType = reqDTO.getChannelExtras().get("trade_type"); // 构建 WxPayUnifiedOrderRequest 对象 WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest .newBuilder() @@ -94,7 +100,7 @@ public class WXNativePayClient extends AbstractPayClient { .timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) .spbillCreateIp(reqDTO.getUserIp()) .notifyUrl(reqDTO.getNotifyUrl()) - .productId(trade_type) + .productId(tradeType) .build(); // 执行请求 return client.createOrder(request); @@ -109,33 +115,72 @@ public class WXNativePayClient extends AbstractPayClient { request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); request.setNotifyUrl(reqDTO.getNotifyUrl()); // 执行请求 -// log.info("支付字段request:{}",request.getTimeExpire()); - return client.createOrderV3(TradeTypeEnum.NATIVE, request); } - + /** + * + * 微信支付回调 分v2 和v3 的处理方式 + * + * @param data 通知结果 + * @return 支付回调对象 + * @throws WxPayException 微信异常类 + */ @Override public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException { + log.info("微信支付回调data数据:{}", data.getBody()); + // 微信支付 v2 回调结果处理 + switch (config.getApiVersion()) { + case WXPayClientConfig.API_VERSION_V2: + return parseOrderNotifyV2(data); + case WXPayClientConfig.API_VERSION_V3: + return parseOrderNotifyV3(data); + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } + + private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException { + WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null); + WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult(); + // 转换结果 + Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), + "支付结果非 SUCCESS"); + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(result.getOutTradeNo()) + .channelOrderNo(result.getTradeState()) + .successTime(DateUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) + .data(data.getBody()) + .build(); + } + + private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyDataDTO data) throws WxPayException { WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); // 转换结果 - return PayOrderNotifyRespDTO.builder().orderExtensionNo(notifyResult.getOutTradeNo()) - .channelOrderNo(notifyResult.getTransactionId()).channelUserId(notifyResult.getOpenid()) - .successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyy-MM-dd'T'HH:mm:ssXXX")) - .data(data.getBody()).build(); + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(notifyResult.getOutTradeNo()) + .channelOrderNo(notifyResult.getTransactionId()) + .channelUserId(notifyResult.getOpenid()) + .successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss")) + .data(data.getBody()) + .build(); + } @Override public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) { - //TODO 需要实现 + // TODO 需要实现 throw new UnsupportedOperationException("需要实现"); } @Override protected PayCommonResult doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - //TODO 需要实现 + // TODO 需要实现 throw new UnsupportedOperationException(); } + } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java index 507243c0b..294f8e4ff 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java @@ -11,8 +11,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Set; -// TODO 芋艿:参数校验 - /** * 微信支付的 PayClientConfig 实现类 * 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性 @@ -22,7 +20,6 @@ import java.util.Set; @Data public class WXPayClientConfig implements PayClientConfig { - // TODO 芋艿:V2 or V3 客户端 /** * API 版本 - V2 * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_1 diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java index 866405e79..238344759 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java @@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.*; import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result; import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; @@ -95,7 +96,6 @@ public class WXPubPayClient extends AbstractPayClient { // 构建 WxPayUnifiedOrderRequest 对象 WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder() .outTradeNo(reqDTO.getMerchantOrderId()) - // TODO 芋艿:貌似没 title? .body(reqDTO.getBody()) .totalFee(reqDTO.getAmount().intValue()) // 单位分 .timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) @@ -111,7 +111,6 @@ public class WXPubPayClient extends AbstractPayClient { // 构建 WxPayUnifiedOrderRequest 对象 WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); request.setOutTradeNo(reqDTO.getMerchantOrderId()); - // TODO 芋艿:貌似没 title? request.setDescription(reqDTO.getBody()); request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount().intValue())); // 单位分 request.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")); @@ -130,27 +129,67 @@ public class WXPubPayClient extends AbstractPayClient { return openid; } + /** + * + * 微信支付回调 分v2 和v3 的处理方式 + * + * @param data 通知结果 + * @return 支付回调对象 + * @throws WxPayException 微信异常类 + */ @Override public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException { + log.info("[parseOrderNotify][微信支付回调data数据: {}]", data.getBody()); + // 微信支付 v2 回调结果处理 + switch (config.getApiVersion()) { + case WXPayClientConfig.API_VERSION_V2: + return parseOrderNotifyV2(data); + case WXPayClientConfig.API_VERSION_V3: + return parseOrderNotifyV3(data); + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } + + private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException { + WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null); + WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult(); + // 转换结果 + Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), + "支付结果非 SUCCESS"); + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(result.getOutTradeNo()) + .channelOrderNo(result.getTradeState()) + .successTime(DateUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) + .data(data.getBody()) + .build(); + } + + private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyDataDTO data) throws WxPayException { WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); // 转换结果 - return PayOrderNotifyRespDTO.builder().orderExtensionNo(notifyResult.getOutTradeNo()) - .channelOrderNo(notifyResult.getTransactionId()).channelUserId(notifyResult.getOpenid()) + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(notifyResult.getOutTradeNo()) + .channelOrderNo(notifyResult.getTransactionId()) + .channelUserId(notifyResult.getOpenid()) .successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss")) - .data(data.getBody()).build(); + .data(data.getBody()) + .build(); + } @Override public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) { - //TODO 需要实现 + // TODO 需要实现 throw new UnsupportedOperationException("需要实现"); } - @Override protected PayCommonResult doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - //TODO 需要实现 + // TODO 需要实现 throw new UnsupportedOperationException(); } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java index a708faf8e..0754f9dae 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java @@ -22,7 +22,6 @@ public enum PayChannelEnum { WX_APP("wx_app", "微信 App 支付", WXPayClientConfig.class), WX_NATIVE("wx_native", "微信 native 支付", WXPayClientConfig.class), - ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class), ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class), ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class), diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml index 1d67e7a9c..1d43ff2c5 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml @@ -56,6 +56,12 @@ spring-boot-starter-test test + + + + com.google.guava + guava + diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java index 5c1376534..c1c969439 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java @@ -11,9 +11,11 @@ import cn.iocoder.yudao.framework.tenant.core.job.TenantJobHandlerDecorator; import cn.iocoder.yudao.framework.tenant.core.mq.TenantRedisMessageInterceptor; import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter; import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; +import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl; import cn.iocoder.yudao.framework.tenant.core.web.TenantContextWebFilter; import cn.iocoder.yudao.framework.web.config.WebProperties; import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler; +import cn.iocoder.yudao.module.system.api.tenant.TenantApi; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; import org.springframework.beans.BeansException; @@ -29,6 +31,11 @@ import org.springframework.context.annotation.Configuration; @EnableConfigurationProperties(TenantProperties.class) public class YudaoTenantAutoConfiguration { + @Bean + public TenantFrameworkService tenantFrameworkService(TenantApi tenantApi) { + return new TenantFrameworkServiceImpl(tenantApi); + } + // ========== AOP ========== @Bean diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java index 15c72f992..c493b41d1 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/mq/TenantRedisMessageInterceptor.java @@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.mq.core.interceptor.RedisMessageInterceptor; import cn.iocoder.yudao.framework.mq.core.message.AbstractRedisMessage; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; + /** * 多租户 {@link AbstractRedisMessage} 拦截器 * @@ -15,8 +17,6 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; */ public class TenantRedisMessageInterceptor implements RedisMessageInterceptor { - private static final String HEADER_TENANT_ID = "tenant-id"; - @Override public void sendMessageBefore(AbstractRedisMessage message) { Long tenantId = TenantContextHolder.getTenantId(); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/service/TenantFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/service/TenantFrameworkServiceImpl.java new file mode 100644 index 000000000..75d065e1e --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/service/TenantFrameworkServiceImpl.java @@ -0,0 +1,73 @@ +package cn.iocoder.yudao.framework.tenant.core.service; + +import cn.iocoder.yudao.framework.common.exception.ServiceException; +import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; +import cn.iocoder.yudao.module.system.api.tenant.TenantApi; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +import java.time.Duration; +import java.util.List; + +/** + * Tenant 框架 Service 实现类 + * + * @author 芋道源码 + */ +@RequiredArgsConstructor +public class TenantFrameworkServiceImpl implements TenantFrameworkService { + + private static final ServiceException SERVICE_EXCEPTION_NULL = new ServiceException(); + + private final TenantApi tenantApi; + + /** + * 针对 {@link #getTenantIds()} 的缓存 + */ + private final LoadingCache> getTenantIdsCache = CacheUtils.buildAsyncReloadingCache( + Duration.ofMinutes(1L), // 过期时间 1 分钟 + new CacheLoader>() { + + @Override + public List load(Object key) { + return tenantApi.getTenantIds(); + } + + }); + + /** + * 针对 {@link #validTenant(Long)} 的缓存 + */ + private final LoadingCache validTenantCache = CacheUtils.buildAsyncReloadingCache( + Duration.ofMinutes(1L), // 过期时间 1 分钟 + new CacheLoader() { + + @Override + public ServiceException load(Long id) { + try { + tenantApi.validTenant(id); + return SERVICE_EXCEPTION_NULL; + } catch (ServiceException ex) { + return ex; + } + } + + }); + + @Override + @SneakyThrows + public List getTenantIds() { + return getTenantIdsCache.get(Boolean.TRUE); + } + + @Override + public void validTenant(Long id) { + ServiceException serviceException = validTenantCache.getUnchecked(id); + if (serviceException != SERVICE_EXCEPTION_NULL) { + throw serviceException; + } + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java index 272419c09..8e37727d9 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java @@ -18,8 +18,6 @@ import java.io.IOException; */ public class TenantContextWebFilter extends OncePerRequestFilter { - private static final String HEADER_TENANT_ID = "tenant-id"; - @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/convert/DictConvert.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/convert/DictConvert.java index beed26f94..7698cf4a6 100644 --- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/convert/DictConvert.java +++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/convert/DictConvert.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.framework.excel.core.convert; import cn.hutool.core.convert.Convert; -import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO; import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import com.alibaba.excel.converters.Converter; @@ -12,7 +11,7 @@ import com.alibaba.excel.metadata.property.ExcelContentProperty; import lombok.extern.slf4j.Slf4j; /** - * Excel {@link DictDataRespDTO} 数据字典转换器 + * Excel 数据字典转换器 * * @author 芋道源码 */ @@ -35,14 +34,14 @@ public class DictConvert implements Converter { // 使用字典解析 String type = getType(contentProperty); String label = cellData.getStringValue(); - DictDataRespDTO dictData = DictFrameworkUtils.parseDictDataFromCache(type, label); - if (dictData == null) { + String value = DictFrameworkUtils.parseDictDataValue(type, label); + if (value == null) { log.error("[convertToJavaData][type({}) 解析不掉 label({})]", type, label); return null; } // 将 String 的 value 转换成对应的属性 Class fieldClazz = contentProperty.getField().getType(); - return Convert.convert(fieldClazz, dictData.getValue()); + return Convert.convert(fieldClazz, value); } @Override @@ -56,13 +55,13 @@ public class DictConvert implements Converter { // 使用字典格式化 String type = getType(contentProperty); String value = String.valueOf(object); - DictDataRespDTO dictData = DictFrameworkUtils.getDictDataFromCache(type, value); - if (dictData == null) { + String label = DictFrameworkUtils.getDictDataLabel(type, value); + if (label == null) { log.error("[convertToExcelData][type({}) 转换不了 label({})]", type, value); return new CellData<>(""); } // 生成 Excel 小表格 - return new CellData<>(dictData.getLabel()); + return new CellData<>(label); } private static String getType(ExcelContentProperty contentProperty) { diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/config/YudaoExtensionAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/config/YudaoExtensionAutoConfiguration.java deleted file mode 100644 index 8b047ae1b..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/config/YudaoExtensionAutoConfiguration.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.framework.extension.config; - -import cn.iocoder.yudao.framework.extension.core.ExtensionBootstrap; -import cn.iocoder.yudao.framework.extension.core.context.ExtensionContext; -import cn.iocoder.yudao.framework.extension.core.context.ExtensionContextHolder; -import cn.iocoder.yudao.framework.extension.core.context.ExtensionExecutor; -import cn.iocoder.yudao.framework.extension.core.factory.ExtensionFactory; -import cn.iocoder.yudao.framework.extension.core.factory.ExtensionRegisterFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @description 扩展点组件自动装配 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 21:50 - * @class cn.iocoder.yudao.framework.extension.config.YudaoExtensionAutoConfiguration.java - */ -@Configuration -public class YudaoExtensionAutoConfiguration { - - /** - * 组件初始化 - * @return - */ - @Bean(initMethod = "init") - @ConditionalOnMissingBean(ExtensionBootstrap.class) - public ExtensionBootstrap bootstrap() { - return new ExtensionBootstrap(); - } - - /** - * 扩展点工厂 - * @return - */ - @Bean - @ConditionalOnMissingBean({ExtensionRegisterFactory.class, ExtensionFactory.class}) - public ExtensionRegisterFactory registerFactory() { - return new ExtensionRegisterFactory(); - } - - /** - * 扩展组件上下文对象 - * @return - */ - @Bean - @ConditionalOnMissingBean({ExtensionContextHolder.class, ExtensionContext.class}) - public ExtensionContextHolder context() { - return new ExtensionContextHolder(); - } - - /** - * 扩展组件执行器 - * @return - */ - @Bean - @ConditionalOnMissingBean(ExtensionExecutor.class) - public ExtensionExecutor executor() { - return new ExtensionExecutor(); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/BusinessScenario.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/BusinessScenario.java deleted file mode 100644 index 732350c67..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/BusinessScenario.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * @description 业务场景 = businessId + useCase + scenario, 用来标识系统中唯一的一个场景
- * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 22:19 - * @class cn.iocoder.yudao.framework.extension.core.BusinessScenario.java - */ -public class BusinessScenario implements Serializable { - - /** - * 默认业务id - */ - public final static String DEFAULT_BUSINESS_ID = "#defaultBusinessId#"; - - /** - * 默认用例 - */ - public final static String DEFAULT_USECASE = "#defaultUseCase#"; - - /** - * 默认场景 - */ - public final static String DEFAULT_SCENARIO = "#defaultScenario#"; - - /** - * 分隔符 - */ - private final static String DOT_SEPARATOR = "."; - - /** - * 业务Id - */ - private String businessId; - - /** - * 用例 - */ - private String useCase; - - /** - * 场景 - */ - private String scenario; - - public BusinessScenario() { - this.businessId = DEFAULT_BUSINESS_ID; - this.useCase = DEFAULT_USECASE; - this.scenario = DEFAULT_SCENARIO; - } - - public BusinessScenario(@NotNull String businessId, @NotNull String useCase, @NotNull String scenario) { - this.businessId = businessId; - this.useCase = useCase; - this.scenario = scenario; - } - - public BusinessScenario(@NotNull String scenario) { - this(); - this.scenario = scenario; - } - - public BusinessScenario(@NotNull String useCase, @NotNull String scenario) { - this(DEFAULT_BUSINESS_ID, useCase, scenario); - } - - public String getBusinessId() { - return businessId; - } - - public void setBusinessId(String businessId) { - this.businessId = businessId; - } - - public String getUseCase() { - return useCase; - } - - public void setUseCase(String useCase) { - this.useCase = useCase; - } - - public String getScenario() { - return scenario; - } - - public void setScenario(String scenario) { - this.scenario = scenario; - } - - /** - * 构建业务场景 - * @param businessId - * @param useCase - * @param scenario - * @return - */ - public static BusinessScenario valueOf(@NotNull String businessId, @NotNull String useCase, @NotNull String scenario) { - return new BusinessScenario(businessId, useCase, scenario); - } - - /** - * 构建业务场景 - * @param useCase - * @param scenario - * @return - */ - public static BusinessScenario valueOf(@NotNull String useCase, @NotNull String scenario) { - return new BusinessScenario(useCase, scenario); - } - - /** - * 构建业务场景 - * @param scenario - * @return - */ - public static BusinessScenario valueOf(@NotNull String scenario) { - return new BusinessScenario(scenario); - } - - /** - * 业务场景唯一标识 - * @return - */ - public String getUniqueIdentity(){ - return new StringJoiner(DOT_SEPARATOR).add(businessId).add(useCase).add(scenario).toString(); - } - - @Override - public String toString() { - return "BusinessScenario{" + - "businessId='" + businessId + '\'' + - ", useCase='" + useCase + '\'' + - ", scenario='" + scenario + '\'' + - '}'; - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/ExtensionBootstrap.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/ExtensionBootstrap.java deleted file mode 100644 index 800c431be..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/ExtensionBootstrap.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core; - -import cn.iocoder.yudao.framework.extension.core.factory.ExtensionRegisterFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -import javax.annotation.PostConstruct; - -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-29 00:18 - * @class cn.iocoder.yudao.framework.extension.core.ExtensionBootstrap.java - */ -public class ExtensionBootstrap implements ApplicationContextAware { - - /** - * spring 容器 - */ - private ApplicationContext applicationContext; - - @Autowired - private ExtensionRegisterFactory registerFactory; - - /** - * 初始化 - */ - @PostConstruct - public void init() { - registerFactory.setApplicationContext(applicationContext); - registerFactory.register(null); - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/AbstractComponentExecutor.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/AbstractComponentExecutor.java deleted file mode 100644 index f46d05d90..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/AbstractComponentExecutor.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.context; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; - -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * @description 执行器通用方法 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-29 00:38 - * @class cn.iocoder.yudao.framework.extension.core.context.AbstractComponentExecutor.java - */ -public abstract class AbstractComponentExecutor { - - /** - * ("业务" + "用例" + "场景")执行扩展组件,并返回执行结果 - * @param targetClazz - * @param businessId - * @param useCase - * @param scenario - * @param function - * @param - * @param - * @return - */ - public R execute(Class targetClazz, String businessId, String useCase, String scenario, Function function) { - return execute(targetClazz, BusinessScenario.valueOf(businessId, useCase, scenario), function); - } - - - /** - * ("用例" + "场景")执行扩展组件,并返回执行结果 - * @param targetClazz - * @param useCase - * @param scenario - * @param function - * @param - * @param - * @return - */ - public R execute(Class targetClazz, String useCase, String scenario, Function function) { - return execute(targetClazz, BusinessScenario.valueOf(useCase, scenario), function); - } - - /** - * ("场景")执行扩展组件,并返回执行结果 - * @param targetClazz - * @param scenario - * @param function - * @param - * @param - * @return - */ - public R execute(Class targetClazz, String scenario, Function function) { - return execute(targetClazz, BusinessScenario.valueOf(scenario), function); - } - - /** - * 执行扩展组件,并返回执行结果 - * @param targetClazz - * @param businessScenario - * @param function - * @param Response Type - * @param Parameter Type - * @return - */ - public R execute(Class targetClazz, BusinessScenario businessScenario, Function function) { - T component = locateComponent(targetClazz, businessScenario); - return function.apply(component); - } - - /** - * ("业务" + "用例" + "场景")执行扩展组件,适用于无返回值的业务 - * @param targetClazz - * @param businessId - * @param useCase - * @param scenario - * @param consumer - * @param - */ - public void accept(Class targetClazz, String businessId, String useCase, String scenario, Consumer consumer) { - accept(targetClazz, BusinessScenario.valueOf(businessId, useCase, scenario), consumer); - } - - /** - * ("场景")执行扩展组件,适用于无返回值的业务 - * @param targetClazz - * @param useCase - * @param scenario - * @param consumer - * @param - */ - public void accept(Class targetClazz, String useCase, String scenario, Consumer consumer) { - accept(targetClazz, BusinessScenario.valueOf(useCase, scenario), consumer); - } - - /** - * ("场景")执行扩展组件,适用于无返回值的业务 - * @param targetClazz - * @param scenario - * @param consumer - * @param - */ - public void accept(Class targetClazz, String scenario, Consumer consumer) { - accept(targetClazz, BusinessScenario.valueOf(scenario), consumer); - } - - /** - * 执行扩展组件,适用于无返回值的业务 - * @param targetClazz - * @param businessScenario - * @param consumer - * @param Parameter Type - */ - public void accept(Class targetClazz, BusinessScenario businessScenario, Consumer consumer) { - T component = locateComponent(targetClazz, businessScenario); - consumer.accept(component); - } - - /** - * 获取/定位扩展点组件 - * @param targetClazz - * @param businessScenario - * @param - * @return - */ - protected abstract C locateComponent(Class targetClazz, BusinessScenario businessScenario); -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionContext.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionContext.java deleted file mode 100644 index 5704cc49f..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionContext.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.context; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; - -/** - * @description 上下文,包含各个扩展点的相关操作 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 22:15 - * @class cn.iocoder.yudao.framework.extension.core.context.ExtensionContext.java - */ -public interface ExtensionContext { - - /** - * 根据业务场景唯一标识获取扩展点组件实现类 - * @param businessId - * @param useCase - * @param scenario - * @param clazz - * @param - * @return - */ - T getPoint(String businessId, String useCase, String scenario, Class clazz); - - /** - * 根据("实例" + "场景")获取扩展点组件实现类,其中:业务id(businessId)= {@linkplain cn.iocoder.yudao.framework.extension.core.BusinessScenario.DEFAULT_BUSINESS_ID} - * @param useCase - * @param scenario - * @param clazz - * @param - * @return - */ - T getPoint(String useCase, String scenario, Class clazz); - - /** - * 根据("场景")获取扩展点组件实现类
- * 其中: - * 业务id(businessId)= {@linkplain cn.iocoder.yudao.framework.extension.core.BusinessScenario.DEFAULT_BUSINESS_ID} - * 实例(useCase)= {@linkplain cn.iocoder.yudao.framework.extension.core.BusinessScenario.DEFAULT_USECASE} - * @param scenario - * @param clazz - * @param - * @return - */ - T getPoint(String scenario, Class clazz); - - /** - * 根据业务场景唯一标识获取扩展点组件实现类 - * @param businessScenario - * @param clazz - * @param - * @return - */ - T getPoint(BusinessScenario businessScenario, Class clazz); -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionContextHolder.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionContextHolder.java deleted file mode 100644 index 6e121b70d..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionContextHolder.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.context; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.factory.ExtensionFactory; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.NotNull; - -/** - * @description 上下文及扩展点组件工厂的持有类 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-29 00:29 - * @class cn.iocoder.yudao.framework.extension.core.context.ExtensionContextHolder.java - */ -@Component -@Slf4j -public class ExtensionContextHolder implements ExtensionContext{ - - @Autowired - private ExtensionFactory factory; - - @Override - public T getPoint(@NotNull String businessId, @NotNull String useCase, @NotNull String scenario, Class clazz) { - return getPoint(BusinessScenario.valueOf(businessId, useCase, scenario), clazz); - } - - @Override - public T getPoint(@NotNull String useCase, String scenario, Class clazz) { - return getPoint(BusinessScenario.valueOf(useCase, scenario), clazz); - } - - @Override - public T getPoint(@NotNull String scenario, Class clazz) { - return getPoint(BusinessScenario.valueOf(scenario), clazz); - } - - @Override - public T getPoint(@NotNull BusinessScenario businessScenario, Class clazz) { - return factory.get(businessScenario, clazz); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionExecutor.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionExecutor.java deleted file mode 100644 index 5f48652e5..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/context/ExtensionExecutor.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.context; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * @description 扩展组件执行器 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-29 00:32 - * @class cn.iocoder.yudao.framework.extension.core.context.ExtensionExecutor.java - */ -@Component -@Slf4j -public class ExtensionExecutor extends AbstractComponentExecutor{ - - @Autowired - private ExtensionContextHolder contextHolder; - - - @Override - protected C locateComponent(Class targetClazz, BusinessScenario businessScenario) { - return contextHolder.getPoint(businessScenario, targetClazz); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionDefinition.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionDefinition.java deleted file mode 100644 index 5feed6660..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionDefinition.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.factory; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.util.Objects; - -/** - * @description 扩展定义(扩展坐标),标识唯一一个业务场景实现 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 23:14 - * @class cn.iocoder.yudao.framework.extension.core.factory.ExtensionDefinition.java - */ -@Setter -@Getter -public class ExtensionDefinition implements Serializable { - - /** - * 业务场景唯一标识(id) - */ - private String uniqueIdentify; - - /** - * 扩展点实现类名称 - */ - private String extensionPointName; - - /** - * 业务场景 - */ - private BusinessScenario businessScenario; - - /** - * 扩展点实现类 - */ - private ExtensionPoint extensionPoint; - - /** - * class - */ - private Class extensionPointClass; - - public ExtensionDefinition() { - } - - public ExtensionDefinition(@NotNull BusinessScenario businessScenario, @NotNull ExtensionPoint extensionPoint) { - this.businessScenario = businessScenario; - this.extensionPoint = extensionPoint; - this.uniqueIdentify = this.businessScenario.getUniqueIdentity(); - this.extensionPointClass = this.extensionPoint.getClass(); - } - - /** - * 构建definition - * @param businessScenario - * @param point - * @return - */ - public static ExtensionDefinition valueOf(@NotNull BusinessScenario businessScenario, @NotNull ExtensionPoint point) { - return new ExtensionDefinition(businessScenario, point); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ExtensionDefinition that = (ExtensionDefinition) o; - return Objects.equals(uniqueIdentify, that.uniqueIdentify) && Objects.equals(extensionPointName, that.extensionPointName); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((uniqueIdentify == null) ? 0 : uniqueIdentify.hashCode()); - result = prime * result + ((extensionPointName == null) ? 0 : extensionPointName.hashCode()); - return result; - } - - @Override - public String toString() { - return "ExtensionDefinition{" + - "uniqueIdentify='" + uniqueIdentify + '\'' + - ", extensionPointName='" + extensionPointName + '\'' + - '}'; - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionFactory.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionFactory.java deleted file mode 100644 index c03175c13..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.factory; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; - -/** - * @description 扩展点工厂 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 23:04 - * @class cn.iocoder.yudao.framework.extension.core.factory.ExtensionFactory.java - */ -public interface ExtensionFactory { - - /** - * 注册所有扩展点实现类 - * @param basePackage - */ - void register(String basePackage); - - /** - * 根据业务场景获取指定类型的扩展点 - * @param businessScenario - * @param clazz - * @param - * @return - */ - T get(BusinessScenario businessScenario, Class clazz); -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionRegisterFactory.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionRegisterFactory.java deleted file mode 100644 index 15b802436..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/factory/ExtensionRegisterFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.factory; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; -import cn.iocoder.yudao.framework.extension.core.stereotype.Extension; -import lombok.extern.slf4j.Slf4j; -import org.springframework.aop.support.AopUtils; -import org.springframework.context.ApplicationContext; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.stereotype.Component; -import org.springframework.util.ClassUtils; - -import javax.validation.constraints.NotNull; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @description 注册工厂 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 23:07 - * @class cn.iocoder.yudao.framework.extension.core.factory.ExtensionRegisterFactory.java - */ -@Component -@Slf4j -public class ExtensionRegisterFactory implements ExtensionFactory { - - /** - * spring ApplicationContext - */ - private ApplicationContext applicationContext; - - /** - * 扩展点实现类集合 - */ - private Map registerExtensionBeans = new ConcurrentHashMap<>(); - - @Override - public void register(String basePackage) { - final Map beans = applicationContext.getBeansWithAnnotation(Extension.class); - if(beans == null || beans.isEmpty()) { - return; - } - - beans.values().forEach(point -> doRegister((ExtensionPoint) point)); - log.info("业务场景相关扩展点注册完成,注册数量: {}", registerExtensionBeans.size()); - } - - @Override - public T get(BusinessScenario businessScenario, Class clazz) { - - final ExtensionDefinition definition = registerExtensionBeans.get(businessScenario.getUniqueIdentity()); - if(definition == null) { - log.error("获取业务场景扩展点实现失败,失败原因:尚未定义该业务场景相关扩展点。{}", businessScenario); - throw new RuntimeException("尚未定义该业务场景相关扩展点 [" + businessScenario + "]"); - } - - return (T) definition.getExtensionPoint(); - } - - /** - * 注册扩展点 - * @param point - */ - private void doRegister(@NotNull ExtensionPoint point) { - Class extensionClazz = point.getClass(); - - if (AopUtils.isAopProxy(point)) { - extensionClazz = ClassUtils.getUserClass(point); - } - - Extension extension = AnnotationUtils.findAnnotation(extensionClazz, Extension.class); - final BusinessScenario businessScenario = BusinessScenario.valueOf(extension.businessId(), extension.useCase(), extension.scenario()); - final ExtensionDefinition definition = ExtensionDefinition.valueOf(businessScenario, point); - final ExtensionDefinition exist = registerExtensionBeans.get(businessScenario.getUniqueIdentity()); - if(exist != null && !exist.equals(definition)) { - throw new RuntimeException("相同的业务场景重复注册了不同类型的扩展点实现 :【" + definition + "】【" + exist + "】"); - } - - registerExtensionBeans.put(businessScenario.getUniqueIdentity(), definition); - } - - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/package-info.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/package-info.java deleted file mode 100644 index 636491eca..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description core 核心 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 21:54 - * @class cn.iocoder.yudao.framework.extension.core.package-info.java - */ -package cn.iocoder.yudao.framework.extension.core; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/point/ExtensionPoint.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/point/ExtensionPoint.java deleted file mode 100644 index e1a86d791..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/point/ExtensionPoint.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.point; -/** - * @description 扩展点
- * 表示一块逻辑在不同的业务有不同的实现,使用扩展点做接口申明,然后用{@linkplain cn.iocoder.yudao.framework.extension.core.stereotype.Extension}(扩展)去实现扩展点。 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 22:06 - * @class cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint.java - */ -public interface ExtensionPoint { -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/stereotype/Extension.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/stereotype/Extension.java deleted file mode 100644 index eaa9f99f8..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/core/stereotype/Extension.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.framework.extension.core.stereotype; - -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import org.springframework.stereotype.Component; - -import java.lang.annotation.*; - -/** - * @description 表示带注释的类是“扩展组件” - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 21:59 - * @class cn.iocoder.yudao.framework.extension.core.stereotype.Extension.java - */ -@Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -@Component -public @interface Extension { - - /** - * 业务
- * 一个自负盈亏的财务主体,比如tmall、淘宝和零售通就是三个不同的业务 - * @return - */ - String businessId() default BusinessScenario.DEFAULT_BUSINESS_ID; - - /** - * 用例
- * 描述了用户和系统之间的互动,每个用例提供了一个或多个场景。比如,支付订单就是一个典型的用例。 - * @return - */ - String useCase() default BusinessScenario.DEFAULT_USECASE; - - /** - * 场景
- * 场景也被称为用例的实例(Instance),包括用例所有的可能情况(正常的和异常的)。比如对于"订单支付"这个用例,就有“支付宝支付”、“银行卡支付”、"微信支付"等多个场景 - * @return - */ - String scenario() default BusinessScenario.DEFAULT_SCENARIO; -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/package-info.java b/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/package-info.java deleted file mode 100644 index 1c4ae94ae..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/java/cn/iocoder/yudao/framework/extension/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description 扩展点组件 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-28 14:35 - * @class cn.iocoder.yudao.framework.extension.package-info.java - */ -package cn.iocoder.yudao.framework.extension; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-extension/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 82d14b8b0..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - cn.iocoder.yudao.framework.extension.config.YudaoExtensionAutoConfiguration diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/Application.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/Application.java deleted file mode 100644 index a589affd3..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/Application.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.framework.extension; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @description Application - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:32 - * @class cn.iocoder.yudao.framework.extension.Application.java - */ -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/ExtensionTest.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/ExtensionTest.java deleted file mode 100644 index aa3b900c3..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/ExtensionTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.framework.extension; - -import cn.hutool.core.util.IdUtil; -import cn.hutool.json.JSONUtil; -import cn.iocoder.yudao.framework.extension.core.BusinessScenario; -import cn.iocoder.yudao.framework.extension.core.context.ExtensionExecutor; -import cn.iocoder.yudao.framework.extension.pay.PayExtensionPoint; -import cn.iocoder.yudao.framework.extension.pay.command.TransactionsCommand; -import cn.iocoder.yudao.framework.extension.pay.domain.TransactionsResult; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.math.BigDecimal; - -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:30 - * @class cn.iocoder.yudao.framework.extension.ExtensionTest.java - */ -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = Application.class) -@Slf4j -public class ExtensionTest { - - @Autowired - private ExtensionExecutor extensionExecutor; - - @Test - public void unifiedOrder() { - final BusinessScenario scenario = BusinessScenario.valueOf("pay", "jsapi", "wechat"); - final TransactionsCommand command = new TransactionsCommand(IdUtil.objectId(), new BigDecimal(105), "Image形象店-深圳腾大-QQ公仔", "https://www.weixin.qq.com/wxpay/pay.php"); - final TransactionsResult result = extensionExecutor.execute(PayExtensionPoint.class, scenario, extension -> extension.unifiedOrder(command)); - log.info("result is: {}", JSONUtil.toJsonStr(result)); - Assert.assertSame("wechat", result.getChannel()); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/package-info.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/package-info.java deleted file mode 100644 index d0bc63e1c..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:25 - * @class cn.iocoder.yudao.framework.extension.package-info.java - */ -package cn.iocoder.yudao.framework.extension; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/PayExtensionPoint.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/PayExtensionPoint.java deleted file mode 100644 index 9adc56b4c..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/PayExtensionPoint.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.framework.extension.pay; - -import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint; -import cn.iocoder.yudao.framework.extension.pay.command.TransactionsCommand; -import cn.iocoder.yudao.framework.extension.pay.domain.TransactionsResult; - -/** - * @description 支付操作接口 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:35 - * @class cn.iocoder.yudao.framework.extension.pay.PayExtensionPoint.java - */ -public interface PayExtensionPoint extends ExtensionPoint { - - /** - * 统一下单:获取"预支付交易会话标识" - * @param command - * @return - */ - TransactionsResult unifiedOrder(TransactionsCommand command); -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/command/TransactionsCommand.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/command/TransactionsCommand.java deleted file mode 100644 index 0ac1908dd..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/command/TransactionsCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.framework.extension.pay.command; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * @description 下单请求 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:48 - * @class cn.iocoder.yudao.framework.extension.pay.command.TransactionsCommand.java - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class TransactionsCommand implements Serializable { - /** - * 订单编号 - */ - private String orderNo; - - /** - * 支付金额 - */ - private BigDecimal amount; - - /** - * 商品描述 - */ - private String productDescription; - - /** - * 通知地址 - */ - private String notifyUrl; -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/domain/TransactionsResult.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/domain/TransactionsResult.java deleted file mode 100644 index 35861bbd0..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/domain/TransactionsResult.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.framework.extension.pay.domain; - -import lombok.*; - -import java.io.Serializable; - -/** - * @description 下单: 预支付交易单返回结果 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:43 - * @class cn.iocoder.yudao.framework.extension.pay.domain.TransactionsResult.java - */ -@Data -@AllArgsConstructor -public class TransactionsResult implements Serializable { - - /** - * 预支付交易会话标识 - */ - private String prepayId; - - /** - * 订单编号 - */ - private String orderNo; - - /** - * 系统内部支付单号 - */ - private String paymentNo; - - /** - * 支付渠道:微信 or 支付宝 - */ - private String channel; - - -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/impl/AlipayService.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/impl/AlipayService.java deleted file mode 100644 index 2daac2ff6..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/impl/AlipayService.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.framework.extension.pay.impl; - -import cn.hutool.core.util.IdUtil; -import cn.hutool.json.JSONUtil; -import cn.iocoder.yudao.framework.extension.core.stereotype.Extension; -import cn.iocoder.yudao.framework.extension.pay.PayExtensionPoint; -import cn.iocoder.yudao.framework.extension.pay.command.TransactionsCommand; -import cn.iocoder.yudao.framework.extension.pay.domain.TransactionsResult; -import lombok.extern.slf4j.Slf4j; - -/** - * @description 微信 JSAPI 支付 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:38 - * @class cn.iocoder.yudao.framework.extension.pay.impl.AlipayService.java - */ -@Extension(businessId = "pay", useCase = "jsapi", scenario = "alipay") -@Slf4j -public class AlipayService implements PayExtensionPoint { - @Override - public TransactionsResult unifiedOrder(TransactionsCommand command) { - log.info("微信 JSAPI 支付:{}", JSONUtil.toJsonStr(command)); - return new TransactionsResult("alipay26112221580621e9b071c00d9e093b0000", command.getOrderNo(), IdUtil.objectId(), "alipay"); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/impl/WechatPayService.java b/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/impl/WechatPayService.java deleted file mode 100644 index cae294092..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/src/test/java/cn/iocoder/yudao/framework/extension/pay/impl/WechatPayService.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.framework.extension.pay.impl; - -import cn.hutool.core.util.IdUtil; -import cn.hutool.json.JSONUtil; -import cn.iocoder.yudao.framework.extension.core.stereotype.Extension; -import cn.iocoder.yudao.framework.extension.pay.PayExtensionPoint; -import cn.iocoder.yudao.framework.extension.pay.command.TransactionsCommand; -import cn.iocoder.yudao.framework.extension.pay.domain.TransactionsResult; -import lombok.extern.slf4j.Slf4j; - -/** - * @description 微信 JSAPI 支付 - * @author Qingchen - * @version 1.0.0 - * @date 2021-08-30 10:37 - * @class cn.iocoder.yudao.framework.extension.pay.impl.WechatPayService.java - */ -@Extension(businessId = "pay", useCase = "jsapi", scenario = "wechat") -@Slf4j -public class WechatPayService implements PayExtensionPoint { - @Override - public TransactionsResult unifiedOrder(TransactionsCommand command) { - log.info("微信 JSAPI 支付:{}", JSONUtil.toJsonStr(command)); - return new TransactionsResult("wx26112221580621e9b071c00d9e093b0000", command.getOrderNo(), IdUtil.objectId(), "wechat"); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-extension/《芋道 Spring Boot 扩展点组件》.md b/yudao-framework/yudao-spring-boot-starter-extension/《芋道 Spring Boot 扩展点组件》.md deleted file mode 100644 index 59ff2dcb3..000000000 --- a/yudao-framework/yudao-spring-boot-starter-extension/《芋道 Spring Boot 扩展点组件》.md +++ /dev/null @@ -1,19 +0,0 @@ -### 作用 - -​ 为了解决同一个流程不同业务有不同处理逻辑而产生,减少代码中 if else 逻辑,降低代码的耦合性,通过统一的扩展形式来支撑业务的变化。 - -### 原理 - -​ https://blog.csdn.net/significantfrank/article/details/100074716 - - - -### 使用介绍 - -参考测试代码 `cn.iocoder.yudao.framework.extension.ExtensionTest` - - - - - - diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml b/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml index 5c728353c..ebd1210c0 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml @@ -58,6 +58,12 @@ apm-toolkit-opentracing + + + io.micrometer + micrometer-registry-prometheus + + de.codecentric spring-boot-admin-starter-client diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java new file mode 100644 index 000000000..cda0d2cb8 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.framework.tracer.config; + +import io.micrometer.core.instrument.MeterRegistry; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Metrics 配置类 + * + * @author 芋道源码 + */ +@Configuration +@ConditionalOnClass({MeterRegistryCustomizer.class}) +@ConditionalOnProperty(prefix = "yudao.metrics", value = "enable", matchIfMissing = true) // 允许使用 yudao.metrics.enable=false 禁用 Metrics +public class YudaoMetricsAutoConfiguration { + + @Bean + public MeterRegistryCustomizer metricsCommonTags( + @Value("${spring.application.name}") String applicationName) { + return registry -> registry.config().commonTags("application", applicationName); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories index 6f4f606bb..9b69f01ea 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories @@ -1,2 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - cn.iocoder.yudao.framework.tracer.config.YudaoTracerAutoConfiguration + cn.iocoder.yudao.framework.tracer.config.YudaoTracerAutoConfiguration,\ + cn.iocoder.yudao.framework.tracer.config.YudaoMetricsAutoConfiguration diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java index a9373cd9c..9d5f64597 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/SecurityProperties.java @@ -16,18 +16,18 @@ public class SecurityProperties { * HTTP 请求时,访问令牌的请求 Header */ @NotEmpty(message = "Token Header 不能为空") - private String tokenHeader; + private String tokenHeader = "Authorization"; /** * mock 模式的开关 */ @NotNull(message = "mock 模式的开关不能为空") - private Boolean mockEnable; + private Boolean mockEnable = false; /** * mock 模式的密钥 * 一定要配置密钥,保证安全性 */ @NotEmpty(message = "mock 模式的密钥不能为空") // 这里设置了一个默认值,因为实际上只有 mockEnable 为 true 时才需要配置。 - private String mockSecret = "yudaoyuanma"; + private String mockSecret = "test"; } diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java index c5f2ef033..e9045c76f 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java @@ -8,7 +8,7 @@ import cn.iocoder.yudao.framework.security.core.handler.AuthenticationEntryPoint import cn.iocoder.yudao.framework.security.core.service.SecurityFrameworkService; import cn.iocoder.yudao.framework.security.core.service.SecurityFrameworkServiceImpl; import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler; -import cn.iocoder.yudao.module.system.api.auth.OAuth2TokenApi; +import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; import cn.iocoder.yudao.module.system.api.permission.PermissionApi; import org.springframework.beans.factory.config.MethodInvokingFactoryBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -81,7 +81,7 @@ public class YudaoSecurityAutoConfiguration { return new TokenAuthenticationFilter(securityProperties, globalExceptionHandler, oauth2TokenApi); } - @Bean("ss") // 使用 Spring Security 的缩写,方便食用 + @Bean("ss") // 使用 Spring Security 的缩写,方便使用 public SecurityFrameworkService securityFrameworkService(PermissionApi permissionApi) { return new SecurityFrameworkServiceImpl(permissionApi); } diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java index e59324004..e87f5bc44 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java @@ -10,8 +10,8 @@ import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler; import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.system.api.auth.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCheckRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; import lombok.RequiredArgsConstructor; import org.springframework.security.access.AccessDeniedException; import org.springframework.web.filter.OncePerRequestFilter; diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml index 44081d86b..8662584e3 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml @@ -53,6 +53,13 @@ provided + + + cn.iocoder.boot + yudao-module-infra-api + ${revision} + + io.github.resilience4j diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java index 7dc78c445..e2875c1c3 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java @@ -2,11 +2,17 @@ package cn.iocoder.yudao.framework.apilog.config; import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter; import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; +import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl; +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl; +import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; import cn.iocoder.yudao.framework.web.config.WebProperties; import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration; -import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; +import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi; +import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,10 +23,21 @@ import javax.servlet.Filter; @AutoConfigureAfter(YudaoWebAutoConfiguration.class) public class YudaoApiLogAutoConfiguration { + @Bean + public ApiAccessLogFrameworkService apiAccessLogFrameworkService(ApiAccessLogApi apiAccessLogApi) { + return new ApiAccessLogFrameworkServiceImpl(apiAccessLogApi); + } + + @Bean + public ApiErrorLogFrameworkService apiErrorLogFrameworkService(ApiErrorLogApi apiErrorLogApi) { + return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi); + } + /** * 创建 ApiAccessLogFilter Bean,记录 API 请求日志 */ @Bean + @ConditionalOnProperty(prefix = "yudao.access-log", value = "enable", matchIfMissing = true) // 允许使用 yudao.access-log.enable=false 禁用访问日志 public FilterRegistrationBean apiAccessLogFilter(WebProperties webProperties, @Value("${spring.application.name}") String applicationName, ApiAccessLogFrameworkService apiAccessLogFrameworkService) { diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java index a0bdf64c8..6417189b0 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java @@ -3,8 +3,8 @@ package cn.iocoder.yudao.framework.apilog.core.filter; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.extra.servlet.ServletUtil; +import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog; import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; @@ -66,16 +66,16 @@ public class ApiAccessLogFilter extends ApiRequestFilter { private void createApiAccessLog(HttpServletRequest request, Date beginTime, Map queryString, String requestBody, Exception ex) { - ApiAccessLogCreateReqDTO accessLog = new ApiAccessLogCreateReqDTO(); + ApiAccessLog accessLog = new ApiAccessLog(); try { this.buildApiAccessLogDTO(accessLog, request, beginTime, queryString, requestBody, ex); - apiAccessLogFrameworkService.createApiAccessLogAsync(accessLog); + apiAccessLogFrameworkService.createApiAccessLog(accessLog); } catch (Throwable th) { log.error("[createApiAccessLog][url({}) log({}) 发生异常]", request.getRequestURI(), toJsonString(accessLog), th); } } - private void buildApiAccessLogDTO(ApiAccessLogCreateReqDTO accessLog, HttpServletRequest request, Date beginTime, + private void buildApiAccessLogDTO(ApiAccessLog accessLog, HttpServletRequest request, Date beginTime, Map queryString, String requestBody, Exception ex) { // 处理用户信息 accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java new file mode 100644 index 000000000..a92b06c26 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * API 访问日志 + * + * @author 芋道源码 + */ +@Data +public class ApiAccessLog { + + /** + * 链路追踪编号 + */ + private String traceId; + /** + * 用户编号 + */ + private Long userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 应用名 + */ + @NotNull(message = "应用名不能为空") + private String applicationName; + + /** + * 请求方法名 + */ + @NotNull(message = "http 请求方法不能为空") + private String requestMethod; + /** + * 访问地址 + */ + @NotNull(message = "访问地址不能为空") + private String requestUrl; + /** + * 请求参数 + */ + @NotNull(message = "请求参数不能为空") + private String requestParams; + /** + * 用户 IP + */ + @NotNull(message = "ip 不能为空") + private String userIp; + /** + * 浏览器 UA + */ + @NotNull(message = "User-Agent 不能为空") + private String userAgent; + + /** + * 开始请求时间 + */ + @NotNull(message = "开始请求时间不能为空") + private Date beginTime; + /** + * 结束请求时间 + */ + @NotNull(message = "结束请求时间不能为空") + private Date endTime; + /** + * 执行时长,单位:毫秒 + */ + @NotNull(message = "执行时长不能为空") + private Integer duration; + /** + * 结果码 + */ + @NotNull(message = "错误码不能为空") + private Integer resultCode; + /** + * 结果提示 + */ + private String resultMsg; + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java index 71df0f6fb..9bfc3a573 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java @@ -1,9 +1,5 @@ package cn.iocoder.yudao.framework.apilog.core.service; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; - -import javax.validation.Valid; - /** * API 访问日志 Framework Service 接口 * @@ -14,8 +10,8 @@ public interface ApiAccessLogFrameworkService { /** * 创建 API 访问日志 * - * @param createDTO 创建信息 + * @param apiAccessLog API 访问日志 */ - void createApiAccessLogAsync(@Valid ApiAccessLogCreateReqDTO createDTO); + void createApiAccessLog(ApiAccessLog apiAccessLog); } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java new file mode 100644 index 000000000..83162f164 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Async; + +/** + * API 访问日志 Framework Service 实现类 + * + * 基于 {@link ApiAccessLogApi} 服务,记录访问日志 + * + * @author 芋道源码 + */ +@RequiredArgsConstructor +public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkService { + + private final ApiAccessLogApi apiAccessLogApi; + + @Override + @Async + public void createApiAccessLog(ApiAccessLog apiAccessLog) { + ApiAccessLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiAccessLog, ApiAccessLogCreateReqDTO.class); + apiAccessLogApi.createApiAccessLog(reqDTO); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java new file mode 100644 index 000000000..3f5d539cb --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * API 错误日志 + * + * @author 芋道源码 + */ +@Data +public class ApiErrorLog { + + /** + * 链路编号 + */ + private String traceId; + /** + * 账号编号 + */ + private Long userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 应用名 + */ + @NotNull(message = "应用名不能为空") + private String applicationName; + + /** + * 请求方法名 + */ + @NotNull(message = "http 请求方法不能为空") + private String requestMethod; + /** + * 访问地址 + */ + @NotNull(message = "访问地址不能为空") + private String requestUrl; + /** + * 请求参数 + */ + @NotNull(message = "请求参数不能为空") + private String requestParams; + /** + * 用户 IP + */ + @NotNull(message = "ip 不能为空") + private String userIp; + /** + * 浏览器 UA + */ + @NotNull(message = "User-Agent 不能为空") + private String userAgent; + + /** + * 异常时间 + */ + @NotNull(message = "异常时间不能为空") + private Date exceptionTime; + /** + * 异常名 + */ + @NotNull(message = "异常名不能为空") + private String exceptionName; + /** + * 异常发生的类全名 + */ + @NotNull(message = "异常发生的类全名不能为空") + private String exceptionClassName; + /** + * 异常发生的类文件 + */ + @NotNull(message = "异常发生的类文件不能为空") + private String exceptionFileName; + /** + * 异常发生的方法名 + */ + @NotNull(message = "异常发生的方法名不能为空") + private String exceptionMethodName; + /** + * 异常发生的方法所在行 + */ + @NotNull(message = "异常发生的方法所在行不能为空") + private Integer exceptionLineNumber; + /** + * 异常的栈轨迹异常的栈轨迹 + */ + @NotNull(message = "异常的栈轨迹不能为空") + private String exceptionStackTrace; + /** + * 异常导致的根消息 + */ + @NotNull(message = "异常导致的根消息不能为空") + private String exceptionRootCauseMessage; + /** + * 异常导致的消息 + */ + @NotNull(message = "异常导致的消息不能为空") + private String exceptionMessage; + + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java index 9229745d7..403c574bc 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java @@ -1,9 +1,5 @@ package cn.iocoder.yudao.framework.apilog.core.service; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; - -import javax.validation.Valid; - /** * API 错误日志 Framework Service 接口 * @@ -14,8 +10,8 @@ public interface ApiErrorLogFrameworkService { /** * 创建 API 错误日志 * - * @param createDTO 创建信息 + * @param apiErrorLog API 错误日志 */ - void createApiErrorLogAsync(@Valid ApiErrorLogCreateReqDTO createDTO); + void createApiErrorLog(ApiErrorLog apiErrorLog); } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java new file mode 100644 index 000000000..cb5abe3c2 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.framework.apilog.core.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Async; + +/** + * API 错误日志 Framework Service 实现类 + * + * 基于 {@link ApiErrorLogApi} 服务,记录错误日志 + * + * @author 芋道源码 + */ +@RequiredArgsConstructor +public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService { + + private final ApiErrorLogApi apiErrorLogApi; + + @Override + @Async + public void createApiErrorLog(ApiErrorLog apiErrorLog) { + ApiErrorLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiErrorLog, ApiErrorLogCreateReqDTO.class); + apiErrorLogApi.createApiErrorLog(reqDTO); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java index 6ebd29b12..b4b29974c 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.framework.swagger.config; +import cn.iocoder.yudao.framework.swagger.core.SpringFoxHandlerProviderBeanPostProcessor; import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -21,6 +21,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.Collections; import java.util.List; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; import static springfox.documentation.builders.RequestHandlerSelectors.basePackage; /** @@ -38,27 +39,27 @@ import static springfox.documentation.builders.RequestHandlerSelectors.basePacka public class YudaoSwaggerAutoConfiguration { @Bean - @ConditionalOnMissingBean - public SwaggerProperties swaggerProperties() { - return new SwaggerProperties(); + public SpringFoxHandlerProviderBeanPostProcessor springFoxHandlerProviderBeanPostProcessor() { + return new SpringFoxHandlerProviderBeanPostProcessor(); } @Bean - public Docket createRestApi() { - SwaggerProperties properties = swaggerProperties(); + public Docket createRestApi(SwaggerProperties properties) { // 创建 Docket 对象 return new Docket(DocumentationType.SWAGGER_2) - // 用来创建该 API 的基本信息,展示在文档的页面中(自定义展示的信息) + // ① 用来创建该 API 的基本信息,展示在文档的页面中(自定义展示的信息) .apiInfo(apiInfo(properties)) - // 设置扫描指定 package 包下的 + // ② 设置扫描指定 package 包下的 .select() .apis(basePackage(properties.getBasePackage())) -// .apis(basePackage("cn.iocoder.yudao.module.infra")) // 可用于 swagger 无法展示时使用 +// .apis(basePackage("cn.iocoder.yudao.module.system")) // 可用于 swagger 无法展示时使用 .paths(PathSelectors.any()) .build() + // ③ 安全上下文(认证) .securitySchemes(securitySchemes()) - .globalRequestParameters(globalRequestParameters()) - .securityContexts(securityContexts()); + .securityContexts(securityContexts()) + // ④ 全局参数(多租户 header) + .globalRequestParameters(globalRequestParameters()); } // ========== apiInfo ========== @@ -93,6 +94,7 @@ public class YudaoSwaggerAutoConfiguration { private static List securityContexts() { return Collections.singletonList(SecurityContext.builder() .securityReferences(securityReferences()) + // 通过 PathSelectors.regex("^(?!auth).*$"),排除包含 "auth" 的接口不需要使用securitySchemes .forPaths(PathSelectors.regex("^(?!auth).*$")) .build()); } @@ -108,7 +110,8 @@ public class YudaoSwaggerAutoConfiguration { // ========== globalRequestParameters ========== private static List globalRequestParameters() { - RequestParameterBuilder tenantParameter = new RequestParameterBuilder().name("tenant-id").description("租户编号") + RequestParameterBuilder tenantParameter = new RequestParameterBuilder() + .name(HEADER_TENANT_ID).description("租户编号") .in(ParameterType.HEADER).example(new ExampleBuilder().value(1L).build()); return Collections.singletonList(tenantParameter.build()); } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java new file mode 100644 index 000000000..c9d178ac8 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.framework.swagger.core; + +import cn.hutool.core.util.ReflectUtil; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanPostProcessor; +import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; +import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider; +import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; + +import java.util.List; + +/** + * 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题 + * 该问题对应的 issue 为 https://github.com/springfox/springfox/issues/3462 + * + * @author 芋道源码 + */ +public class SpringFoxHandlerProviderBeanPostProcessor implements BeanPostProcessor { + + @Override + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { + if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { + customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); + } + return bean; + } + + private void customizeSpringfoxHandlerMappings(List mappings) { + // 移除,只保留 patternParser + List copy = CollectionUtils.filterList(mappings, mapping -> mapping.getPatternParser() == null); + // 添加到 mappings 中 + mappings.clear(); + mappings.addAll(copy); + } + + @SuppressWarnings("unchecked") + private List getHandlerMappings(Object bean) { + return (List) + ReflectUtil.getFieldValue(bean, "handlerMappings"); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java index 173a67042..03f4d70b6 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/WebProperties.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.framework.web.config; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; @@ -15,14 +17,16 @@ import javax.validation.constraints.NotNull; public class WebProperties { @NotNull(message = "APP API 不能为空") - private Api appApi; + private Api appApi = new Api("/app-api", "**.controller.app.**"); @NotNull(message = "Admin API 不能为空") - private Api adminApi; + private Api adminApi = new Api("/admin-api", "**.controller.admin.**"); @NotNull(message = "Admin UI 不能为空") private Ui adminUi; @Data + @AllArgsConstructor + @NoArgsConstructor @Valid public static class Api { diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java index 578ad76f9..7a0fe6be7 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java @@ -3,14 +3,14 @@ package cn.iocoder.yudao.framework.web.core.handler; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.extra.servlet.ServletUtil; +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog; +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; -import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import io.github.resilience4j.ratelimiter.RequestNotPermitted; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -229,18 +229,18 @@ public class GlobalExceptionHandler { private void createExceptionLog(HttpServletRequest req, Throwable e) { // 插入错误日志 - ApiErrorLogCreateReqDTO errorLog = new ApiErrorLogCreateReqDTO(); + ApiErrorLog errorLog = new ApiErrorLog(); try { // 初始化 errorLog initExceptionLog(errorLog, req, e); // 执行插入 errorLog - apiErrorLogFrameworkService.createApiErrorLogAsync(errorLog); + apiErrorLogFrameworkService.createApiErrorLog(errorLog); } catch (Throwable th) { log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th); } } - private void initExceptionLog(ApiErrorLogCreateReqDTO errorLog, HttpServletRequest request, Throwable e) { + private void initExceptionLog(ApiErrorLog errorLog, HttpServletRequest request, Throwable e) { // 处理用户信息 errorLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); errorLog.setUserType(WebFrameworkUtils.getLoginUserType(request)); diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java index f5ac676fa..e11a3236a 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java @@ -23,7 +23,7 @@ public class WebFrameworkUtils { private static final String REQUEST_ATTRIBUTE_COMMON_RESULT = "common_result"; - private static final String HEADER_TENANT_ID = "tenant-id"; + public static final String HEADER_TENANT_ID = "tenant-id"; private static WebProperties properties; diff --git a/yudao-module-infra/yudao-module-infra-api/pom.xml b/yudao-module-infra/yudao-module-infra-api/pom.xml index f194e82b0..168ea645b 100644 --- a/yudao-module-infra/yudao-module-infra-api/pom.xml +++ b/yudao-module-infra/yudao-module-infra-api/pom.xml @@ -21,6 +21,13 @@ cn.iocoder.boot yudao-common + + + + org.springframework.boot + spring-boot-starter-validation + true + diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java index fa3ec5c6e..c41c6e039 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java @@ -1,7 +1,5 @@ package cn.iocoder.yudao.module.infra.api.file; -import cn.hutool.core.util.IdUtil; - /** * 文件 API 接口 * @@ -15,9 +13,9 @@ public interface FileApi { * @param content 文件内容 * @return 文件路径 */ - default String createFile(byte[] content) throws Exception { - return createFile(IdUtil.fastUUID(), content); - } + default String createFile(byte[] content) { + return createFile(null, null, content); + } /** * 保存文件,并返回文件的访问路径 @@ -26,6 +24,18 @@ public interface FileApi { * @param content 文件内容 * @return 文件路径 */ - String createFile(String path, byte[] content) throws Exception; + default String createFile(String path, byte[] content) { + return createFile(null, path, content); + } + + /** + * 保存文件,并返回文件的访问路径 + * + * @param name 文件名称 + * @param path 文件路径 + * @param content 文件内容 + * @return 文件路径 + */ + String createFile(String name, String path, byte[] content); } diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java new file mode 100644 index 000000000..ed3f3ee1e --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApi.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; + +import javax.validation.Valid; + +/** + * API 访问日志的 API 接口 + * + * @author 芋道源码 + */ +public interface ApiAccessLogApi { + + /** + * 创建 API 访问日志 + * + * @param createDTO 创建信息 + */ + void createApiAccessLog(@Valid ApiAccessLogCreateReqDTO createDTO); + +} diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java new file mode 100644 index 000000000..9b53c6643 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApi.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; + +import javax.validation.Valid; + +/** + * API 错误日志的 API 接口 + * + * @author 芋道源码 + */ +public interface ApiErrorLogApi { + + /** + * 创建 API 错误日志 + * + * @param createDTO 创建信息 + */ + void createApiErrorLog(@Valid ApiErrorLogCreateReqDTO createDTO); + +} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java similarity index 94% rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java rename to yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java index a32f7b346..0ad0ea79c 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiAccessLogCreateReqDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.apilog.core.service.dto; +package cn.iocoder.yudao.module.infra.api.logger.dto; import lombok.Data; @@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull; import java.util.Date; /** - * API 访问日志创建 DTO + * API 访问日志 * * @author 芋道源码 */ diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java similarity index 93% rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java rename to yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java index 70baebc5c..c2d555703 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/logger/dto/ApiErrorLogCreateReqDTO.java @@ -1,18 +1,16 @@ -package cn.iocoder.yudao.framework.apilog.core.service.dto; +package cn.iocoder.yudao.module.infra.api.logger.dto; import lombok.Data; -import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; import java.util.Date; /** - * API 错误日志创建 DTO + * API 错误日志 * * @author 芋道源码 */ @Data -@Accessors(chain = true) public class ApiErrorLogCreateReqDTO { /** @@ -105,4 +103,5 @@ public class ApiErrorLogCreateReqDTO { @NotNull(message = "异常导致的消息不能为空") private String exceptionMessage; + } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java index d43eac1d5..05fb946fe 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java @@ -19,8 +19,8 @@ public class FileApiImpl implements FileApi { private FileService fileService; @Override - public String createFile(String path, byte[] content) throws Exception { - return fileService.createFile(path, content); + public String createFile(String name, String path, byte[] content) { + return fileService.createFile(name, path, content); } } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java new file mode 100644 index 000000000..2daa4a1c4 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiAccessLogApiImpl.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; +import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * API 访问日志的 API 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ApiAccessLogApiImpl implements ApiAccessLogApi { + + @Resource + private ApiAccessLogService apiAccessLogService; + + @Override + public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) { + apiAccessLogService.createApiAccessLog(createDTO); + } + +} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java new file mode 100644 index 000000000..cdb0ec293 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/logger/ApiErrorLogApiImpl.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.infra.api.logger; + +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; +import cn.iocoder.yudao.module.infra.service.logger.ApiErrorLogService; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * API 访问日志的 API 接口 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ApiErrorLogApiImpl implements ApiErrorLogApi { + + @Resource + private ApiErrorLogService apiErrorLogService; + + @Override + public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) { + apiErrorLogService.createApiErrorLog(createDTO); + } + +} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java index 4500133ed..fcdca025f 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java @@ -46,7 +46,7 @@ public class FileController { @OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要 public CommonResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam(value = "path", required = false) String path) throws Exception { - return success(fileService.createFile(path, IoUtil.readBytes(file.getInputStream()))); + return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); } @DeleteMapping("/delete") diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileRespVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileRespVO.java index 8e39a7520..10737693d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileRespVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileRespVO.java @@ -16,6 +16,9 @@ public class FileRespVO { @ApiModelProperty(value = "文件路径", required = true, example = "yudao.jpg") private String path; + @ApiModelProperty(value = "原文件名", required = true, example = "yudao.jpg") + private String name; + @ApiModelProperty(value = "文件 URL", required = true, example = "https://www.iocoder.cn/yudao.jpg") private String url; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java index 7162d4d9a..f3a80e8c0 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.infra.convert.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExcelVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java index 8eef7463a..778e171c7 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.infra.convert.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExcelVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileDO.java index 4ad155e94..7e81280da 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileDO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileDO.java @@ -33,6 +33,10 @@ public class FileDO extends BaseDO { * 关联 {@link FileConfigDO#getId()} */ private Long configId; + /** + * 原文件名 + */ + private String name; /** * 路径,即文件名 */ diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java index 2d893c082..24baf4218 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java @@ -22,11 +22,12 @@ public interface FileService { /** * 保存文件,并返回文件的访问路径 * + * @param name 文件名称 * @param path 文件路径 * @param content 文件内容 * @return 文件路径 */ - String createFile(String path, byte[] content) throws Exception; + String createFile(String name, String path, byte[] content); /** * 删除文件 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java index fc3eedbac..b90e92752 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.file.core.client.FileClient; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper; +import lombok.SneakyThrows; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -37,12 +38,17 @@ public class FileServiceImpl implements FileService { } @Override - public String createFile(String path, byte[] content) throws Exception { + @SneakyThrows + public String createFile(String name, String path, byte[] content) { // 计算默认的 path 名 - String type = FileTypeUtil.getType(new ByteArrayInputStream(content), path); + String type = FileTypeUtil.getType(new ByteArrayInputStream(content), name); if (StrUtil.isEmpty(path)) { path = DigestUtil.md5Hex(content) + '.' + type; } + // 如果 name 为空,则使用 path 填充 + if (StrUtil.isEmpty(name)) { + name = path; + } // 上传到文件存储器 FileClient client = fileConfigService.getMasterFileClient(); @@ -52,6 +58,7 @@ public class FileServiceImpl implements FileService { // 保存到数据库 FileDO file = new FileDO(); file.setConfigId(client.getId()); + file.setName(name); file.setPath(path); file.setUrl(url); file.setType(type); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java index 22aea79b4..e473b2322 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; import java.util.List; @@ -13,7 +13,14 @@ import java.util.List; * * @author 芋道源码 */ -public interface ApiAccessLogService extends ApiAccessLogFrameworkService { +public interface ApiAccessLogService { + + /** + * 创建 API 访问日志 + * + * @param createReqDTO API 访问日志 + */ + void createApiAccessLog(ApiAccessLogCreateReqDTO createReqDTO); /** * 获得 API 访问日志分页 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java index 64df85ac0..e3b3234ee 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java @@ -1,13 +1,12 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -26,6 +25,12 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService { @Resource private ApiAccessLogMapper apiAccessLogMapper; + @Override + public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) { + ApiAccessLogDO apiAccessLog = ApiAccessLogConvert.INSTANCE.convert(createDTO); + apiAccessLogMapper.insert(apiAccessLog); + } + @Override public PageResult getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) { return apiAccessLogMapper.selectPage(pageReqVO); @@ -36,11 +41,4 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService { return apiAccessLogMapper.selectList(exportReqVO); } - @Override - @Async - public void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) { - ApiAccessLogDO apiAccessLog = ApiAccessLogConvert.INSTANCE.convert(createDTO); - apiAccessLogMapper.insert(apiAccessLog); - } - } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java index 2ad0479fe..138c9bef4 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; @@ -13,7 +13,14 @@ import java.util.List; * * @author 芋道源码 */ -public interface ApiErrorLogService extends ApiErrorLogFrameworkService { +public interface ApiErrorLogService { + + /** + * 创建 API 错误日志 + * + * @param createReqDTO API 错误日志 + */ + void createApiErrorLog(ApiErrorLogCreateReqDTO createReqDTO); /** * 获得 API 错误日志分页 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java index 038f47a38..d265f09f6 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java @@ -1,16 +1,15 @@ package cn.iocoder.yudao.module.infra.service.logger; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -30,6 +29,13 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService { @Resource private ApiErrorLogMapper apiErrorLogMapper; + @Override + public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) { + ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO); + apiErrorLog.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); + apiErrorLogMapper.insert(apiErrorLog); + } + @Override public PageResult getApiErrorLogPage(ApiErrorLogPageReqVO pageReqVO) { return apiErrorLogMapper.selectPage(pageReqVO); @@ -54,12 +60,4 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService { .processUserId(processUserId).processTime(new Date()).build()); } - @Override - @Async - public void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) { - ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO); - apiErrorLog.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); - apiErrorLogMapper.insert(apiErrorLog); - } - } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm index 3036c16ed..8b9fbaac2 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm @@ -2,6 +2,12 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac import lombok.*; import java.util.*; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end import io.swagger.annotations.*; import javax.validation.constraints.*; ## 处理 Date 字段的引入 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm index 2ce6f28a8..6b3ea2467 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm @@ -2,6 +2,12 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac import lombok.*; import java.util.*; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end import io.swagger.annotations.*; import com.alibaba.excel.annotation.ExcelProperty; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm index 5c22e388a..4abae1591 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm @@ -2,6 +2,12 @@ package ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.busines import lombok.*; import java.util.*; +#foreach ($column in $columns) +#if (${column.javaType} == "BigDecimal") +import java.math.BigDecimal; +#break +#end +#end import com.baomidou.mybatisplus.annotation.*; import ${BaseDOClassName}; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java index da377e79b..e61039385 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java @@ -80,9 +80,9 @@ public class FileServiceTest extends BaseDbUnitTest { String url = randomString(); when(client.upload(same(content), same(path))).thenReturn(url); when(client.getId()).thenReturn(10L); - + String name = "单测文件名"; // 调用 - String result = fileService.createFile(path, content); + String result = fileService.createFile(name, path, content); // 断言 assertEquals(result, url); // 校验数据 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java index 7ae75d9c4..5f00b3bf5 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.module.infra.service.logger; import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; @@ -155,7 +155,7 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest { dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); // 调用 - apiAccessLogService.createApiAccessLogAsync(createDTO); + apiAccessLogService.createApiAccessLog(createDTO); // 断言 ApiAccessLogDO infApiAccessLogDO = apiAccessLogMapper.selectOne(null); assertNotNull(infApiAccessLogDO); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java index 6c08af886..fbe9ebc05 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java @@ -1,12 +1,12 @@ package cn.iocoder.yudao.module.infra.service.logger; import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; @@ -187,7 +187,7 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest { dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); // 调用 - apiErrorLogService.createApiErrorLogAsync(createDTO); + apiErrorLogService.createApiErrorLog(createDTO); // 断言 ApiErrorLogDO infApiErrorLogDO = infApiErrorLogMapper.selectOne(null); assertNotNull(infApiErrorLogDO); diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/banner/BannerConvert.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/banner/BannerConvert.java index 0e5d66e14..a78650f57 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/banner/BannerConvert.java +++ b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/banner/BannerConvert.java @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerRespVO; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateStatusReqVO; import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -32,5 +31,4 @@ public interface BannerConvert { BannerDO convert(BannerUpdateReqVO updateReqVO); - BannerDO convert(BannerUpdateStatusReqVO updateStatusReqVO); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java index 73577cf6b..755d71a21 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.member.convert.auth; import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO; import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index 44b33fa05..d8c59ad37 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -13,17 +13,17 @@ import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import cn.iocoder.yudao.module.system.api.auth.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCreateReqDTO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.api.logger.LoginLogApi; import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; +import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; import cn.iocoder.yudao.module.system.api.social.SocialUserApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.enums.auth.OAuth2ClientConstants; import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; +import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants; import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import com.google.common.annotations.VisibleForTesting; diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java index 7218e6f1f..805d06aa6 100644 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java +++ b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java @@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.member.controller.app.auth.vo.AppAuthUpdatePasswo import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import cn.iocoder.yudao.module.system.api.auth.OAuth2TokenApi; +import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; import cn.iocoder.yudao.module.system.api.logger.LoginLogApi; import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; import cn.iocoder.yudao.module.system.api.social.SocialUserApi; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java index d228fc3b7..c9b456b90 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.api.dept; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import java.util.Collection; @@ -45,6 +46,9 @@ public interface DeptApi { * @param ids 部门编号数组 * @return 部门 Map */ - Map getDeptMap(Set ids); + default Map getDeptMap(Set ids) { + List list = getDepts(ids); + return CollectionUtils.convertMap(list, DeptRespDTO::getId); + } } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java index 35393a04a..5ba3dfd75 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.system.api.dict; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; + import java.util.Collection; /** @@ -19,4 +21,22 @@ public interface DictDataApi { */ void validDictDatas(String dictType, Collection values); + /** + * 获得指定的字典数据,从缓存中 + * + * @param type 字典类型 + * @param value 字典数据值 + * @return 字典数据 + */ + DictDataRespDTO getDictData(String type, String value); + + /** + * 解析获得指定的字典数据,从缓存中 + * + * @param type 字典类型 + * @param label 字典数据标签 + * @return 字典数据 + */ + DictDataRespDTO parseDictData(String type, String label); + } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/dto/DictDataRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java similarity index 90% rename from yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/dto/DictDataRespDTO.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java index 150ee751e..fe5ab6a21 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/java/cn/iocoder/yudao/framework/dict/core/dto/DictDataRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.dict.core.dto; +package cn.iocoder.yudao.module.system.api.dict.dto; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import lombok.Data; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/service/ErrorCodeFrameworkService.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java similarity index 65% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/service/ErrorCodeFrameworkService.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java index 2d93f75f1..7e504490f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/service/ErrorCodeFrameworkService.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java @@ -1,18 +1,18 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.service; +package cn.iocoder.yudao.module.system.api.errorcode; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeRespDTO; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; import javax.validation.Valid; import java.util.Date; import java.util.List; /** - * 错误码 Framework Service 接口 + * 错误码 Api 接口 * * @author 芋道源码 */ -public interface ErrorCodeFrameworkService { +public interface ErrorCodeApi { /** * 自动创建错误码 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/dto/ErrorCodeAutoGenerateReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/dto/ErrorCodeAutoGenerateReqDTO.java similarity index 90% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/dto/ErrorCodeAutoGenerateReqDTO.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/dto/ErrorCodeAutoGenerateReqDTO.java index 6f5425869..da4df83ca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/dto/ErrorCodeAutoGenerateReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/dto/ErrorCodeAutoGenerateReqDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.dto; +package cn.iocoder.yudao.module.system.api.errorcode.dto; import lombok.Data; import lombok.experimental.Accessors; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/dto/ErrorCodeRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/dto/ErrorCodeRespDTO.java similarity index 83% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/dto/ErrorCodeRespDTO.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/dto/ErrorCodeRespDTO.java index c0b0cbaa3..1f5a27f8a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/core/dto/ErrorCodeRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/dto/ErrorCodeRespDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.framework.errorcode.core.dto; +package cn.iocoder.yudao.module.system.api.errorcode.dto; import lombok.Data; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApi.java new file mode 100644 index 000000000..802cc0a2b --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApi.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.system.api.logger; + +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; + +import javax.validation.Valid; + +/** + * 操作日志 API 接口 + * + * @author 芋道源码 + */ +public interface OperateLogApi { + + /** + * 创建操作日志 + * + * @param createReqDTO 请求 + */ + void createOperateLog(@Valid OperateLogCreateReqDTO createReqDTO); + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java new file mode 100644 index 000000000..80161f77f --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogCreateReqDTO.java @@ -0,0 +1,123 @@ +package cn.iocoder.yudao.module.system.api.logger.dto; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.Map; + +/** + * 操作日志创建 Request DTO + */ +@Data +public class OperateLogCreateReqDTO { + + /** + * 链路追踪编号 + */ + private String traceId; + + /** + * 用户编号 + */ + @NotNull(message = "用户编号不能为空") + private Long userId; + /** + * 用户类型 + */ + @NotNull(message = "用户类型不能为空") + private Integer userType; + + /** + * 操作模块 + */ + @NotEmpty(message = "操作模块不能为空") + private String module; + + /** + * 操作名 + */ + @NotEmpty(message = "操作名") + private String name; + + /** + * 操作分类 + */ + @NotNull(message = "操作分类不能为空") + private Integer type; + + /** + * 操作明细 + */ + private String content; + + /** + * 拓展字段 + */ + private Map exts; + + /** + * 请求方法名 + */ + @NotEmpty(message = "请求方法名不能为空") + private String requestMethod; + + /** + * 请求地址 + */ + @NotEmpty(message = "请求地址不能为空") + private String requestUrl; + + /** + * 用户 IP + */ + @NotEmpty(message = "用户 IP 不能为空") + private String userIp; + + /** + * 浏览器 UserAgent + */ + @NotEmpty(message = "浏览器 UserAgent 不能为空") + private String userAgent; + + /** + * Java 方法名 + */ + @NotEmpty(message = "Java 方法名不能为空") + private String javaMethod; + + /** + * Java 方法的参数 + */ + private String javaMethodArgs; + + /** + * 开始时间 + */ + @NotNull(message = "开始时间不能为空") + private Date startTime; + + /** + * 执行时长,单位:毫秒 + */ + @NotNull(message = "执行时长不能为空") + private Integer duration; + + /** + * 结果码 + */ + @NotNull(message = "结果码不能为空") + private Integer resultCode; + + /** + * 结果提示 + */ + private String resultMsg; + + /** + * 结果数据 + */ + private String resultData; + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/OAuth2TokenApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/OAuth2TokenApi.java similarity index 77% rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/OAuth2TokenApi.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/OAuth2TokenApi.java index 5d0201565..79393cf99 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/OAuth2TokenApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/OAuth2TokenApi.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.module.system.api.auth; +package cn.iocoder.yudao.module.system.api.oauth2; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCheckRespDTO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCreateReqDTO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import javax.validation.Valid; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenCheckRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java similarity index 90% rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenCheckRespDTO.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java index 5b708ff66..319622ba9 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenCheckRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.api.auth.dto; +package cn.iocoder.yudao.module.system.api.oauth2.dto; import lombok.Data; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenCreateReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCreateReqDTO.java similarity index 94% rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenCreateReqDTO.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCreateReqDTO.java index 1d9b793d3..9257cc9ec 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenCreateReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCreateReqDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.api.auth.dto; +package cn.iocoder.yudao.module.system.api.oauth2.dto; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.validation.InEnum; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenRespDTO.java similarity index 91% rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenRespDTO.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenRespDTO.java index 768955594..04c0dbe04 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/auth/dto/OAuth2AccessTokenRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenRespDTO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.api.auth.dto; +package cn.iocoder.yudao.module.system.api.oauth2.dto; import lombok.Data; import lombok.experimental.Accessors; 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 new file mode 100644 index 000000000..3f255d55a --- /dev/null +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.system.api.tenant; + +import java.util.List; + +/** + * 多租户的 API 接口 + * + * @author 芋道源码 + */ +public interface TenantApi { + + /** + * 获得所有租户 + * + * @return 租户编号数组 + */ + List getTenantIds(); + + /** + * 校验租户是否合法 + * + * @param id 租户编号 + */ + void validTenant(Long id); + +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java index d994b0cb3..6c0b7e9d9 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.api.user; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import java.util.Collection; @@ -22,6 +23,14 @@ public interface AdminUserApi { */ AdminUserRespDTO getUser(Long id); + /** + * 通过用户 ID 查询用户们 + * + * @param ids 用户 ID 们 + * @return 用户对象信息 + */ + List getUsers(Collection ids); + /** * 获得指定部门的用户数组 * @@ -44,7 +53,10 @@ public interface AdminUserApi { * @param ids 用户编号数组 * @return 用户 Map */ - Map getUserMap(Collection ids); + default Map getUserMap(Collection ids) { + List users = getUsers(ids); + return CollectionUtils.convertMap(users, AdminUserRespDTO::getId); + } /** * 校验用户们是否有效。如下情况,视为无效: diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/auth/OAuth2ClientConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/oauth2/OAuth2ClientConstants.java similarity index 75% rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/auth/OAuth2ClientConstants.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/oauth2/OAuth2ClientConstants.java index e48e132ff..a123d57b9 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/auth/OAuth2ClientConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/oauth2/OAuth2ClientConstants.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.enums.auth; +package cn.iocoder.yudao.module.system.enums.oauth2; /** * OAuth2.0 客户端的通用枚举 diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/auth/OAuth2GrantTypeEnum.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/oauth2/OAuth2GrantTypeEnum.java similarity index 93% rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/auth/OAuth2GrantTypeEnum.java rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/oauth2/OAuth2GrantTypeEnum.java index 20eb8fce3..80ce4610b 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/auth/OAuth2GrantTypeEnum.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/oauth2/OAuth2GrantTypeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.system.enums.auth; +package cn.iocoder.yudao.module.system.enums.oauth2; import cn.hutool.core.util.ArrayUtil; import lombok.AllArgsConstructor; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java index 27fbc2f13..5721030bb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java @@ -9,8 +9,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Collection; import java.util.List; -import java.util.Map; -import java.util.Set; /** * 部门 API 实现类 @@ -40,10 +38,4 @@ public class DeptApiImpl implements DeptApi { deptService.validDepts(ids); } - @Override - public Map getDeptMap(Set ids) { - Map depts = deptService.getDeptMap(ids); - return DeptConvert.INSTANCE.convertMap(depts); - } - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java index 6db4fb8e0..7de1a43b3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.module.system.api.dict; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; +import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.service.dict.DictDataService; import org.springframework.stereotype.Service; @@ -22,4 +25,16 @@ public class DictDataApiImpl implements DictDataApi { dictDataService.validDictDatas(dictType, values); } + @Override + public DictDataRespDTO getDictData(String dictType, String value) { + DictDataDO dictData = dictDataService.getDictData(dictType, value); + return DictDataConvert.INSTANCE.convert02(dictData); + } + + @Override + public DictDataRespDTO parseDictData(String dictType, String label) { + DictDataDO dictData = dictDataService.parseDictData(dictType, label); + return DictDataConvert.INSTANCE.convert02(dictData); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java new file mode 100644 index 000000000..895aaebcc --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.system.api.errorcode; + +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; +import cn.iocoder.yudao.module.system.service.errorcode.ErrorCodeService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * 错误码 Api 实现类 + * + * @author 芋道源码 + */ +@Service +public class ErrorCodeApiImpl implements ErrorCodeApi { + + @Resource + private ErrorCodeService errorCodeService; + + @Override + public void autoGenerateErrorCodes(List autoGenerateDTOs) { + errorCodeService.autoGenerateErrorCodes(autoGenerateDTOs); + } + + @Override + public List getErrorCodeList(String applicationName, Date minUpdateTime) { + return errorCodeService.getErrorCodeList(applicationName, minUpdateTime); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApiImpl.java new file mode 100644 index 000000000..186f1e098 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApiImpl.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.system.api.logger; + +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; +import cn.iocoder.yudao.module.system.service.logger.OperateLogService; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * 操作日志 API 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class OperateLogApiImpl implements OperateLogApi { + + @Resource + private OperateLogService operateLogService; + + @Override + public void createOperateLog(OperateLogCreateReqDTO createReqDTO) { + operateLogService.createOperateLog(createReqDTO); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/auth/OAuth2TokenApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/OAuth2TokenApiImpl.java similarity index 84% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/auth/OAuth2TokenApiImpl.java rename to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/OAuth2TokenApiImpl.java index 438cf9463..efe4cd5c3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/auth/OAuth2TokenApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/OAuth2TokenApiImpl.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.module.system.api.auth; +package cn.iocoder.yudao.module.system.api.oauth2; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCheckRespDTO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCreateReqDTO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.convert.auth.OAuth2TokenConvert; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java new file mode 100644 index 000000000..6ea4c795e --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.system.api.tenant; + +import cn.iocoder.yudao.module.system.service.tenant.TenantService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 多租户的 API 实现类 + * + * @author 芋道源码 + */ +@Service +public class TenantApiImpl implements TenantApi { + + @Resource + private TenantService tenantService; + + @Override + public List getTenantIds() { + return tenantService.getTenantIds(); + } + + @Override + public void validTenant(Long id) { + tenantService.validTenant(id); + } + +} 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 372e6f5e6..d493b747a 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 @@ -9,7 +9,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Set; /** @@ -29,6 +28,12 @@ public class AdminUserApiImpl implements AdminUserApi { return UserConvert.INSTANCE.convert4(user); } + @Override + public List getUsers(Collection ids) { + List users = userService.getUsers(ids); + return UserConvert.INSTANCE.convertList4(users); + } + @Override public List getUsersByDeptIds(Collection deptIds) { List users = userService.getUsersByDeptIds(deptIds); @@ -41,12 +46,6 @@ public class AdminUserApiImpl implements AdminUserApi { return UserConvert.INSTANCE.convertList4(users); } - @Override - public Map getUserMap(Collection ids) { - Map userMap = userService.getUserMap(ids); - return UserConvert.INSTANCE.convertMap4(userMap); - } - @Override public void validUsers(Set ids) { userService.validUsers(ids); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogBaseVO.java index e8101f6e9..4b5cc22bf 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogBaseVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogBaseVO.java @@ -19,7 +19,7 @@ public class LoginLogBaseVO { @NotNull(message = "日志类型不能为空") private Integer logType; - @ApiModelProperty(value = "链路追踪编号", required = true, example = "89aca178-a370-411c-ae02-3f0d672be4ab") + @ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab") @NotEmpty(message = "链路追踪编号不能为空") private String traceId; @@ -36,8 +36,7 @@ public class LoginLogBaseVO { @NotEmpty(message = "用户 IP 不能为空") private String userIp; - @ApiModelProperty(value = "浏览器 UserAgent", required = true, example = "Mozilla/5.0") - @NotEmpty(message = "浏览器 UserAgent 不能为空") + @ApiModelProperty(value = "浏览器 UserAgent", example = "Mozilla/5.0") private String userAgent; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogRespVO.java index 17177dadf..fd31ff704 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/loginlog/LoginLogRespVO.java @@ -18,8 +18,7 @@ public class LoginLogRespVO extends LoginLogBaseVO { @ApiModelProperty(value = "日志编号", required = true, example = "1024") private Long id; - @ApiModelProperty(value = "用户编号", required = true, example = "666") - @NotNull(message = "用户编号不能为空") + @ApiModelProperty(value = "用户编号", example = "666") private Long userId; @ApiModelProperty(value = "用户类型", required = true, example = "2", notes = "参见 UserTypeEnum 枚举") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenController.java index 45618c4bd..6d8ec452e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenController.java @@ -16,7 +16,7 @@ import cn.iocoder.yudao.module.system.convert.oauth2.OAuth2OpenConvert; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ApproveDO; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.enums.auth.OAuth2GrantTypeEnum; +import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2GrantTypeEnum; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ApproveService; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ClientService; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2GrantService; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserInfoRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserInfoRespVO.java index b513fc3da..ddd7aecc7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserInfoRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserInfoRespVO.java @@ -8,7 +8,7 @@ import lombok.NoArgsConstructor; import java.util.List; -@ApiModel("管理后台 - OAuth2.0 获得用户基本信息 Response VO") +@ApiModel("管理后台 - OAuth2 获得用户基本信息 Response VO") @Data @NoArgsConstructor @AllArgsConstructor diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserUpdateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserUpdateReqVO.java index 991c88a99..16082a75e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserUpdateReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/vo/user/OAuth2UserUpdateReqVO.java @@ -10,7 +10,7 @@ import org.hibernate.validator.constraints.Length; import javax.validation.constraints.Email; import javax.validation.constraints.Size; -@ApiModel("管理后台 - OAuth2.0 更新用户基本信息 Request VO") +@ApiModel("管理后台 - OAuth2 更新用户基本信息 Request VO") @Data @NoArgsConstructor @AllArgsConstructor diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsTemplateController.http b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsTemplateController.http index 3bf59d965..e8213e5cd 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsTemplateController.http +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsTemplateController.http @@ -5,7 +5,8 @@ Content-Type: application/json tenant-id: {{adminTenentId}} { - "code": "test_01", + "templateCode": "test_01", + "mobile": "156016913900", "params": { "key01": "value01", "key02": "value02" diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/OAuth2TokenConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/OAuth2TokenConvert.java index 50a6b977f..17c62f0dd 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/OAuth2TokenConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/OAuth2TokenConvert.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.system.convert.auth; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenCheckRespDTO; -import cn.iocoder.yudao.module.system.api.auth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenRespVO; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; import org.mapstruct.Mapper; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dept/DeptConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dept/DeptConvert.java index 2a514743b..e8ee7cee7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dept/DeptConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dept/DeptConvert.java @@ -31,6 +31,4 @@ public interface DeptConvert { DeptRespDTO convert03(DeptDO bean); - Map convertMap(Map map); - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dict/DictDataConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dict/DictDataConvert.java index 215f252e7..89e4d9e06 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dict/DictDataConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dict/DictDataConvert.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.system.convert.dict; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.*; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -29,6 +29,4 @@ public interface DictDataConvert { DictDataRespDTO convert02(DictDataDO bean); - List convertList03(Collection list); - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/errorcode/ErrorCodeConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/errorcode/ErrorCodeConvert.java index 0402aca8b..436cde66d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/errorcode/ErrorCodeConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/errorcode/ErrorCodeConvert.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.module.system.convert.errorcode; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeExcelVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeRespVO; -import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeRespDTO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeUpdateReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java index 21f7a4948..e32ebd091 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java index 2e8a47336..9a2aac3c5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java @@ -14,7 +14,6 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; import java.util.List; -import java.util.Map; @Mapper public interface UserConvert { @@ -53,6 +52,4 @@ public interface UserConvert { List convertList4(List users); - Map convertMap4(Map map); - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/oauth2/OAuth2ClientDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/oauth2/OAuth2ClientDO.java index 7264f6c41..721a42e91 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/oauth2/OAuth2ClientDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/oauth2/OAuth2ClientDO.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.dal.dataobject.oauth2; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.system.enums.auth.OAuth2GrantTypeEnum; +import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2GrantTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java index 845f21db9..234c4acca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java @@ -8,11 +8,9 @@ import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPage import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; import java.util.Arrays; import java.util.Collection; -import java.util.Date; import java.util.List; @Mapper @@ -23,6 +21,11 @@ public interface DictDataMapper extends BaseMapperX { .eq(DictDataDO::getValue, value)); } + default DictDataDO selectByDictTypeAndLabel(String dictType, String label) { + return selectOne(new LambdaQueryWrapper().eq(DictDataDO::getDictType, dictType) + .eq(DictDataDO::getLabel, label)); + } + default List selectByDictTypeAndValues(String dictType, Collection values) { return selectList(new LambdaQueryWrapper().eq(DictDataDO::getDictType, dictType) .in(DictDataDO::getValue, values)); @@ -46,7 +49,4 @@ public interface DictDataMapper extends BaseMapperX { .eqIfPresent(DictDataDO::getStatus, reqVO.getStatus())); } - @Select("SELECT COUNT(*) FROM system_dict_data WHERE update_time > #{maxUpdateTime}") - Long selectCountByUpdateTimeGt(Date maxUpdateTime); - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/package-info.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/package-info.java deleted file mode 100644 index 012bcb33c..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/errorcode/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 错误码组件 - * - * 将错误码缓存在内存中,同时通过定时器每 n 分钟更新 - */ -package cn.iocoder.yudao.module.system.framework.errorcode; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/dict/DictDataRefreshConsumer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/dict/DictDataRefreshConsumer.java deleted file mode 100644 index e466f96b2..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/dict/DictDataRefreshConsumer.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.system.mq.consumer.dict; - -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; -import cn.iocoder.yudao.module.system.mq.message.dict.DictDataRefreshMessage; -import cn.iocoder.yudao.module.system.service.dict.DictDataService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 针对 {@link DictDataRefreshMessage} 的消费者 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class DictDataRefreshConsumer extends AbstractChannelMessageListener { - - @Resource - private DictDataService dictDataService; - - @Override - public void onMessage(DictDataRefreshMessage message) { - log.info("[onMessage][收到 DictData 刷新消息]"); - dictDataService.initLocalCache(); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/tenant/TenantRefreshConsumer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/tenant/TenantRefreshConsumer.java deleted file mode 100644 index 5bc008ace..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/tenant/TenantRefreshConsumer.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.system.mq.consumer.tenant; - -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; -import cn.iocoder.yudao.module.system.mq.message.tenant.TenantRefreshMessage; -import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 针对 {@link cn.iocoder.yudao.module.system.mq.message.tenant.TenantRefreshMessage} 的消费者 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class TenantRefreshConsumer extends AbstractChannelMessageListener { - - @Resource - private TenantService tenantService; - - @Override - public void onMessage(TenantRefreshMessage message) { - log.info("[onMessage][收到 Tenant 刷新消息]"); - tenantService.initLocalCache(); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/dict/DictDataRefreshMessage.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/dict/DictDataRefreshMessage.java deleted file mode 100644 index 01e5b8605..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/dict/DictDataRefreshMessage.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.system.mq.message.dict; - -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 字典数据数据刷新 Message - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class DictDataRefreshMessage extends AbstractChannelMessage { - - @Override - public String getChannel() { - return "system.dict-data.refresh"; - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/tenant/TenantRefreshMessage.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/tenant/TenantRefreshMessage.java deleted file mode 100644 index 19092a4bb..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/tenant/TenantRefreshMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.system.mq.message.tenant; - -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 租户数据刷新 Message - * - * @author 芋道源码 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class TenantRefreshMessage extends AbstractChannelMessage { - - @Override - public String getChannel() { - return "system.tenant.refresh"; - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/dict/DictDataProducer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/dict/DictDataProducer.java deleted file mode 100644 index fa90c8c42..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/dict/DictDataProducer.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.system.mq.producer.dict; - -import cn.iocoder.yudao.module.system.mq.message.dict.DictDataRefreshMessage; -import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * DictData 字典数据相关消息的 Producer - */ -@Component -public class DictDataProducer { - - @Resource - private RedisMQTemplate redisMQTemplate; - - /** - * 发送 {@link DictDataRefreshMessage} 消息 - */ - public void sendDictDataRefreshMessage() { - DictDataRefreshMessage message = new DictDataRefreshMessage(); - redisMQTemplate.send(message); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/tenant/TenantProducer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/tenant/TenantProducer.java deleted file mode 100644 index eaa9f658d..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/tenant/TenantProducer.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.system.mq.producer.tenant; - -import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate; -import cn.iocoder.yudao.module.system.mq.message.permission.RoleRefreshMessage; -import cn.iocoder.yudao.module.system.mq.message.tenant.TenantRefreshMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * Tenant 租户相关消息的 Producer - * - * @author 芋道源码 - */ -@Component -public class TenantProducer { - - @Resource - private RedisMQTemplate redisMQTemplate; - - /** - * 发送 {@link RoleRefreshMessage} 消息 - */ - public void sendTenantRefreshMessage() { - TenantRefreshMessage message = new TenantRefreshMessage(); - redisMQTemplate.send(message); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index 03f600110..517e058f1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; import cn.iocoder.yudao.module.system.convert.auth.AuthConvert; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.enums.auth.OAuth2ClientConstants; +import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants; import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; @@ -229,7 +229,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { reqDTO.setTraceId(TracerUtils.getTraceId()); reqDTO.setUserId(userId); reqDTO.setUserType(userType); - if (ObjectUtil.notEqual(getUserType(), userType)) { + if (ObjectUtil.equal(getUserType().getValue(), userType)) { reqDTO.setUsername(getUsername(userId)); } else { reqDTO.setUsername(memberService.getMemberUserMobile(userId)); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java index db1a1b624..610fe2a33 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java @@ -1,12 +1,11 @@ package cn.iocoder.yudao.module.system.service.dict; -import cn.iocoder.yudao.framework.dict.core.service.DictDataFrameworkService; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataUpdateReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import java.util.Collection; import java.util.List; @@ -16,12 +15,7 @@ import java.util.List; * * @author ruoyi */ -public interface DictDataService extends DictDataFrameworkService { - - /** - * 初始化字典数据的本地缓存 - */ - void initLocalCache(); +public interface DictDataService { /** * 创建字典数据 @@ -94,4 +88,21 @@ public interface DictDataService extends DictDataFrameworkService { */ void validDictDatas(String dictType, Collection values); + /** + * 获得指定的字典数据 + * + * @param dictType 字典类型 + * @param value 字典数据值 + * @return 字典数据 + */ + DictDataDO getDictData(String dictType, String value); + + /** + * 解析获得指定的字典数据,从缓存中 + * + * @param dictType 字典类型 + * @param label 字典数据标签 + * @return 字典数据 + */ + DictDataDO parseDictData(String dictType, String label); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java index 9c38a368b..0cfdb2b99 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; @@ -13,20 +12,15 @@ import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; import cn.iocoder.yudao.module.system.dal.mysql.dict.DictDataMapper; -import cn.iocoder.yudao.module.system.mq.producer.dict.DictDataProducer; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableTable; import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.Collection; import java.util.Comparator; -import java.util.Date; import java.util.List; +import java.util.Map; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; @@ -47,88 +41,12 @@ public class DictDataServiceImpl implements DictDataService { .comparing(DictDataDO::getDictType) .thenComparingInt(DictDataDO::getSort); - /** - * 定时执行 {@link #schedulePeriodicRefresh()} 的周期 - * 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高 - */ - private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L; - @Resource private DictTypeService dictTypeService; @Resource private DictDataMapper dictDataMapper; - @Resource - private DictDataProducer dictDataProducer; - - /** - * 字典数据缓存,第二个 key 使用 label - * - * key1:字典类型 dictType - * key2:字典标签 label - */ - private ImmutableTable labelDictDataCache; - /** - * 字典数据缓存,第二个 key 使用 value - * - * key1:字典类型 dictType - * key2:字典值 value - */ - private ImmutableTable valueDictDataCache; - /** - * 缓存字典数据的最大更新时间,用于后续的增量轮询,判断是否有更新 - */ - private volatile Date maxUpdateTime; - - @Override - @PostConstruct - public synchronized void initLocalCache() { - // 获取字典数据列表,如果有更新 - List dataList = loadDictDataIfUpdate(maxUpdateTime); - if (CollUtil.isEmpty(dataList)) { - return; - } - - // 构建缓存 - ImmutableTable.Builder labelDictDataBuilder = ImmutableTable.builder(); - ImmutableTable.Builder valueDictDataBuilder = ImmutableTable.builder(); - dataList.forEach(dictData -> { - labelDictDataBuilder.put(dictData.getDictType(), dictData.getLabel(), dictData); - valueDictDataBuilder.put(dictData.getDictType(), dictData.getValue(), dictData); - }); - labelDictDataCache = labelDictDataBuilder.build(); - valueDictDataCache = valueDictDataBuilder.build(); - maxUpdateTime = CollectionUtils.getMaxValue(dataList, DictDataDO::getUpdateTime); - log.info("[initLocalCache][缓存字典数据,数量为:{}]", dataList.size()); - } - - /** - * 如果字典数据发生变化,从数据库中获取最新的全量字典数据。 - * 如果未发生变化,则返回空 - * - * @param maxUpdateTime 当前字典数据的最大更新时间 - * @return 字典数据列表 - */ - private List loadDictDataIfUpdate(Date maxUpdateTime) { - // 第一步,判断是否要更新。 - if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 - log.info("[loadDictDataIfUpdate][首次加载全量字典数据]"); - } else { // 判断数据库中是否有更新的字典数据 - if (dictDataMapper.selectCountByUpdateTimeGt(maxUpdateTime) == 0) { - return null; - } - log.info("[loadDictDataIfUpdate][增量加载全量字典数据]"); - } - // 第二步,如果有更新,则从数据库加载所有字典数据 - return dictDataMapper.selectList(); - } - - @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD) - public void schedulePeriodicRefresh() { - initLocalCache(); - } - @Override public List getDictDatas() { List list = dictDataMapper.selectList(); @@ -153,21 +71,6 @@ public class DictDataServiceImpl implements DictDataService { return dictDataMapper.selectById(id); } - @Override - public DictDataRespDTO getDictDataFromCache(String type, String value) { - return DictDataConvert.INSTANCE.convert02(valueDictDataCache.get(type, value)); - } - - @Override - public DictDataRespDTO parseDictDataFromCache(String type, String label) { - return DictDataConvert.INSTANCE.convert02(labelDictDataCache.get(type, label)); - } - - @Override - public List listDictDatasFromCache(String type) { - return DictDataConvert.INSTANCE.convertList03(labelDictDataCache.row(type).values()); - } - @Override public Long createDictData(DictDataCreateReqVO reqVO) { // 校验正确性 @@ -176,9 +79,6 @@ public class DictDataServiceImpl implements DictDataService { // 插入字典类型 DictDataDO dictData = DictDataConvert.INSTANCE.convert(reqVO); dictDataMapper.insert(dictData); - - // 发送刷新消息 - dictDataProducer.sendDictDataRefreshMessage(); return dictData.getId(); } @@ -190,9 +90,6 @@ public class DictDataServiceImpl implements DictDataService { // 更新字典类型 DictDataDO updateObj = DictDataConvert.INSTANCE.convert(reqVO); dictDataMapper.updateById(updateObj); - - // 发送刷新消息 - dictDataProducer.sendDictDataRefreshMessage(); } @Override @@ -202,9 +99,6 @@ public class DictDataServiceImpl implements DictDataService { // 删除字典数据 dictDataMapper.deleteById(id); - - // 发送刷新消息 - dictDataProducer.sendDictDataRefreshMessage(); } @Override @@ -264,7 +158,8 @@ public class DictDataServiceImpl implements DictDataService { if (CollUtil.isEmpty(values)) { return; } - ImmutableMap dictDataMap = valueDictDataCache.row(dictType); + Map dictDataMap = CollectionUtils.convertMap( + dictDataMapper.selectByDictTypeAndValues(dictType, values), DictDataDO::getValue); // 校验 values.forEach(value -> { DictDataDO dictData = dictDataMap.get(value); @@ -277,4 +172,14 @@ public class DictDataServiceImpl implements DictDataService { }); } + @Override + public DictDataDO getDictData(String dictType, String value) { + return dictDataMapper.selectByDictTypeAndValue(dictType, value); + } + + @Override + public DictDataDO parseDictData(String dictType, String label) { + return dictDataMapper.selectByDictTypeAndLabel(dictType, label); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeService.java index 18875f628..8536a262d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeService.java @@ -1,14 +1,16 @@ package cn.iocoder.yudao.module.system.service.errorcode; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.service.ErrorCodeFrameworkService; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeUpdateReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; import javax.validation.Valid; +import java.util.Date; import java.util.List; /** @@ -16,7 +18,25 @@ import java.util.List; * * @author 芋道源码 */ -public interface ErrorCodeService extends ErrorCodeFrameworkService { +public interface ErrorCodeService { + + /** + * 自动创建错误码 + * + * @param autoGenerateDTOs 错误码信息 + */ + void autoGenerateErrorCodes(@Valid List autoGenerateDTOs); + + /** + * 增量获得错误码数组 + * + * 如果 minUpdateTime 为空时,则获取所有错误码 + * + * @param applicationName 应用名 + * @param minUpdateTime 最小更新时间 + * @return 错误码数组 + */ + List getErrorCodeList(String applicationName, Date minUpdateTime); /** * 创建错误码 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceImpl.java index a34f098cd..2997e32ec 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceImpl.java @@ -2,14 +2,14 @@ package cn.iocoder.yudao.module.system.service.errorcode; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeCreateReqVO; -import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeUpdateReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeRespDTO; -import cn.iocoder.yudao.module.system.convert.errorcode.ErrorCodeConvert; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodePageReqVO; +import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeUpdateReqVO; +import cn.iocoder.yudao.module.system.convert.errorcode.ErrorCodeConvert; +import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; import cn.iocoder.yudao.module.system.dal.mysql.errorcode.ErrorCodeMapper; import cn.iocoder.yudao.module.system.enums.errorcode.ErrorCodeTypeEnum; import com.google.common.annotations.VisibleForTesting; @@ -24,9 +24,10 @@ import java.util.List; import java.util.Map; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_DUPLICATE; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_NOT_EXISTS; /** * 错误码 Service 实现类 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogService.java index 4ec2d8f01..224a83f19 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogService.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.system.service.logger; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.operatelog.core.service.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkService; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; @@ -10,8 +12,17 @@ import java.util.List; /** * 操作日志 Service 接口 + * + * @author 芋道源码 */ -public interface OperateLogService extends OperateLogFrameworkService { +public interface OperateLogService { + + /** + * 记录操作日志 + * + * @param createReqDTO 操作日志请求 + */ + void createOperateLog(OperateLogCreateReqDTO createReqDTO); /** * 获得操作日志分页列表 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java index 48f1b5b15..8ae3d139b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO; import cn.iocoder.yudao.module.system.convert.logger.OperateLogConvert; @@ -13,8 +13,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.mysql.logger.OperateLogMapper; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -22,7 +20,6 @@ import javax.annotation.Resource; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.concurrent.Future; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO.JAVA_METHOD_ARGS_MAX_LENGTH; @@ -40,19 +37,11 @@ public class OperateLogServiceImpl implements OperateLogService { private AdminUserService userService; @Override - @Async - public Future createOperateLogAsync(OperateLogCreateReqDTO reqVO) { - boolean success = false; - try { - OperateLogDO logDO = OperateLogConvert.INSTANCE.convert(reqVO); - logDO.setJavaMethodArgs(StrUtils.maxLength(logDO.getJavaMethodArgs(), JAVA_METHOD_ARGS_MAX_LENGTH)); - logDO.setResultData(StrUtils.maxLength(logDO.getResultData(), RESULT_MAX_LENGTH)); - success = operateLogMapper.insert(logDO) == 1; - } catch (Throwable throwable) { - // 仅仅打印日志,不对外抛出。原因是,还是要保留现场数据。 - log.error("[createOperateLogAsync][记录操作日志异常,日志为 ({})]", reqVO, throwable); - } - return new AsyncResult<>(success); + public void createOperateLog(OperateLogCreateReqDTO createReqDTO) { + OperateLogDO logDO = OperateLogConvert.INSTANCE.convert(createReqDTO); + logDO.setJavaMethodArgs(StrUtils.maxLength(logDO.getJavaMethodArgs(), JAVA_METHOD_ARGS_MAX_LENGTH)); + logDO.setResultData(StrUtils.maxLength(logDO.getResultData(), RESULT_MAX_LENGTH)); + operateLogMapper.insert(logDO); } @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java index 608985454..bd2f1d409 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java @@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; +import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; @@ -40,7 +41,8 @@ public class SmsSendServiceImpl implements SmsSendService { private AdminUserService adminUserService; @Resource private MemberService memberService; - + @Resource + private SmsChannelService smsChannelService; @Resource private SmsTemplateService smsTemplateService; @Resource @@ -80,13 +82,18 @@ public class SmsSendServiceImpl implements SmsSendService { String templateCode, Map templateParams) { // 校验短信模板是否合法 SmsTemplateDO template = this.checkSmsTemplateValid(templateCode); + // 校验短信渠道是否合法 + SmsChannelDO smsChannel = this.checkSmsChannelValid(template.getChannelId()); + // 校验手机号码是否存在 mobile = this.checkMobile(mobile); // 构建有序的模板参数。为什么放在这个位置,是提前保证模板参数的正确性,而不是到了插入发送日志 List> newTemplateParams = this.buildTemplateParams(template, templateParams); // 创建发送日志。如果模板被禁用,则不发送短信,只记录日志 - Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()); + Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()) + && CommonStatusEnum.ENABLE.getStatus().equals(smsChannel.getStatus()); + ; String content = smsTemplateService.formatSmsTemplateContent(template.getContent(), templateParams); Long sendLogId = smsLogService.createSmsLog(mobile, userId, userType, isSend, template, content, templateParams); @@ -98,6 +105,16 @@ public class SmsSendServiceImpl implements SmsSendService { return sendLogId; } + @VisibleForTesting + public SmsChannelDO checkSmsChannelValid(Long channelId) { + // 获得短信模板。考虑到效率,从缓存中获取 + SmsChannelDO channelDO = smsChannelService.getSmsChannel(channelId); + // 短信模板不存在 + if (channelDO == null) { + throw exception(SMS_SEND_TEMPLATE_NOT_EXISTS); + } + return channelDO; + } @VisibleForTesting public SmsTemplateDO checkSmsTemplateValid(String templateCode) { @@ -112,10 +129,10 @@ public class SmsSendServiceImpl implements SmsSendService { /** * 将参数模板,处理成有序的 KeyValue 数组 - * + *

* 原因是,部分短信平台并不是使用 key 作为参数,而是数组下标,例如说腾讯云 https://cloud.tencent.com/document/product/382/39023 * - * @param template 短信模板 + * @param template 短信模板 * @param templateParams 原始参数 * @return 处理后的参数 */ diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java index 1743991d8..d9d55e9f4 100755 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.service.tenant; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; @@ -20,12 +19,7 @@ import java.util.Set; * * @author 芋道源码 */ -public interface TenantService extends TenantFrameworkService { - - /** - * 初始化租户的本地缓存 - */ - void initLocalCache(); +public interface TenantService { /** * 创建租户 @@ -120,4 +114,18 @@ public interface TenantService extends TenantFrameworkService { * @param handler 处理器 */ void handleTenantMenu(TenantMenuHandler handler); + + /** + * 获得所有租户 + * + * @return 租户编号数组 + */ + List getTenantIds(); + + /** + * 校验租户是否合法 + * + * @param id 租户编号 + */ + void validTenant(Long id); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java index 160ffe824..dc4a67ef0 100755 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java @@ -23,31 +23,25 @@ import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper; import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; -import cn.iocoder.yudao.module.system.mq.producer.tenant.TenantProducer; import cn.iocoder.yudao.module.system.service.permission.MenuService; import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.permission.RoleService; import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; import javax.annotation.Resource; -import java.util.*; +import java.util.List; +import java.util.Objects; +import java.util.Set; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertImmutableMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; import static java.util.Collections.singleton; @@ -61,26 +55,6 @@ import static java.util.Collections.singleton; @Slf4j public class TenantServiceImpl implements TenantService { - /** - * 定时执行 {@link #schedulePeriodicRefresh()} 的周期 - * 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高 - */ - private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L; - - /** - * 角色缓存 - * key:角色编号 {@link RoleDO#getId()} - * - * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 - */ - @Getter - private volatile Map tenantCache; - /** - * 缓存角色的最大更新时间,用于后续的增量轮询,判断是否有更新 - */ - @Getter - private volatile Date maxUpdateTime; - @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") @Autowired(required = false) // 由于 yudao.tenant.enable 配置项,可以关闭多租户的功能,所以这里只能不强制注入 private TenantProperties tenantProperties; @@ -100,61 +74,15 @@ public class TenantServiceImpl implements TenantService { @Resource private PermissionService permissionService; - @Resource - private TenantProducer tenantProducer; - - /** - * 初始化 {@link #tenantCache} 缓存 - */ - @Override - @PostConstruct - public void initLocalCache() { - // 获取租户列表,如果有更新 - List tenantList = loadTenantIfUpdate(maxUpdateTime); - if (CollUtil.isEmpty(tenantList)) { - return; - } - - // 写入缓存 - tenantCache = convertImmutableMap(tenantList, TenantDO::getId); - maxUpdateTime = getMaxValue(tenantList, TenantDO::getUpdateTime); - log.info("[initLocalCache][初始化 Tenant 数量为 {}]", tenantList.size()); - } - - @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD) - public void schedulePeriodicRefresh() { - initLocalCache(); - } - - /** - * 如果租户发生变化,从数据库中获取最新的全量租户。 - * 如果未发生变化,则返回空 - * - * @param maxUpdateTime 当前租户的最大更新时间 - * @return 租户列表 - */ - private List loadTenantIfUpdate(Date maxUpdateTime) { - // 第一步,判断是否要更新。 - if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 - log.info("[loadTenantIfUpdate][首次加载全量租户]"); - } else { // 判断数据库中是否有更新的租户 - if (tenantMapper.selectCountByUpdateTimeGt(maxUpdateTime) == 0) { - return null; - } - log.info("[loadTenantIfUpdate][增量加载全量租户]"); - } - // 第二步,如果有更新,则从数据库加载所有租户 - return tenantMapper.selectList(); - } - @Override public List getTenantIds() { - return new ArrayList<>(tenantCache.keySet()); + List tenants = tenantMapper.selectList(); + return CollectionUtils.convertList(tenants, TenantDO::getId); } @Override public void validTenant(Long id) { - TenantDO tenant = tenantCache.get(id); + TenantDO tenant = getTenant(id); if (tenant == null) { throw exception(TENANT_NOT_EXISTS); } @@ -184,13 +112,6 @@ public class TenantServiceImpl implements TenantService { // 修改租户的管理员 tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId)); }); - // 发送刷新消息 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - tenantProducer.sendTenantRefreshMessage(); - } - }); return tenant.getId(); } @@ -228,13 +149,6 @@ public class TenantServiceImpl implements TenantService { if (ObjectUtil.notEqual(tenant.getPackageId(), updateReqVO.getPackageId())) { updateTenantRoleMenu(tenant.getId(), tenantPackage.getMenuIds()); } - // 发送刷新消息 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - tenantProducer.sendTenantRefreshMessage(); - } - }); } @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java index 7720327e0..3e6cc282e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java @@ -14,7 +14,7 @@ import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2Open import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ApproveDO; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.enums.auth.OAuth2GrantTypeEnum; +import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2GrantTypeEnum; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ApproveService; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ClientService; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2GrantService; @@ -77,7 +77,7 @@ public class OAuth2OpenControllerTest extends BaseMockitoUnitTest { // mock 方法(访问令牌) OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(addTime(Duration.ofMillis(30010L))); // 多给 10 毫秒,保证可执行完 + .setExpiresTime(addTime(Duration.ofMillis(30050L))); // 多给 10 毫秒,保证可执行完 when(oauth2GrantService.grantAuthorizationCodeForAccessToken(eq("test_client_id"), eq(code), eq(redirectUri), eq(state))).thenReturn(accessTokenDO); @@ -105,7 +105,7 @@ public class OAuth2OpenControllerTest extends BaseMockitoUnitTest { // mock 方法(访问令牌) OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(addTime(Duration.ofMillis(30010L))); // 多给 10 毫秒,保证可执行完 + .setExpiresTime(addTime(Duration.ofMillis(30050L))); // 多给 10 毫秒,保证可执行完 when(oauth2GrantService.grantPassword(eq(username), eq(password), eq("test_client_id"), eq(Lists.newArrayList("write", "read")))).thenReturn(accessTokenDO); diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceTest.java index b20b33aaf..bf38bace1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceTest.java @@ -1,36 +1,32 @@ package cn.iocoder.yudao.module.system.service.dict; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataUpdateReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; import cn.iocoder.yudao.module.system.dal.mysql.dict.DictDataMapper; -import cn.iocoder.yudao.module.system.mq.producer.dict.DictDataProducer; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import com.google.common.collect.ImmutableTable; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import java.util.Date; import java.util.List; import java.util.function.Consumer; -import static cn.hutool.core.bean.BeanUtil.getFieldValue; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; @Import(DictDataServiceImpl.class) public class DictDataServiceTest extends BaseDbUnitTest { @@ -42,39 +38,6 @@ public class DictDataServiceTest extends BaseDbUnitTest { private DictDataMapper dictDataMapper; @MockBean private DictTypeService dictTypeService; - @MockBean - private DictDataProducer dictDataProducer; - - /** - * 测试加载到新的字典数据的情况 - */ - @Test - @SuppressWarnings("unchecked") - public void testInitLocalCache() { - // mock 数据 - DictDataDO dictData01 = randomDictDataDO(); - dictDataMapper.insert(dictData01); - DictDataDO dictData02 = randomDictDataDO(); - dictDataMapper.insert(dictData02); - - // 调用 - dictDataService.initLocalCache(); - // 断言 labelDictDataCache 缓存 - ImmutableTable labelDictDataCache = - (ImmutableTable) getFieldValue(dictDataService, "labelDictDataCache"); - assertEquals(2, labelDictDataCache.size()); - assertPojoEquals(dictData01, labelDictDataCache.get(dictData01.getDictType(), dictData01.getLabel())); - assertPojoEquals(dictData02, labelDictDataCache.get(dictData02.getDictType(), dictData02.getLabel())); - // 断言 valueDictDataCache 缓存 - ImmutableTable valueDictDataCache = - (ImmutableTable) getFieldValue(dictDataService, "valueDictDataCache"); - assertEquals(2, valueDictDataCache.size()); - assertPojoEquals(dictData01, valueDictDataCache.get(dictData01.getDictType(), dictData01.getValue())); - assertPojoEquals(dictData02, valueDictDataCache.get(dictData02.getDictType(), dictData02.getValue())); - // 断言 maxUpdateTime 缓存 - Date maxUpdateTime = (Date) getFieldValue(dictDataService, "maxUpdateTime"); - assertEquals(ObjectUtils.max(dictData01.getUpdateTime(), dictData02.getUpdateTime()), maxUpdateTime); - } @Test public void testGetDictDataPage() { @@ -148,8 +111,6 @@ public class DictDataServiceTest extends BaseDbUnitTest { // 校验记录的属性是否正确 DictDataDO dictData = dictDataMapper.selectById(dictDataId); assertPojoEquals(reqVO, dictData); - // 校验调用 - verify(dictDataProducer, times(1)).sendDictDataRefreshMessage(); } @Test @@ -170,8 +131,6 @@ public class DictDataServiceTest extends BaseDbUnitTest { // 校验是否更新正确 DictDataDO dictData = dictDataMapper.selectById(reqVO.getId()); // 获取最新的 assertPojoEquals(reqVO, dictData); - // 校验调用 - verify(dictDataProducer, times(1)).sendDictDataRefreshMessage(); } @Test @@ -186,8 +145,6 @@ public class DictDataServiceTest extends BaseDbUnitTest { dictDataService.deleteDictData(id); // 校验数据不存在了 assertNull(dictDataMapper.selectById(id)); - // 校验调用 - verify(dictDataProducer, times(1)).sendDictDataRefreshMessage(); } @Test diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java index 37d542c14..717640525 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java @@ -1,17 +1,17 @@ package cn.iocoder.yudao.module.system.service.errorcode; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.yudao.module.system.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeUpdateReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; import cn.iocoder.yudao.module.system.dal.mysql.errorcode.ErrorCodeMapper; import cn.iocoder.yudao.module.system.enums.errorcode.ErrorCodeTypeEnum; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import org.assertj.core.util.Lists; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; @@ -21,12 +21,12 @@ import java.util.List; import java.util.function.Consumer; import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_DUPLICATE; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_NOT_EXISTS; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_DUPLICATE; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; @Import(ErrorCodeServiceImpl.class) diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java index 8e6d742c2..f1b043524 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java @@ -7,9 +7,10 @@ import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstant import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; @@ -17,7 +18,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.mysql.logger.OperateLogMapper; import cn.iocoder.yudao.module.system.enums.common.SexEnum; import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; @@ -25,8 +25,6 @@ import org.springframework.context.annotation.Import; import javax.annotation.Resource; import java.util.Collections; import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import static cn.hutool.core.util.RandomUtil.randomEle; import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; @@ -49,7 +47,7 @@ public class OperateLogServiceImplTest extends BaseDbUnitTest { private AdminUserService userService; @Test - public void testCreateOperateLogAsync() throws InterruptedException, ExecutionException { + public void testCreateOperateLogAsync() { String traceId = TracerUtils.getTraceId(); OperateLogCreateReqDTO reqVO = RandomUtils.randomPojo(OperateLogCreateReqDTO.class, o -> { o.setTraceId(traceId); @@ -59,8 +57,7 @@ public class OperateLogServiceImplTest extends BaseDbUnitTest { }); // 执行service方法 - Future future = operateLogServiceImpl.createOperateLogAsync(reqVO); - future.get(); + operateLogServiceImpl.createOperateLog(reqVO); // 断言插入是否正确 OperateLogDO sysOperateLogDO = operateLogMapper.selectOne("trace_id", traceId); assertPojoEquals(reqVO, sysOperateLogDO); diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java index 37ff97fda..61daa866f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.system.service.tenant; -import cn.hutool.core.util.ReflectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.tenant.config.TenantProperties; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; @@ -16,14 +16,12 @@ import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper; import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; -import cn.iocoder.yudao.module.system.mq.producer.tenant.TenantProducer; import cn.iocoder.yudao.module.system.service.permission.MenuService; import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.permission.RoleService; import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; @@ -34,13 +32,11 @@ import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Map; import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.addTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.max; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; @@ -78,43 +74,18 @@ public class TenantServiceImplTest extends BaseDbUnitTest { private MenuService menuService; @MockBean private PermissionService permissionService; - @MockBean - private TenantProducer tenantProducer; @BeforeEach public void setUp() { - // 清理缓存 - ReflectUtil.setFieldValue(tenantService, "tenantCache", Collections.emptyMap()); - ReflectUtil.setFieldValue(tenantService, "maxUpdateTime", null); // 清理租户上下文 TenantContextHolder.clear(); } - @Test - public void testInitLocalCache() { - // mock 数据 - TenantDO tenantDO1 = randomPojo(TenantDO.class); - tenantMapper.insert(tenantDO1); - TenantDO tenantDO2 = randomPojo(TenantDO.class); - tenantMapper.insert(tenantDO2); - - // 调用 - tenantService.initLocalCache(); - // 断言 tenantCache 缓存 - Map tenantCache = tenantService.getTenantCache(); - assertEquals(2, tenantCache.size()); - assertPojoEquals(tenantDO1, tenantCache.get(tenantDO1.getId())); - assertPojoEquals(tenantDO2, tenantCache.get(tenantDO2.getId())); - // 断言 maxUpdateTime 缓存 - assertEquals(max(tenantDO1.getUpdateTime(), tenantDO2.getUpdateTime()), tenantService.getMaxUpdateTime()); - } - @Test public void testGetTenantIds() { // mock 数据 TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L)); tenantMapper.insert(tenant); - tenantService.initLocalCache(); // 调用,并断言业务异常 List result = tenantService.getTenantIds(); @@ -131,7 +102,6 @@ public class TenantServiceImplTest extends BaseDbUnitTest { // mock 数据 TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.DISABLE.getStatus())); tenantMapper.insert(tenant); - tenantService.initLocalCache(); // 调用,并断言业务异常 assertServiceException(() -> tenantService.validTenant(1L), TENANT_DISABLE, tenant.getName()); @@ -143,7 +113,6 @@ public class TenantServiceImplTest extends BaseDbUnitTest { TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.ENABLE.getStatus()) .setExpireTime(buildTime(2020, 2, 2))); tenantMapper.insert(tenant); - tenantService.initLocalCache(); // 调用,并断言业务异常 assertServiceException(() -> tenantService.validTenant(1L), TENANT_EXPIRE, tenant.getName()); @@ -155,7 +124,6 @@ public class TenantServiceImplTest extends BaseDbUnitTest { TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.ENABLE.getStatus()) .setExpireTime(addTime(Duration.ofDays(1)))); tenantMapper.insert(tenant); - tenantService.initLocalCache(); // 调用,并断言业务异常 tenantService.validTenant(1L); @@ -206,8 +174,6 @@ public class TenantServiceImplTest extends BaseDbUnitTest { verify(permissionService).assignRoleMenu(eq(200L), same(tenantPackage.getMenuIds())); // verify 分配角色 verify(permissionService).assignUserRole(eq(300L), eq(singleton(200L))); - // verify 发送刷新消息 - verify(tenantProducer).sendTenantRefreshMessage(); } @Test @@ -240,8 +206,6 @@ public class TenantServiceImplTest extends BaseDbUnitTest { // 校验是否更新正确 TenantDO tenant = tenantMapper.selectById(reqVO.getId()); // 获取最新的 assertPojoEquals(reqVO, tenant); - // verify 发送刷新消息 - verify(tenantProducer).sendTenantRefreshMessage(); // verify 设置角色权限 verify(permissionService).assignRoleMenu(eq(100L), eq(asSet(200L, 201L))); verify(permissionService).assignRoleMenu(eq(101L), eq(asSet(201L))); diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java index 4bacb2657..39f4c0152 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java @@ -225,7 +225,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes); // mock 方法 String avatar = randomString(); - when(fileApi.createFile(eq(avatarFileBytes))).thenReturn(avatar); + when(fileApi.createFile(eq( avatarFileBytes))).thenReturn(avatar); // 调用 userService.updateUserAvatar(userId, avatarFile); diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index eab7a525a..8dec9b8d3 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -62,6 +62,10 @@ + + cn.iocoder.boot + yudao-spring-boot-starter-biz-error-code + @@ -69,6 +73,10 @@ spring-boot-configuration-processor true + + cn.iocoder.boot + yudao-spring-boot-starter-banner + @@ -86,7 +94,7 @@ org.springframework.boot spring-boot-maven-plugin - 2.5.12 + 2.6.7 true diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/tip/package-info.java b/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/tip/package-info.java deleted file mode 100644 index 3006aa4ae..000000000 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/tip/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 目的:项目启动成功后,提供文档相关的地址 - */ -package cn.iocoder.yudao.server.framework.tip; diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index 4989a6146..e54bec4fc 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -171,10 +171,6 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta # 芋道配置项,设置当前项目所有自定义的配置 yudao: - security: - token-header: Authorization - mock-enable: true - mock-secret: test xss: enable: false exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 388b5676f..177abf9e4 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -198,9 +198,7 @@ yudao: captcha: enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 security: - token-header: Authorization mock-enable: true - mock-secret: test xss: enable: false exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 @@ -210,6 +208,10 @@ yudao: pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify pay-return-url: http://niubi.natapp1.cc/api/pay/order/return refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify + access-log: # 访问日志的配置项 + enable: false + error-code: # 错误码相关配置项 + enable: false demo: false # 关闭演示模式 justauth: diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 179cad761..89b1acac8 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -5,12 +5,18 @@ spring: profiles: active: local + main: + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 + # Servlet 配置 servlet: # 文件上传相关配置项 multipart: max-file-size: 16MB # 单个文件大小 max-request-size: 32MB # 设置总上传的文件大小 + mvc: + pathmatch: + matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 # Jackson 配置项 jackson: @@ -69,12 +75,6 @@ yudao: version: 1.0.0 base-package: cn.iocoder.yudao web: - admin-api: - prefix: /admin-api - controller: '**.controller.admin.**' - app-api: - prefix: /app-api - controller: '**.controller.app.**' admin-ui: url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 swagger: @@ -103,6 +103,7 @@ yudao: - /admin-api/system/captcha/get-image # 获取图片验证码,和租户无关 - /admin-api/infra/file/*/get/** # 获取图片,和租户无关 - /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号 + - /app-api/pay/order/notify/* # 支付回调通知,不携带租户编号 ignore-tables: - system_tenant - system_tenant_package diff --git a/yudao-ui-admin/package.json b/yudao-ui-admin/package.json index 5925a5c0e..11ffd16e2 100644 --- a/yudao-ui-admin/package.json +++ b/yudao-ui-admin/package.json @@ -45,7 +45,7 @@ "clipboard": "2.0.8", "core-js": "^3.21.1", "echarts": "4.9.0", - "element-ui": "^2.15.6", + "element-ui": "2.15.8", "file-saver": "2.0.5", "fuse.js": "6.4.3", "highlight.js": "9.18.5", diff --git a/yudao-ui-admin/src/assets/icons/svg/config.svg b/yudao-ui-admin/src/assets/icons/svg/config.svg index 79db5fb6a..4982b1e90 100644 --- a/yudao-ui-admin/src/assets/icons/svg/config.svg +++ b/yudao-ui-admin/src/assets/icons/svg/config.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/download.svg b/yudao-ui-admin/src/assets/icons/svg/download.svg index c89695134..87a04f928 100644 --- a/yudao-ui-admin/src/assets/icons/svg/download.svg +++ b/yudao-ui-admin/src/assets/icons/svg/download.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/merchant.svg b/yudao-ui-admin/src/assets/icons/svg/merchant.svg index f1ecb8127..57be1bc27 100644 --- a/yudao-ui-admin/src/assets/icons/svg/merchant.svg +++ b/yudao-ui-admin/src/assets/icons/svg/merchant.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/monitor.svg b/yudao-ui-admin/src/assets/icons/svg/monitor.svg index bc308cb0f..1cfde117f 100644 --- a/yudao-ui-admin/src/assets/icons/svg/monitor.svg +++ b/yudao-ui-admin/src/assets/icons/svg/monitor.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/order.svg b/yudao-ui-admin/src/assets/icons/svg/order.svg index 676ce3c59..41b37a396 100644 --- a/yudao-ui-admin/src/assets/icons/svg/order.svg +++ b/yudao-ui-admin/src/assets/icons/svg/order.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/pay.svg b/yudao-ui-admin/src/assets/icons/svg/pay.svg index ddab05def..31fe84172 100644 --- a/yudao-ui-admin/src/assets/icons/svg/pay.svg +++ b/yudao-ui-admin/src/assets/icons/svg/pay.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/percentSign.svg b/yudao-ui-admin/src/assets/icons/svg/percentSign.svg index bedbce63d..210947e57 100644 --- a/yudao-ui-admin/src/assets/icons/svg/percentSign.svg +++ b/yudao-ui-admin/src/assets/icons/svg/percentSign.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/assets/icons/svg/system.svg b/yudao-ui-admin/src/assets/icons/svg/system.svg index dba28cf6f..8ab97815c 100644 --- a/yudao-ui-admin/src/assets/icons/svg/system.svg +++ b/yudao-ui-admin/src/assets/icons/svg/system.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/yudao-ui-admin/src/layout/components/Navbar.vue b/yudao-ui-admin/src/layout/components/Navbar.vue index d6418e9fd..fbc2e7579 100644 --- a/yudao-ui-admin/src/layout/components/Navbar.vue +++ b/yudao-ui-admin/src/layout/components/Navbar.vue @@ -28,6 +28,7 @@

+ {{ nickname }}
@@ -73,6 +74,7 @@ export default { ...mapGetters([ 'sidebar', 'avatar', + 'nickname', 'device' ]), setting: { @@ -173,14 +175,20 @@ export default { margin-right: 30px; .avatar-wrapper { - margin-top: 5px; + display: flex; + justify-content: center; + align-items: center; position: relative; .user-avatar { cursor: pointer; - width: 40px; - height: 40px; - border-radius: 10px; + width: 35px; + height: 35px; + border-radius: 50%; + } + .user-nickname{ + margin-left: 5px; + font-size: 14px; } .el-icon-caret-bottom { diff --git a/yudao-ui-admin/src/store/getters.js b/yudao-ui-admin/src/store/getters.js index bcf7ab797..79cdf2c35 100644 --- a/yudao-ui-admin/src/store/getters.js +++ b/yudao-ui-admin/src/store/getters.js @@ -8,6 +8,7 @@ const getters = { token: state => state.user.token, avatar: state => state.user.avatar, name: state => state.user.name, + nickname: state => state.user.nickname, introduction: state => state.user.introduction, roles: state => state.user.roles, permissions: state => state.user.permissions, diff --git a/yudao-ui-admin/src/store/modules/user.js b/yudao-ui-admin/src/store/modules/user.js index fbe209b75..7c3df753b 100644 --- a/yudao-ui-admin/src/store/modules/user.js +++ b/yudao-ui-admin/src/store/modules/user.js @@ -17,6 +17,9 @@ const user = { SET_NAME: (state, name) => { state.name = name }, + SET_NICKNAME: (state, nickname) => { + state.nickname = nickname + }, SET_AVATAR: (state, avatar) => { state.avatar = avatar }, @@ -109,7 +112,8 @@ const user = { user: { id: '', avatar: '', - userName: '' + userName: '', + nickname: '' } } } @@ -126,6 +130,7 @@ const user = { } commit('SET_ID', user.id) commit('SET_NAME', user.userName) + commit('SET_NICKNAME', user.nickname) commit('SET_AVATAR', avatar) resolve(res) }).catch(error => { diff --git a/yudao-ui-admin/src/views/infra/dbDoc/index.vue b/yudao-ui-admin/src/views/infra/dbDoc/index.vue index 1058c795c..3df8f36b7 100644 --- a/yudao-ui-admin/src/views/infra/dbDoc/index.vue +++ b/yudao-ui-admin/src/views/infra/dbDoc/index.vue @@ -27,7 +27,7 @@ export default { return { height: document.documentElement.clientHeight - 94.5 + "px;", loading: true, - src: undefined, + src: "undefined", }; }, mounted: function() { diff --git a/yudao-ui-admin/src/views/infra/file/index.vue b/yudao-ui-admin/src/views/infra/file/index.vue index 0b02a3dae..462a879de 100644 --- a/yudao-ui-admin/src/views/infra/file/index.vue +++ b/yudao-ui-admin/src/views/infra/file/index.vue @@ -26,8 +26,9 @@ - - + + + @@ -160,7 +161,7 @@ export default { }, /** 处理上传的文件发生变化 */ handleFileChange(file, fileList) { - this.upload.data.path = file.name; + }, /** 处理文件上传中 */ handleFileUploadProgress(event, file, fileList) { diff --git a/yudao-ui-admin/src/views/infra/fileConfig/index.vue b/yudao-ui-admin/src/views/infra/fileConfig/index.vue index 08c12793c..2662a0d9d 100755 --- a/yudao-ui-admin/src/views/infra/fileConfig/index.vue +++ b/yudao-ui-admin/src/views/infra/fileConfig/index.vue @@ -77,7 +77,7 @@ - + @@ -91,7 +91,7 @@ - + diff --git a/yudao-ui-admin/src/views/system/sms/smsLog.vue b/yudao-ui-admin/src/views/system/sms/smsLog.vue index 8975d9350..cfd14e3d5 100644 --- a/yudao-ui-admin/src/views/system/sms/smsLog.vue +++ b/yudao-ui-admin/src/views/system/sms/smsLog.vue @@ -44,10 +44,6 @@ - - 新增 - 导出