mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feat_test-user
Conflicts: src/test/resources/sql/clean.sql src/test/resources/sql/create_tables.sql
This commit is contained in:
commit
f676153778
84
README.md
84
README.md
@ -1,6 +1,6 @@
|
|||||||
## 平台简介
|
## 平台简介
|
||||||
|
|
||||||
**芋道** 是基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue) **重构**,一套**全部开源**的**企业级**的快速开发平台,毫无保留给个人及企业免费使用。
|
**芋道**,一套**全部开源**的**企业级**的快速开发平台,毫无保留给个人及企业免费使用。
|
||||||
|
|
||||||
> 有任何问题,或者想要的功能,可以在 _Issues_ 中提给艿艿。
|
> 有任何问题,或者想要的功能,可以在 _Issues_ 中提给艿艿。
|
||||||
|
|
||||||
@ -17,39 +17,63 @@
|
|||||||
* 基础设施
|
* 基础设施
|
||||||
* 研发工具
|
* 研发工具
|
||||||
|
|
||||||
|
> 友情提示:本项目基于 RuoYi-Vue 修改,**重构优化**后端的代码,**美化**前端的界面。
|
||||||
|
>
|
||||||
|
> 额外新增的功能,我们使用 🚀 标记。
|
||||||
|
|
||||||
|
🙂 所有功能,都通过 **单元测试** 保证高质量。
|
||||||
|
|
||||||
### 系统功能
|
### 系统功能
|
||||||
|
|
||||||
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置
|
|
||||||
1. 在线用户:当前系统中活跃用户状态监控
|
| | 功能 | 描述 |
|
||||||
1. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分
|
| --- | --- | --- |
|
||||||
1. 菜单管理:配置系统菜单,操作权限,按钮权限标识等
|
| | 用户管理 | 用户是系统操作者,该功能主要完成系统用户配置 |
|
||||||
1. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限
|
| | 在线用户 | 当前系统中活跃用户状态监控,支持手动踢下线 |
|
||||||
1. 岗位管理:配置系统用户所属担任职务
|
| | 角色管理 | 角色菜单权限分配、设置角色按机构进行数据范围权限划分 |
|
||||||
1. 字典管理:对系统中经常使用的一些较为固定的数据进行维护
|
| | 菜单管理 | 配置系统菜单,操作权限,按钮权限标识等 |
|
||||||
1. 通知公告:系统通知公告信息发布维护
|
| | 部门管理 | 配置系统组织机构(公司、部门、小组),树结构展现支持数据权限 |
|
||||||
1. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询
|
| | 岗位管理 | 配置系统用户所属担任职务 |
|
||||||
1. 登录日志:系统登录日志记录查询包含登录异常
|
| | 字典管理 | 对系统中经常使用的一些较为固定的数据进行维护 |
|
||||||
|
| | 通知公告 | 系统通知公告信息发布维护 |
|
||||||
|
| 🚀 | 操作日志 | 系统正常操作日志记录和查询,集成 Swagger 生成日志内容 |
|
||||||
|
| | 登录日志 | 系统登录日志记录查询包含登录异常 |
|
||||||
|
|
||||||
|
计划新增功能:
|
||||||
|
* 短信
|
||||||
|
* 邮件
|
||||||
|
* 钉钉、飞书等通知
|
||||||
|
|
||||||
### 基础设施
|
### 基础设施
|
||||||
|
|
||||||
1. 配置管理:对系统动态配置常用参数
|
| | 功能 | 描述 |
|
||||||
1. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志
|
| --- | --- | --- |
|
||||||
1. API 日志:包括 RESTful API 访问日志、异常日志两部分,方便排查 API 相关的问题
|
| 🚀 | 配置管理 | 对系统动态配置常用参数,支持 SpringBoot 加载 |
|
||||||
1. MySQL 监控:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈
|
| | 定时任务 | 在线(添加、修改、删除)任务调度包含执行结果日志 |
|
||||||
1. Redis 监控:监控 Redis 数据库的使用情况,使用的 Redis Key 管理
|
| 🚀 | 文件服务 | 支持本地文件存储,同时支持兼容 Amazon S3 协议的云服务、开源组件 |
|
||||||
1. Java 监控:基于 Spring Boot Admin 实现 Java 应用的监控
|
| 🚀 | API 日志 | 包括 RESTful API 访问日志、异常日志两部分,方便排查 API 相关的问题 |
|
||||||
1. 链路追踪:基于 SkyWalking 实现性能监控,特别是链路的追踪
|
| | MySQL 监控 | 监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈 |
|
||||||
1. 分布式锁:基于 Redis 实现分布式锁,满足并发场景
|
| | Redis 监控 |监控 Redis 数据库的使用情况,使用的 Redis Key 管理 |
|
||||||
1. 幂等组件:基于 Redis 实现幂等组件,解决重复请求问题
|
| 🚀 |Java 监控 | 基于 Spring Boot Admin 实现 Java 应用的监控 |
|
||||||
1. 服务保障:基于 Resilience4j 实现服务的稳定性,包括限流、熔断等功能
|
| 🚀 | 链路追踪 | 基于 SkyWalking 实现性能监控,特别是链路的追踪 |
|
||||||
1. 日志服务:轻量级日志中心,查看远程服务器的日志
|
| 🚀 | 分布式锁 | 基于 Redis 实现分布式锁,满足并发场景 |
|
||||||
|
| 🚀 | 幂等组件 | 基于 Redis 实现幂等组件,解决重复请求问题 |
|
||||||
|
| 🚀 | 服务保障 | 基于 Resilience4j 实现服务的稳定性,包括限流、熔断等功能 |
|
||||||
|
| 🚀 | 日志服务 | 轻量级日志中心,查看远程服务器的日志 |
|
||||||
|
| 🚀 | 单元测试 |基于 JUnit + Mockito 实现单元测试,保证功能的正确性、代码的质量等 |
|
||||||
|
|
||||||
|
计划新增:
|
||||||
|
* 工作流
|
||||||
|
* 错误码
|
||||||
|
|
||||||
### 研发工具
|
### 研发工具
|
||||||
|
|
||||||
1. 表单构建:拖动表单元素生成相应的 HTML 代码
|
| | 功能 | 描述 |
|
||||||
1. 代码生成:前后端代码的生成(Java、Vue、SQL),支持 CRUD 下载
|
| --- | --- | --- |
|
||||||
1. 系统接口:基于 Swagger 自动生成相关的 RESTful API 接口文档
|
| 🚀 | 代码生成 |前后端代码的生成(Java、Vue、SQL、单元测试),支持 CRUD 下载 |
|
||||||
1. 数据库文档:基于 Screw 自动生成数据库文档
|
| 🚀 | 系统接口 | 基于 Swagger 自动生成相关的 RESTful API 接口文档 |
|
||||||
|
| 🚀 | 数据库文档 | 基于 Screw 自动生成数据库文档,支持导出 Word、HTML、MD 格式 |
|
||||||
|
| | 表单构建 | 拖动表单元素生成相应的 HTML 代码 |
|
||||||
|
|
||||||
## 在线体验
|
## 在线体验
|
||||||
|
|
||||||
@ -78,12 +102,14 @@
|
|||||||
| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.1.7 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) |
|
| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.1.7 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) |
|
||||||
| [Quartz](https://github.com/quartz-scheduler) | 任务调度组件 | 2.3.2 | [文档](http://www.iocoder.cn/Spring-Boot/Job/?yudao) |
|
| [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) |
|
| [Knife4j](https://gitee.com/xiaoym/knife4j) | Swagger 增强 UI 实现 | 3.0.2 | [文档](http://www.iocoder.cn/Spring-Boot/Swagger/?yudao) |
|
||||||
| [Resilience4j](https://github.com/quartz-scheduler) | 服务保障组件 | 1.7.0 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) |
|
| [Resilience4j](https://github.com/resilience4j/resilience4j) | 服务保障组件 | 1.7.0 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) |
|
||||||
| [SkyWalking](https://skywalking.apache.org/) | 分布式应用追踪系统 | 8.6.0 | [文档](http://www.iocoder.cn/Spring-Boot/SkyWalking/?yudao) |
|
| [SkyWalking](https://skywalking.apache.org/) | 分布式应用追踪系统 | 8.6.0 | [文档](http://www.iocoder.cn/Spring-Boot/SkyWalking/?yudao) |
|
||||||
| [Spring Boot Admin](https://github.com/skywalking) | Spring Boot 监控平台 | 8.6.0 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) |
|
| [Spring Boot Admin](https://github.com/codecentric/spring-boot-admin) | Spring Boot 监控平台 | 8.6.0 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) |
|
||||||
| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.11.4 | |
|
| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.11.4 | |
|
||||||
| [MapStruct](https://mapstruct.org/) | Java Bean 转换 | 1.4.1 | [文档](http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao) |
|
| [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) |
|
| [Lombok](https://projectlombok.org/) | 消除冗长的 Java 代码 | 1.16.14 | [文档](http://www.iocoder.cn/Spring-Boot/Lombok/?yudao) |
|
||||||
|
| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.7.0 | - |
|
||||||
|
| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 3.6.28 | - |
|
||||||
|
|
||||||
**前端**
|
**前端**
|
||||||
|
|
||||||
@ -125,7 +151,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
||||||
<td><img src="https://oscimg.oschina.net/oscnet/up-6d73c2140ce694e3de4c05035fdc1868d4c.png"/></td>
|
<td> - </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
4
lombok.config
Normal file
4
lombok.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
config.stopBubbling = true
|
||||||
|
lombok.tostring.callsuper=true
|
||||||
|
lombok.equalsandhashcode.callsuper=true
|
||||||
|
lombok.accessors.chain=true
|
84
pom.xml
84
pom.xml
@ -22,14 +22,15 @@
|
|||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||||
<!-- 统一依赖管理 -->
|
<!-- 统一依赖管理 -->
|
||||||
<spring.boot.version>2.4.2</spring.boot.version>
|
<spring.boot.version>2.4.4</spring.boot.version>
|
||||||
<!-- Web 相关 -->
|
<!-- Web 相关 -->
|
||||||
<knife4j.version>3.0.2</knife4j.version>
|
<knife4j.version>3.0.2</knife4j.version>
|
||||||
|
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
||||||
<!-- DB 相关 -->
|
<!-- DB 相关 -->
|
||||||
<mysql-connector-java.version>5.1.46</mysql-connector-java.version>
|
<mysql-connector-java.version>5.1.46</mysql-connector-java.version>
|
||||||
<druid.version>1.2.4</druid.version>
|
<druid.version>1.2.4</druid.version>
|
||||||
<mybatis-plus.version>3.4.1</mybatis-plus.version>
|
<mybatis-plus.version>3.4.2</mybatis-plus.version>
|
||||||
<redisson.version>3.14.1</redisson.version>
|
<redisson.version>3.15.1</redisson.version>
|
||||||
<!-- Config 配置中心相关 -->
|
<!-- Config 配置中心相关 -->
|
||||||
<apollo.version>1.7.0</apollo.version>
|
<apollo.version>1.7.0</apollo.version>
|
||||||
<!-- 服务保障相关 -->
|
<!-- 服务保障相关 -->
|
||||||
@ -41,10 +42,11 @@
|
|||||||
<!-- 工具类相关 -->
|
<!-- 工具类相关 -->
|
||||||
<lombok.version>1.16.14</lombok.version>
|
<lombok.version>1.16.14</lombok.version>
|
||||||
<mapstruct.version>1.4.1.Final</mapstruct.version>
|
<mapstruct.version>1.4.1.Final</mapstruct.version>
|
||||||
<hutool.version>5.5.6</hutool.version>
|
<hutool.version>5.6.1</hutool.version>
|
||||||
<easyexcel.verion>2.2.7</easyexcel.verion>
|
<easyexcel.verion>2.2.7</easyexcel.verion>
|
||||||
<velocity.version>2.2</velocity.version>
|
<velocity.version>2.2</velocity.version>
|
||||||
<screw.version>1.0.5</screw.version>
|
<screw.version>1.0.5</screw.version>
|
||||||
|
<!-- 三方云服务相关 -->
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
@ -100,8 +102,21 @@
|
|||||||
<artifactId>mapstruct</artifactId>
|
<artifactId>mapstruct</artifactId>
|
||||||
<groupId>org.mapstruct</groupId> <!-- 避免冲突 -->
|
<groupId>org.mapstruct</groupId> <!-- 避免冲突 -->
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- DB 相关 -->
|
<!-- DB 相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -144,6 +159,12 @@
|
|||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>lock4j-redisson-spring-boot-starter</artifactId>
|
<artifactId>lock4j-redisson-spring-boot-starter</artifactId>
|
||||||
<version>${lock4j.version}</version>
|
<version>${lock4j.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -175,6 +196,12 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>asm</artifactId>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -209,6 +236,12 @@
|
|||||||
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
|
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
|
||||||
<version>${mapstruct.version}</version>
|
<version>${mapstruct.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>${mapstruct.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
<artifactId>mapstruct-jdk8</artifactId>
|
<artifactId>mapstruct-jdk8</artifactId>
|
||||||
@ -217,27 +250,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>${hutool.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-extra</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-captcha</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-http</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-crypto</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -259,6 +272,27 @@
|
|||||||
<version>${screw.version}</version>
|
<version>${screw.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 三方云服务相关 -->
|
||||||
|
|
||||||
|
<!-- SMS SDK begin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.yunpian.sdk</groupId>
|
||||||
|
<artifactId>yunpian-java-sdk</artifactId>
|
||||||
|
<version>1.2.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
<version>4.5.18</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- SMS SDK end -->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
7
ruoyi-ui/.env.demo1024
Normal file
7
ruoyi-ui/.env.demo1024
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
NODE_ENV = production
|
||||||
|
|
||||||
|
# 测试环境配置
|
||||||
|
ENV = 'staging'
|
||||||
|
|
||||||
|
# 芋道管理系统/测试环境
|
||||||
|
VUE_APP_BASE_API = 'http://127.0.0.1:48080'
|
@ -8,6 +8,7 @@
|
|||||||
"dev": "vue-cli-service serve",
|
"dev": "vue-cli-service serve",
|
||||||
"build:prod": "vue-cli-service build",
|
"build:prod": "vue-cli-service build",
|
||||||
"build:stage": "vue-cli-service build --mode staging",
|
"build:stage": "vue-cli-service build --mode staging",
|
||||||
|
"build:demo1024": "vue-cli-service build --mode demo1024",
|
||||||
"preview": "node build/index.js --preview",
|
"preview": "node build/index.js --preview",
|
||||||
"lint": "eslint --ext .js,.vue src"
|
"lint": "eslint --ext .js,.vue src"
|
||||||
},
|
},
|
||||||
|
@ -8,3 +8,19 @@ export function exportHtml() {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function exportWord() {
|
||||||
|
return request({
|
||||||
|
url: '/infra/db-doc/export-word',
|
||||||
|
method: 'get',
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exportMarkdown() {
|
||||||
|
return request({
|
||||||
|
url: '/infra/db-doc/export-markdown',
|
||||||
|
method: 'get',
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
18
ruoyi-ui/src/api/infra/file.js
Normal file
18
ruoyi-ui/src/api/infra/file.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 删除文件
|
||||||
|
export function deleteFile(id) {
|
||||||
|
return request({
|
||||||
|
url: '/infra/file/delete?id=' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得文件分页
|
||||||
|
export function getFilePage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/infra/file/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
@ -46,7 +46,7 @@ export function addDept(data) {
|
|||||||
export function updateDept(data) {
|
export function updateDept(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dept/update',
|
url: '/system/dept/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -55,6 +55,6 @@ export function updateDept(data) {
|
|||||||
export function delDept(id) {
|
export function delDept(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dept/delete?id=' + id,
|
url: '/system/dept/delete?id=' + id,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ export function addData(data) {
|
|||||||
export function updateData(data) {
|
export function updateData(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dict-data/update',
|
url: '/system/dict-data/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ export function updateData(data) {
|
|||||||
export function delData(dictCode) {
|
export function delData(dictCode) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dict-data/delete?id=' + dictCode,
|
url: '/system/dict-data/delete?id=' + dictCode,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export function addType(data) {
|
|||||||
export function updateType(data) {
|
export function updateType(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dict-type/update',
|
url: '/system/dict-type/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ export function updateType(data) {
|
|||||||
export function delType(dictId) {
|
export function delType(dictId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dict-type/delete?id=' + dictId,
|
url: '/system/dict-type/delete?id=' + dictId,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export function addMenu(data) {
|
|||||||
export function updateMenu(data) {
|
export function updateMenu(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/menu/update',
|
url: '/system/menu/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -47,6 +47,6 @@ export function updateMenu(data) {
|
|||||||
export function delMenu(id) {
|
export function delMenu(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/menu/delete?id=' + id,
|
url: '/system/menu/delete?id=' + id,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export function addNotice(data) {
|
|||||||
export function updateNotice(data) {
|
export function updateNotice(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/notice/update',
|
url: '/system/notice/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -39,6 +39,6 @@ export function updateNotice(data) {
|
|||||||
export function delNotice(noticeId) {
|
export function delNotice(noticeId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/notice/delete?id=' + noticeId,
|
url: '/system/notice/delete?id=' + noticeId,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ export function addPost(data) {
|
|||||||
export function updatePost(data) {
|
export function updatePost(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/update',
|
url: '/system/post/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ export function updatePost(data) {
|
|||||||
export function delPost(postId) {
|
export function delPost(postId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/delete?id=' + postId,
|
url: '/system/post/delete?id=' + postId,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export function addRole(data) {
|
|||||||
export function updateRole(data) {
|
export function updateRole(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/role/update',
|
url: '/system/role/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ export function changeRoleStatus(id, status) {
|
|||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/role/update-status',
|
url: '/system/role/update-status',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ export function changeRoleStatus(id, status) {
|
|||||||
export function delRole(roleId) {
|
export function delRole(roleId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/role/delete?id=' + roleId,
|
url: '/system/role/delete?id=' + roleId,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
ruoyi-ui/src/api/system/sms/smsChannel.js
Normal file
52
ruoyi-ui/src/api/system/sms/smsChannel.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 创建短信渠道
|
||||||
|
export function createSmsChannel(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-channel/create',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新短信渠道
|
||||||
|
export function updateSmsChannel(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-channel/update',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除短信渠道
|
||||||
|
export function deleteSmsChannel(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-channel/delete?id=' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得短信渠道
|
||||||
|
export function getSmsChannel(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-channel/get?id=' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得短信渠道分页
|
||||||
|
export function getSmsChannelPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-channel/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得短信渠道精简列表
|
||||||
|
export function getSimpleSmsChannels() {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-channel/list-all-simple',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
20
ruoyi-ui/src/api/system/sms/smsLog.js
Normal file
20
ruoyi-ui/src/api/system/sms/smsLog.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 获得短信日志分页
|
||||||
|
export function getSmsLogPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-log/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出短信日志 Excel
|
||||||
|
export function exportSmsLogExcel(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-log/export-excel',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
64
ruoyi-ui/src/api/system/sms/smsTemplate.js
Normal file
64
ruoyi-ui/src/api/system/sms/smsTemplate.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 创建短信模板
|
||||||
|
export function createSmsTemplate(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/create',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新短信模板
|
||||||
|
export function updateSmsTemplate(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/update',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除短信模板
|
||||||
|
export function deleteSmsTemplate(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/delete?id=' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得短信模板
|
||||||
|
export function getSmsTemplate(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/get?id=' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得短信模板分页
|
||||||
|
export function getSmsTemplatePage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建短信模板
|
||||||
|
export function sendSms(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/send-sms',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出短信模板 Excel
|
||||||
|
export function exportSmsTemplateExcel(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/sms-template/export-excel',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ export function addUser(data) {
|
|||||||
export function updateUser(data) {
|
export function updateUser(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/update',
|
url: '/system/user/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ export function resetUserPwd(id, password) {
|
|||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/update-password',
|
url: '/system/user/update-password',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ export function changeUserStatus(id, status) {
|
|||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/update-status',
|
url: '/system/user/update-status',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ export function changeUserStatus(id, status) {
|
|||||||
// 查询用户个人信息
|
// 查询用户个人信息
|
||||||
export function getUserProfile() {
|
export function getUserProfile() {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile',
|
url: '/system/user/profile/get',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ export function getUserProfile() {
|
|||||||
// 修改用户个人信息
|
// 修改用户个人信息
|
||||||
export function updateUserProfile(data) {
|
export function updateUserProfile(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile',
|
url: '/system/user/profile/update',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@ -104,9 +104,9 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||||||
newPassword
|
newPassword
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile/updatePwd',
|
url: '/system/user/profile/update-password',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
params: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||||||
export function uploadAvatar(data) {
|
export function uploadAvatar(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile/avatar',
|
url: '/system/user/profile/avatar',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@ import {
|
|||||||
download,
|
download,
|
||||||
handleTree,
|
handleTree,
|
||||||
downloadExcel,
|
downloadExcel,
|
||||||
downloadZip
|
downloadWord,
|
||||||
|
downloadZip,
|
||||||
|
downloadHtml,
|
||||||
|
downloadMarkdown,
|
||||||
} from "@/utils/ruoyi";
|
} from "@/utils/ruoyi";
|
||||||
import Pagination from "@/components/Pagination";
|
import Pagination from "@/components/Pagination";
|
||||||
// 自定义表格工具扩展
|
// 自定义表格工具扩展
|
||||||
@ -48,6 +51,9 @@ Vue.prototype.getDictDataLabel = getDictDataLabel
|
|||||||
Vue.prototype.DICT_TYPE = DICT_TYPE
|
Vue.prototype.DICT_TYPE = DICT_TYPE
|
||||||
Vue.prototype.download = download
|
Vue.prototype.download = download
|
||||||
Vue.prototype.downloadExcel = downloadExcel
|
Vue.prototype.downloadExcel = downloadExcel
|
||||||
|
Vue.prototype.downloadWord = downloadWord
|
||||||
|
Vue.prototype.downloadHtml = downloadHtml
|
||||||
|
Vue.prototype.downloadMarkdown = downloadMarkdown
|
||||||
Vue.prototype.downloadZip = downloadZip
|
Vue.prototype.downloadZip = downloadZip
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ const user = {
|
|||||||
getInfo(state.token).then(res => {
|
getInfo(state.token).then(res => {
|
||||||
res = res.data; // 读取 data 数据
|
res = res.data; // 读取 data 数据
|
||||||
const user = res.user
|
const user = res.user
|
||||||
const avatar = user.avatar === "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
const avatar = user.avatar === "" ? require("@/assets/images/profile.jpg") : user.avatar;
|
||||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||||
commit('SET_ROLES', res.roles)
|
commit('SET_ROLES', res.roles)
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
commit('SET_PERMISSIONS', res.permissions)
|
||||||
|
@ -17,6 +17,10 @@ export const DICT_TYPE = {
|
|||||||
SYS_OPERATE_TYPE: 'sys_operate_type',
|
SYS_OPERATE_TYPE: 'sys_operate_type',
|
||||||
SYS_LOGIN_RESULT: 'sys_login_result',
|
SYS_LOGIN_RESULT: 'sys_login_result',
|
||||||
SYS_CONFIG_TYPE: 'sys_config_type',
|
SYS_CONFIG_TYPE: 'sys_config_type',
|
||||||
|
SYS_SMS_CHANNEL_CODE: 'sys_sms_channel_code',
|
||||||
|
SYS_SMS_TEMPLATE_TYPE: 'sys_sms_template_type',
|
||||||
|
SYS_SMS_SEND_STATUS: 'sys_sms_send_status',
|
||||||
|
SYS_SMS_RECEIVE_STATUS: 'sys_sms_receive_status',
|
||||||
|
|
||||||
INF_REDIS_TIMEOUT_TYPE: 'inf_redis_timeout_type',
|
INF_REDIS_TIMEOUT_TYPE: 'inf_redis_timeout_type',
|
||||||
INF_JOB_STATUS: 'inf_job_status',
|
INF_JOB_STATUS: 'inf_job_status',
|
||||||
|
@ -73,6 +73,18 @@ service.interceptors.response.use(res => {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
return Promise.reject(new Error(msg))
|
return Promise.reject(new Error(msg))
|
||||||
|
} else if (code === 901) {
|
||||||
|
Message({
|
||||||
|
type: 'error',
|
||||||
|
duration: 0,
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<div>演示模式,不发进行写操作</div>'
|
||||||
|
+ '<div> </div>'
|
||||||
|
+ '<div>参考 https://www.iocoder.cn/Yudao/build-debugger-environment 教程</div>'
|
||||||
|
+ '<div> </div>'
|
||||||
|
+ '<div>5 分钟搭建本地环境</div>',
|
||||||
|
})
|
||||||
|
return Promise.reject(new Error(msg))
|
||||||
} else if (code !== 200) {
|
} else if (code !== 200) {
|
||||||
Notification.error({
|
Notification.error({
|
||||||
title: msg
|
title: msg
|
||||||
|
@ -120,11 +120,26 @@ export function downloadExcel(data, fileName) {
|
|||||||
download0(data, fileName, 'application/vnd.ms-excel');
|
download0(data, fileName, 'application/vnd.ms-excel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 下载 Word 方法
|
||||||
|
export function downloadWord(data, fileName) {
|
||||||
|
download0(data, fileName, 'application/msword');
|
||||||
|
}
|
||||||
|
|
||||||
// 下载 Zip 方法
|
// 下载 Zip 方法
|
||||||
export function downloadZip(data, fileName) {
|
export function downloadZip(data, fileName) {
|
||||||
download0(data, fileName, 'application/zip');
|
download0(data, fileName, 'application/zip');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 下载 Html 方法
|
||||||
|
export function downloadHtml(data, fileName) {
|
||||||
|
download0(data, fileName, 'text/html');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载 Markdown 方法
|
||||||
|
export function downloadMarkdown(data, fileName) {
|
||||||
|
download0(data, fileName, 'text/markdown');
|
||||||
|
}
|
||||||
|
|
||||||
function download0(data, fileName, mineType) {
|
function download0(data, fileName, mineType) {
|
||||||
// 创建 blob
|
// 创建 blob
|
||||||
let blob = new Blob([data], {type: mineType});
|
let blob = new Blob([data], {type: mineType});
|
||||||
|
@ -2,24 +2,12 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="参数名称" prop="name">
|
<el-form-item label="参数名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入参数名称" clearable size="small" style="width: 240px"
|
||||||
v-model="queryParams.name"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入参数名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="参数键名" prop="key">
|
<el-form-item label="参数键名" prop="key">
|
||||||
<el-input
|
<el-input v-model="queryParams.key" placeholder="请输入参数键名" clearable size="small" style="width: 240px"
|
||||||
v-model="queryParams.key"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入参数键名"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="系统内置" prop="type">
|
<el-form-item label="系统内置" prop="type">
|
||||||
<el-select v-model="queryParams.type" placeholder="系统内置" clearable size="small">
|
<el-select v-model="queryParams.type" placeholder="系统内置" clearable size="small">
|
||||||
@ -56,7 +44,7 @@
|
|||||||
icon="el-icon-plus"
|
icon="el-icon-plus"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
v-hasPermi="['infra:config:add']"
|
v-hasPermi="['infra:config:create']"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
@ -95,31 +83,15 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['infra:config:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['infra:config:delete']">删除</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['infra:config:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['infra:config:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList"/>
|
||||||
v-show="total>0"
|
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改参数配置对话框 -->
|
<!-- 添加或修改参数配置对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
202
ruoyi-ui/src/views/infra/file/index.vue
Normal file
202
ruoyi-ui/src/views/infra/file/index.vue
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="文件路径" prop="id">
|
||||||
|
<el-input v-model="queryParams.id" placeholder="请输入文件路径" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="文件类型" prop="type">
|
||||||
|
<el-select v-model="queryParams.type" placeholder="请选择文件类型" clearable size="small">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">上传文件</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<el-table v-loading="loading" :data="list">
|
||||||
|
<el-table-column label="文件路径" align="center" prop="id" width="300" />
|
||||||
|
<el-table-column label="文件类型" align="center" prop="type" width="80" />
|
||||||
|
<el-table-column label="文件内容" align="center" prop="content">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<img v-if="scope.row.type === 'jpg' || scope.row.type === 'png' || scope.row.type === 'gif'"
|
||||||
|
width="200px" :src="getFileUrl + scope.row.id">
|
||||||
|
<i v-else>非图片,无法预览</i>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['infra:file:delete']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"/>
|
||||||
|
|
||||||
|
<!-- 对话框(添加 / 修改) -->
|
||||||
|
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||||
|
<el-upload ref="upload" :limit="1" accept=".jpg, .png, .gif" :auto-upload="false" drag
|
||||||
|
:headers="upload.headers" :action="upload.url" :data="upload.data" :disabled="upload.isUploading"
|
||||||
|
:on-change="handleFileChange"
|
||||||
|
:on-progress="handleFileUploadProgress"
|
||||||
|
:on-success="handleFileSuccess">
|
||||||
|
<i class="el-icon-upload"></i>
|
||||||
|
<div class="el-upload__text">
|
||||||
|
将文件拖到此处,或 <em>点击上传</em>
|
||||||
|
</div>
|
||||||
|
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入 jpg、png、gif 格式文件!</div>
|
||||||
|
</el-upload>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||||
|
<el-button @click="upload.open = false">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { deleteFile, getFilePage } from "@/api/infra/file";
|
||||||
|
import {getToken} from "@/utils/auth";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "File",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
getFileUrl: process.env.VUE_APP_BASE_API + '/api/infra/file/get/',
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 文件列表
|
||||||
|
list: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
dateRangeCreateTime: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
id: null,
|
||||||
|
type: null,
|
||||||
|
},
|
||||||
|
// 用户导入参数
|
||||||
|
upload: {
|
||||||
|
open: false, // 是否显示弹出层
|
||||||
|
title: "", // 弹出层标题
|
||||||
|
isUploading: false, // 是否禁用上传
|
||||||
|
url: process.env.VUE_APP_BASE_API + '/api/' + "/infra/file/upload", // 请求地址
|
||||||
|
headers: { Authorization: "Bearer " + getToken() }, // 设置上传的请求头部
|
||||||
|
data: {} // 上传的额外数据,用于文件名
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行查询
|
||||||
|
getFilePage(params).then(response => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
content: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNo = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRangeCreateTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.upload.open = true;
|
||||||
|
this.upload.title = "上传文件";
|
||||||
|
},
|
||||||
|
/** 处理上传的文件发生变化 */
|
||||||
|
handleFileChange(file, fileList) {
|
||||||
|
this.upload.data.path = file.name;
|
||||||
|
},
|
||||||
|
/** 处理文件上传中 */
|
||||||
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
|
this.upload.isUploading = true; // 禁止修改
|
||||||
|
},
|
||||||
|
/** 发起文件上窜 */
|
||||||
|
submitFileForm() {
|
||||||
|
this.$refs.upload.submit();
|
||||||
|
},
|
||||||
|
/** 文件上传成功处理 */
|
||||||
|
handleFileSuccess(response, file, fileList) {
|
||||||
|
// 清理
|
||||||
|
this.upload.open = false;
|
||||||
|
this.upload.isUploading = false;
|
||||||
|
this.$refs.upload.clearFiles();
|
||||||
|
// 提示成功,并刷新
|
||||||
|
this.msgSuccess("上传成功");
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const id = row.id;
|
||||||
|
this.$confirm('是否确认删除文件编号为"' + id + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return deleteFile(id);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -2,22 +2,11 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
|
||||||
<el-form-item label="部门名称" prop="name">
|
<el-form-item label="部门名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入部门名称" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.name"
|
|
||||||
placeholder="请输入部门名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
|
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -28,24 +17,13 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:dept:create']">新增</el-button>
|
||||||
type="primary"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:dept:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table v-loading="loading" :data="deptList" row-key="id" default-expand-all
|
||||||
v-loading="loading"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
:data="deptList"
|
|
||||||
row-key="id"
|
|
||||||
default-expand-all
|
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
||||||
>
|
|
||||||
<el-table-column prop="name" label="部门名称" width="260"></el-table-column>
|
<el-table-column prop="name" label="部门名称" width="260"></el-table-column>
|
||||||
<el-table-column prop="sort" label="排序" width="200"></el-table-column>
|
<el-table-column prop="sort" label="排序" width="200"></el-table-column>
|
||||||
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
|
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
|
||||||
@ -56,28 +34,12 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:dept:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:dept:create']">新增</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
<el-button v-if="scope.row.parentId !== 0" size="mini" type="text" icon="el-icon-delete"
|
||||||
v-hasPermi="['system:dept:edit']"
|
@click="handleDelete(scope.row)" v-hasPermi="['system:dept:delete']">删除</el-button>
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
@click="handleAdd(scope.row)"
|
|
||||||
v-hasPermi="['system:dept:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="scope.row.parentId !== 0"
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:dept:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -119,11 +81,8 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="部门状态" prop="status">
|
<el-form-item label="部门状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
|
||||||
v-for="dict in statusDictDatas"
|
{{dict.label}}</el-radio>
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -3,31 +3,15 @@
|
|||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="字典名称" prop="dictType">
|
<el-form-item label="字典名称" prop="dictType">
|
||||||
<el-select v-model="queryParams.dictType" size="small">
|
<el-select v-model="queryParams.dictType" size="small">
|
||||||
<el-option
|
<el-option v-for="item in typeOptions" :key="item.id" :label="item.name" :value="item.type"/>
|
||||||
v-for="item in typeOptions"
|
|
||||||
:key="item.id"
|
|
||||||
:label="item.name"
|
|
||||||
:value="item.type"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="字典标签" prop="label">
|
<el-form-item label="字典标签" prop="label">
|
||||||
<el-input
|
<el-input v-model="queryParams.label" placeholder="请输入字典标签" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.label"
|
|
||||||
placeholder="请输入字典标签"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small">
|
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in statusOptions" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
v-for="dict in statusOptions"
|
|
||||||
:key="dict.value"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -38,22 +22,12 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:dict:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:dict:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:dict:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:dict:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -72,31 +46,16 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:dict:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:dict:delete']">删除</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['system:dict:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:dict:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改参数配置对话框 -->
|
<!-- 添加或修改参数配置对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
@ -115,11 +74,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
|
@ -2,52 +2,19 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="字典名称" prop="name">
|
<el-form-item label="字典名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入字典名称" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.name"
|
|
||||||
placeholder="请输入字典名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="字典类型" prop="type">
|
<el-form-item label="字典类型" prop="type">
|
||||||
<el-input
|
<el-input v-model="queryParams.type" placeholder="请输入字典类型" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.type"
|
|
||||||
placeholder="请输入字典类型"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="queryParams.status" placeholder="字典状态" clearable size="small" style="width: 240px">
|
||||||
v-model="queryParams.status"
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
placeholder="字典状态"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间">
|
<el-form-item label="创建时间">
|
||||||
<el-date-picker
|
<el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
|
||||||
v-model="dateRange"
|
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -57,22 +24,12 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:dict:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:dict:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:dict:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:dict:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -96,31 +53,16 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:dict:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:dict:delete']">删除</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['system:dict:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:dict:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改参数配置对话框 -->
|
<!-- 添加或修改参数配置对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
@ -133,11 +75,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
@ -177,7 +115,7 @@ export default {
|
|||||||
// 状态数据字典
|
// 状态数据字典
|
||||||
statusOptions: [],
|
statusOptions: [],
|
||||||
// 日期范围
|
// 日期范围
|
||||||
dateRange: [],
|
dateRangeCreateTime: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@ -211,15 +149,15 @@ export default {
|
|||||||
/** 查询字典类型列表 */
|
/** 查询字典类型列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listType(this.addDateRange(this.queryParams, [
|
// 处理查询参数
|
||||||
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
|
let params = {...this.queryParams};
|
||||||
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
])).then(response => {
|
// 执行查询
|
||||||
|
listType(params).then(response => {
|
||||||
this.typeList = response.data.list;
|
this.typeList = response.data.list;
|
||||||
this.total = response.data.total;
|
this.total = response.data.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
// 字典状态字典翻译
|
// 字典状态字典翻译
|
||||||
statusFormat(row, column) {
|
statusFormat(row, column) {
|
||||||
@ -248,7 +186,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.dateRange = [];
|
this.dateRangeCreateTime = [];
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
@ -304,18 +242,20 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.addDateRange(this.queryParams, [
|
// 处理查询参数
|
||||||
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
|
let params = {...this.queryParams};
|
||||||
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
|
params.pageNo = undefined;
|
||||||
]);
|
params.pageSize = undefined;
|
||||||
this.$confirm('是否确认导出所有类型数据项?', "警告", {
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行导出
|
||||||
|
this.$confirm('是否确认导出所有字典类型数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return exportType(queryParams);
|
return exportType(params);
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
this.downloadExcel(response, '数据类型.xls');
|
this.downloadExcel(response, '字典类型.xls');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,56 +2,22 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="登录地址" prop="userIp">
|
<el-form-item label="登录地址" prop="userIp">
|
||||||
<el-input
|
<el-input v-model="queryParams.userIp" placeholder="请输入登录地址" clearable style="width: 240px;" size="small"
|
||||||
v-model="queryParams.userIp"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入登录地址"
|
|
||||||
clearable
|
|
||||||
style="width: 240px;"
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="用户名称" prop="username">
|
<el-form-item label="用户名称" prop="username">
|
||||||
<el-input
|
<el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable style="width: 240px;" size="small"
|
||||||
v-model="queryParams.username"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入用户名称"
|
|
||||||
clearable
|
|
||||||
style="width: 240px;"
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="queryParams.status" placeholder="结果" clearable size="small" style="width: 240px">
|
||||||
v-model="queryParams.status"
|
<el-option :key="true" label="成功" :value="true"/>
|
||||||
placeholder="结果"
|
<el-option :key="false" label="失败" :value="false"/>
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
:key="true"
|
|
||||||
label="成功"
|
|
||||||
:value="true"
|
|
||||||
/>
|
|
||||||
<el-option
|
|
||||||
:key="false"
|
|
||||||
label="失败"
|
|
||||||
:value="false"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="登录时间">
|
<el-form-item label="登录时间">
|
||||||
<el-date-picker
|
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
v-model="dateRange"
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -61,13 +27,8 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:login-log:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:login-log:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -76,7 +37,7 @@
|
|||||||
<el-table-column label="访问编号" align="center" prop="id" />
|
<el-table-column label="访问编号" align="center" prop="id" />
|
||||||
<el-table-column label="日志类型" align="center" prop="logType">
|
<el-table-column label="日志类型" align="center" prop="logType">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ scope.row.logType === 1 ? '登录' : '退出' }}</span>
|
<span>{{ scope.row.logType === 100 ? '登录' : '退出' }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="用户名称" align="center" prop="username" />
|
<el-table-column label="用户名称" align="center" prop="username" />
|
||||||
@ -95,13 +56,8 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -2,22 +2,11 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
|
||||||
<el-form-item label="菜单名称" prop="name">
|
<el-form-item label="菜单名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入菜单名称" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.name"
|
|
||||||
placeholder="请输入菜单名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
|
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -28,23 +17,14 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:menu:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:menu:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table v-loading="loading" :data="menuList" row-key="id"
|
||||||
v-loading="loading"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
:data="menuList"
|
|
||||||
row-key="id"
|
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
||||||
>
|
|
||||||
<el-table-column prop="name" label="菜单名称" :show-overflow-tooltip="true" width="200"></el-table-column>
|
<el-table-column prop="name" label="菜单名称" :show-overflow-tooltip="true" width="200"></el-table-column>
|
||||||
<el-table-column prop="icon" label="图标" align="center" width="100">
|
<el-table-column prop="icon" label="图标" align="center" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -62,26 +42,12 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini"
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
type="text"
|
v-hasPermi="['system:menu:update']">修改</el-button>
|
||||||
icon="el-icon-edit"
|
<el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
|
||||||
@click="handleUpdate(scope.row)"
|
v-hasPermi="['system:menu:create']">新增</el-button>
|
||||||
v-hasPermi="['system:menu:edit']"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
>修改</el-button>
|
v-hasPermi="['system:menu:delete']">删除</el-button>
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
@click="handleAdd(scope.row)"
|
|
||||||
v-hasPermi="['system:menu:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:menu:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -92,43 +58,25 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="上级菜单">
|
<el-form-item label="上级菜单">
|
||||||
<treeselect
|
<treeselect v-model="form.parentId" :options="menuOptions" :normalizer="normalizer" :show-count="true"
|
||||||
v-model="form.parentId"
|
placeholder="选择上级菜单"/>
|
||||||
:options="menuOptions"
|
|
||||||
:normalizer="normalizer"
|
|
||||||
:show-count="true"
|
|
||||||
placeholder="选择上级菜单"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="菜单类型" prop="type">
|
<el-form-item label="菜单类型" prop="type">
|
||||||
<el-radio-group v-model="form.type">
|
<el-radio-group v-model="form.type">
|
||||||
<el-radio
|
<el-radio v-for="dict in menuTypeDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
|
||||||
v-for="dict in menuTypeDictDatas"
|
{{dict.label}}</el-radio>
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item v-if="form.type != '3'" label="菜单图标">
|
<el-form-item v-if="form.type != '3'" label="菜单图标">
|
||||||
<el-popover
|
<el-popover placement="bottom-start" width="460" trigger="click" @show="$refs['iconSelect'].reset()">
|
||||||
placement="bottom-start"
|
|
||||||
width="460"
|
|
||||||
trigger="click"
|
|
||||||
@show="$refs['iconSelect'].reset()"
|
|
||||||
>
|
|
||||||
<IconSelect ref="iconSelect" @selected="selected" />
|
<IconSelect ref="iconSelect" @selected="selected" />
|
||||||
<el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly>
|
<el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly>
|
||||||
<svg-icon
|
<svg-icon v-if="form.icon" slot="prefix" :icon-class="form.icon" class="el-input__icon"
|
||||||
v-if="form.icon"
|
style="height: 32px;width: 16px;"/>
|
||||||
slot="prefix"
|
|
||||||
:icon-class="form.icon"
|
|
||||||
class="el-input__icon"
|
|
||||||
style="height: 32px;width: 16px;"
|
|
||||||
/>
|
|
||||||
<i v-else slot="prefix" class="el-icon-search el-input__icon" />
|
<i v-else slot="prefix" class="el-icon-search el-input__icon" />
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
|
@ -2,31 +2,14 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="公告标题" prop="title">
|
<el-form-item label="公告标题" prop="title">
|
||||||
<el-input
|
<el-input v-model="queryParams.title" placeholder="请输入公告标题" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.title"
|
|
||||||
placeholder="请输入公告标题"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="操作人员" prop="createBy">
|
<el-form-item label="操作人员" prop="createBy">
|
||||||
<el-input
|
<el-input v-model="queryParams.createBy" placeholder="请输入操作人员" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.createBy"
|
|
||||||
placeholder="请输入操作人员"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="类型" prop="type">
|
<el-form-item label="类型" prop="type">
|
||||||
<el-select v-model="queryParams.type" placeholder="公告类型" clearable size="small">
|
<el-select v-model="queryParams.type" placeholder="公告类型" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in noticeTypeDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in noticeTypeDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -37,39 +20,16 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:notice:create']"s>新增</el-button>
|
||||||
type="primary"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:notice:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="noticeList">
|
<el-table v-loading="loading" :data="noticeList">
|
||||||
<el-table-column label="序号" align="center" prop="id" width="100" />
|
<el-table-column label="序号" align="center" prop="id" width="100" />
|
||||||
<el-table-column
|
<el-table-column label="公告标题" align="center" prop="title" :show-overflow-tooltip="true"/>
|
||||||
label="公告标题"
|
<el-table-column label="公告类型" align="center" prop="type" :formatter="typeFormat" width="100"/>
|
||||||
align="center"
|
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" width="100"/>
|
||||||
prop="title"
|
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
/>
|
|
||||||
<el-table-column
|
|
||||||
label="公告类型"
|
|
||||||
align="center"
|
|
||||||
prop="type"
|
|
||||||
:formatter="typeFormat"
|
|
||||||
width="100"
|
|
||||||
/>
|
|
||||||
<el-table-column
|
|
||||||
label="状态"
|
|
||||||
align="center"
|
|
||||||
prop="status"
|
|
||||||
:formatter="statusFormat"
|
|
||||||
width="100"
|
|
||||||
/>
|
|
||||||
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
|
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -78,31 +38,16 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:notice:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:notice:delete']">删除</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['system:notice:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:notice:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改公告对话框 -->
|
<!-- 添加或修改公告对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
|
||||||
|
@ -2,72 +2,28 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="系统模块" prop="title">
|
<el-form-item label="系统模块" prop="title">
|
||||||
<el-input
|
<el-input v-model="queryParams.title" placeholder="请输入系统模块" clearable style="width: 240px;" size="small"
|
||||||
v-model="queryParams.title"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入系统模块"
|
|
||||||
clearable
|
|
||||||
style="width: 240px;"
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="操作人员" prop="operName">
|
<el-form-item label="操作人员" prop="operName">
|
||||||
<el-input
|
<el-input v-model="queryParams.operName" placeholder="请输入操作人员" clearable style="width: 240px;" size="small"
|
||||||
v-model="queryParams.operName"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入操作人员"
|
|
||||||
clearable
|
|
||||||
style="width: 240px;"
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="类型" prop="type">
|
<el-form-item label="类型" prop="type">
|
||||||
<el-select
|
<el-select v-model="queryParams.type" placeholder="操作类型" clearable size="small" style="width: 240px">
|
||||||
v-model="queryParams.type"
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_OPERATE_TYPE)" :key="parseInt(dict.value)"
|
||||||
placeholder="操作类型"
|
:label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="dict in this.getDictDatas(DICT_TYPE.SYS_OPERATE_TYPE)"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="queryParams.success" placeholder="操作状态" clearable size="small" style="width: 240px">
|
||||||
v-model="queryParams.success"
|
<el-option :key="true" label="成功" :value="true"/>
|
||||||
placeholder="操作状态"
|
<el-option :key="false" label="失败" :value="false"/>
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
:key="true"
|
|
||||||
label="成功"
|
|
||||||
:value="true"
|
|
||||||
/>
|
|
||||||
<el-option
|
|
||||||
:key="false"
|
|
||||||
label="失败"
|
|
||||||
:value="false"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="操作时间">
|
<el-form-item label="操作时间">
|
||||||
<el-date-picker
|
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
v-model="dateRange"
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -77,13 +33,8 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:operate-log:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:config:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -212,7 +163,6 @@ export default {
|
|||||||
businessType: undefined,
|
businessType: undefined,
|
||||||
status: undefined
|
status: undefined
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -2,31 +2,14 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="岗位编码" prop="code">
|
<el-form-item label="岗位编码" prop="code">
|
||||||
<el-input
|
<el-input v-model="queryParams.code" placeholder="请输入岗位编码" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.code"
|
|
||||||
placeholder="请输入岗位编码"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="岗位名称" prop="name">
|
<el-form-item label="岗位名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入岗位名称" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.name"
|
|
||||||
placeholder="请输入岗位名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
|
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -37,22 +20,12 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:post:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:post:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:post:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:post:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -70,31 +43,16 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:post:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:post:delete']">删除</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['system:post:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:post:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改岗位对话框 -->
|
<!-- 添加或修改岗位对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
@ -110,11 +68,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="岗位状态" prop="status">
|
<el-form-item label="岗位状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
|
||||||
v-for="dict in statusDictDatas"
|
{{dict.label}}</el-radio>
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
|
@ -2,52 +2,21 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
|
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
|
||||||
<el-form-item label="角色名称" prop="name">
|
<el-form-item label="角色名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入角色名称" clearable size="small" style="width: 240px"
|
||||||
v-model="queryParams.name"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入角色名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="角色标识" prop="code">
|
<el-form-item label="角色标识" prop="code">
|
||||||
<el-input
|
<el-input v-model="queryParams.code" placeholder="请输入角色标识" clearable size="small" style="width: 240px"
|
||||||
v-model="queryParams.code"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入角色标识"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="queryParams.status" placeholder="角色状态" clearable size="small" style="width: 240px">
|
||||||
v-model="queryParams.status"
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
placeholder="角色状态"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间">
|
<el-form-item label="创建时间">
|
||||||
<el-date-picker
|
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
|
||||||
v-model="dateRange"
|
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -57,22 +26,12 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:role:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:role:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:role:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:role:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -85,12 +44,7 @@
|
|||||||
<el-table-column label="显示顺序" prop="sort" width="100" />
|
<el-table-column label="显示顺序" prop="sort" width="100" />
|
||||||
<el-table-column label="状态" align="center" width="100">
|
<el-table-column label="状态" align="center" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch
|
<el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
|
||||||
v-model="scope.row.status"
|
|
||||||
:active-value="0"
|
|
||||||
:inactive-value="1"
|
|
||||||
@change="handleStatusChange(scope.row)"
|
|
||||||
></el-switch>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
@ -100,45 +54,20 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:role:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-circle-check" @click="handleMenu(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:permission:assign-role-menu']">菜单权限</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
<el-button size="mini" type="text" icon="el-icon-circle-check" @click="handleDataScope(scope.row)"
|
||||||
v-hasPermi="['system:role:edit']"
|
v-hasPermi="['system:permission:assign-role-data-scope']">数据权限</el-button>
|
||||||
>修改</el-button>
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
<el-button
|
v-hasPermi="['system:role:delete']">删除</el-button>
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-circle-check"
|
|
||||||
@click="handleMenu(scope.row)"
|
|
||||||
v-hasPermi="['system:permission:assign-role-menu']"
|
|
||||||
>菜单权限</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-circle-check"
|
|
||||||
@click="handleDataScope(scope.row)"
|
|
||||||
v-hasPermi="['system:permission:assign-role-data-scope']"
|
|
||||||
>数据权限</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:role:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNum"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改角色配置对话框 -->
|
<!-- 添加或修改角色配置对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
542
ruoyi-ui/src/views/system/sms/smsChannel.vue
Normal file
542
ruoyi-ui/src/views/system/sms/smsChannel.vue
Normal file
@ -0,0 +1,542 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="短信签名" prop="signature">
|
||||||
|
<el-input v-model="queryParams.signature" placeholder="请输入短信签名" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="启用状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择启用状态" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
|
v-hasPermi="['system:sms-channel:create']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
|
v-hasPermi="['system:sms-channel:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<el-table v-loading="loading" :data="list">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="短信签名" align="center" prop="signature" />
|
||||||
|
<el-table-column label="渠道编码" align="center" prop="code">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, scope.row.code) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>>
|
||||||
|
<el-table-column label="启用状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, scope.row.status) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="短信 API 的账号" align="center" prop="apiKey" />
|
||||||
|
<el-table-column label="短信 API 的秘钥" align="center" prop="apiSecret" />
|
||||||
|
<el-table-column label="短信发送回调 URL" align="center" prop="callbackUrl" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-channel:update']">修改</el-button>
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-channel:delete']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"/>
|
||||||
|
|
||||||
|
<!-- 对话框(添加 / 修改) -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="短信签名" prop="signature">
|
||||||
|
<el-input v-model="form.signature" placeholder="请输入短信签名" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="渠道编码" prop="code">
|
||||||
|
<el-input v-model="form.code" placeholder="请输入渠道编码" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="启用状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
|
||||||
|
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信 API 的账号" prop="apiKey">
|
||||||
|
<el-input v-model="form.apiKey" placeholder="请输入短信 API 的账号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信 API 的秘钥" prop="apiSecret">
|
||||||
|
<el-input v-model="form.apiSecret" placeholder="请输入短信 API 的秘钥" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信发送回调 URL" prop="callbackUrl">
|
||||||
|
<el-input v-model="form.callbackUrl" placeholder="请输入短信发送回调 URL" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { createSmsChannel, updateSmsChannel, deleteSmsChannel, getSmsChannel, getSmsChannelPage,
|
||||||
|
getSimpleSmsChannels } from "@/api/system/sms/smsChannel";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "SmsChannel",
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 短信渠道列表
|
||||||
|
list: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
dateRangeCreateTime: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
signature: null,
|
||||||
|
status: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
signature: [{ required: true, message: "短信签名不能为空", trigger: "blur" }],
|
||||||
|
code: [{ required: true, message: "渠道编码不能为空", trigger: "blur" }],
|
||||||
|
status: [{ required: true, message: "启用状态不能为空", trigger: "blur" }],
|
||||||
|
apiKey: [{ required: true, message: "短信 API 的账号不能为空", trigger: "blur" }],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行查询
|
||||||
|
getSmsChannelPage(params).then(response => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
signature: undefined,
|
||||||
|
code: undefined,
|
||||||
|
status: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
apiKey: undefined,
|
||||||
|
apiSecret: undefined,
|
||||||
|
callbackUrl: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNo = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRangeCreateTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加短信渠道";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id;
|
||||||
|
getSmsChannel(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改短信渠道";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateSmsChannel(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
createSmsChannel(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const id = row.id;
|
||||||
|
this.$confirm('是否确认删除短信渠道编号为"' + id + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return deleteSmsChannel(id);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
params.pageNo = undefined;
|
||||||
|
params.pageSize = undefined;
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行导出
|
||||||
|
this.$confirm('是否确认导出所有短信渠道数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportSmsChannelExcel(params);
|
||||||
|
}).then(response => {
|
||||||
|
this.downloadExcel(response, '短信渠道.xls');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script><template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="短信签名" prop="signature">
|
||||||
|
<el-input v-model="queryParams.signature" placeholder="请输入短信签名" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="启用状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择启用状态" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
|
v-hasPermi="['system:sms-channel:create']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
|
v-hasPermi="['system:sms-channel:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<el-table v-loading="loading" :data="list">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="短信签名" align="center" prop="signature" />
|
||||||
|
<el-table-column label="渠道编码" align="center" prop="code">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, scope.row.code) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>>
|
||||||
|
<el-table-column label="启用状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, scope.row.status) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-channel:update']">修改</el-button>
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-channel:delete']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"/>
|
||||||
|
|
||||||
|
<!-- 对话框(添加 / 修改) -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="130px">
|
||||||
|
<el-form-item label="短信签名" prop="signature">
|
||||||
|
<el-input v-model="form.signature" placeholder="请输入短信签名" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="渠道编码" prop="code">
|
||||||
|
<el-select v-model="form.code" placeholder="请选择渠道编码" :disabled="form.id > 0">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_CHANNEL_CODE)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="启用状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
|
||||||
|
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信 API 的账号" prop="apiKey">
|
||||||
|
<el-input v-model="form.apiKey" placeholder="请输入短信 API 的账号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.code !== 'YUN_PIAN'" label="短信 API 的秘钥" prop="apiSecret">
|
||||||
|
<el-input v-model="form.apiSecret" placeholder="请输入短信 API 的秘钥" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信发送回调 URL" prop="callbackUrl">
|
||||||
|
<el-input v-model="form.callbackUrl" placeholder="请输入短信发送回调 URL" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { createSmsChannel, updateSmsChannel, deleteSmsChannel, getSmsChannel, getSmsChannelPage } from "@/api/system/sms/smsChannel";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "SmsChannel",
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 短信渠道列表
|
||||||
|
list: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
dateRangeCreateTime: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
signature: null,
|
||||||
|
status: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
apiKeyEnableChannelCodes: ['YUN_PIAN'],
|
||||||
|
rules: {
|
||||||
|
signature: [{ required: true, message: "短信签名不能为空", trigger: "blur" }],
|
||||||
|
code: [{ required: true, message: "渠道编码不能为空", trigger: "blur" }],
|
||||||
|
status: [{ required: true, message: "启用状态不能为空", trigger: "blur" }],
|
||||||
|
apiKey: [{ required: true, message: "短信 API 的账号不能为空", trigger: "blur" }],
|
||||||
|
apiSecret: [{ required: true, message: "短信 API 的秘钥不能为空", trigger: "blur" }],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行查询
|
||||||
|
getSmsChannelPage(params).then(response => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
signature: undefined,
|
||||||
|
code: undefined,
|
||||||
|
status: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
apiKey: undefined,
|
||||||
|
apiSecret: undefined,
|
||||||
|
callbackUrl: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNo = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRangeCreateTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加短信渠道";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id;
|
||||||
|
getSmsChannel(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改短信渠道";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateSmsChannel(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
createSmsChannel(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const id = row.id;
|
||||||
|
this.$confirm('是否确认删除短信渠道编号为"' + id + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return deleteSmsChannel(id);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
params.pageNo = undefined;
|
||||||
|
params.pageSize = undefined;
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行导出
|
||||||
|
this.$confirm('是否确认导出所有短信渠道数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportSmsChannelExcel(params);
|
||||||
|
}).then(response => {
|
||||||
|
this.downloadExcel(response, '短信渠道.xls');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
297
ruoyi-ui/src/views/system/sms/smsLog.vue
Normal file
297
ruoyi-ui/src/views/system/sms/smsLog.vue
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
|
||||||
|
<el-form-item label="手机号" prop="mobile">
|
||||||
|
<el-input v-model="queryParams.mobile" placeholder="请输入手机号" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信渠道" prop="channelId">
|
||||||
|
<el-select v-model="queryParams.channelId" placeholder="请选择短信渠道" clearable size="small">
|
||||||
|
<el-option v-for="channel in channelOptions"
|
||||||
|
:key="channel.id" :value="channel.id"
|
||||||
|
:label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, channel.code) + '】'" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板编号" prop="templateId">
|
||||||
|
<el-input v-model="queryParams.templateId" placeholder="请输入模板编号" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发送状态" prop="sendStatus">
|
||||||
|
<el-select v-model="queryParams.sendStatus" placeholder="请选择发送状态" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_SEND_STATUS)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发送时间">
|
||||||
|
<el-date-picker v-model="dateRangeSendTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="接收状态" prop="receiveStatus">
|
||||||
|
<el-select v-model="queryParams.receiveStatus" placeholder="请选择接收状态" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_RECEIVE_STATUS)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="接收时间">
|
||||||
|
<el-date-picker v-model="dateRangeReceiveTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
|
v-hasPermi="['system:sms-log:create']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
|
v-hasPermi="['system:sms-log:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<el-table v-loading="loading" :data="list">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="手机号" align="center" prop="mobile" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div>{{ scope.row.mobile }}</div>
|
||||||
|
<div v-if="scope.row.userType && scope.row.userId">
|
||||||
|
{{ getDictDataLabel(DICT_TYPE.USER_TYPE, scope.row.userType) + '(' + scope.row.userId + ')' }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="短信内容" align="center" prop="templateContent" width="300" />
|
||||||
|
<el-table-column label="发送状态" align="center" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_SEND_STATUS, scope.row.sendStatus) }}</div>
|
||||||
|
<div>{{ parseTime(scope.row.sendTime) }}</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="接收状态" align="center" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_RECEIVE_STATUS, scope.row.receiveStatus) }}</div>
|
||||||
|
<div>{{ parseTime(scope.row.receiveTime) }}</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="短信渠道" align="center" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div>{{ formatChannelSignature(scope.row.channelId) }}</div>
|
||||||
|
<div>【{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, scope.row.channelCode) }}】</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="模板编号" align="center" prop="templateId" />
|
||||||
|
<el-table-column label="短信类型" align="center" prop="templateType">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE, scope.row.templateType) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)"
|
||||||
|
v-hasPermi="['system:sms-log:query']">详细</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"/>
|
||||||
|
|
||||||
|
<!-- 短信日志详细 -->
|
||||||
|
<el-dialog title="短信日志详细" :visible.sync="open" width="700px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" label-width="140px" size="mini">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="日志主键:">{{ form.id }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="短信渠道:">
|
||||||
|
{{ formatChannelSignature(form.channelId) }}【{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, form.channelCode) }}】
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="短信模板:">
|
||||||
|
{{ form.templateId }} | {{ form.templateCode}} | {{ getDictDataLabel(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE, form.templateType) }}
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="API 的模板编号:">{{ form.apiTemplateId }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="用户信息:">{{ form.mobile }}
|
||||||
|
<span v-if="form.userType && form.userId"> | {{ getDictDataLabel(DICT_TYPE.USER_TYPE, form.userType) }} | {{ form.userId }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="短信内容:">{{ form.templateContent }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="短信参数:">{{ form.templateParams }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="创建时间:">{{ parseTime(form.createTime) }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="发送状态:">{{ getDictDataLabel(DICT_TYPE.SYS_SMS_SEND_STATUS, form.sendStatus) }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="发送时间:">{{ parseTime(form.sendTime) }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="发送结果:">{{ form.sendCode }} | {{ form.sendMsg }}
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="API 发送结果:">{{ form.apiSendCode }} | {{ form.apiSendMsg }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="API 短信编号:">{{ form.apiSerialNo }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="API 请求编号:">{{ form.apiRequestId }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="接收状态:">{{ getDictDataLabel(DICT_TYPE.SYS_SMS_RECEIVE_STATUS, form.receiveStatus) }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="接收时间:">{{ parseTime(form.receiveTime) }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="API 接收结果:">{{ form.apiReceiveCode }} | {{ form.apiReceiveMsg }}
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="open = false">关 闭</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getSmsLogPage, exportSmsLogExcel } from "@/api/system/sms/smsLog";
|
||||||
|
import { getSimpleSmsChannels } from "@/api/system/sms/smsChannel";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "SmsLog",
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 短信日志列表
|
||||||
|
list: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
dateRangeSendTime: [],
|
||||||
|
dateRangeReceiveTime: [],
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
channelId: null,
|
||||||
|
templateId: null,
|
||||||
|
mobile: null,
|
||||||
|
sendStatus: null,
|
||||||
|
receiveStatus: null,
|
||||||
|
},
|
||||||
|
// 短信渠道
|
||||||
|
channelOptions: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
// 获得短信渠道
|
||||||
|
getSimpleSmsChannels().then(response => {
|
||||||
|
this.channelOptions = response.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeReceiveTime, 'receiveTime');
|
||||||
|
// 执行查询
|
||||||
|
getSmsLogPage(params).then(response => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNo = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRangeSendTime = [];
|
||||||
|
this.dateRangeReceiveTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
params.pageNo = undefined;
|
||||||
|
params.pageSize = undefined;
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeReceiveTime, 'receiveTime');
|
||||||
|
// 执行导出
|
||||||
|
this.$confirm('是否确认导出所有短信日志数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportSmsLogExcel(params);
|
||||||
|
}).then(response => {
|
||||||
|
this.downloadExcel(response, '短信日志.xls');
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 详细按钮操作 */
|
||||||
|
handleView(row) {
|
||||||
|
this.open = true;
|
||||||
|
this.form = row;
|
||||||
|
},
|
||||||
|
/** 格式化短信渠道 */
|
||||||
|
formatChannelSignature(channelId) {
|
||||||
|
for (const channel of this.channelOptions) {
|
||||||
|
if (channel.id === channelId) {
|
||||||
|
return channel.signature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '找不到签名:' + channelId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
405
ruoyi-ui/src/views/system/sms/smsTemplate.vue
Normal file
405
ruoyi-ui/src/views/system/sms/smsTemplate.vue
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="150px">
|
||||||
|
<el-form-item label="短信类型" prop="type">
|
||||||
|
<el-select v-model="queryParams.type" placeholder="请选择短信类型" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开启状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择开启状态" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板编码" prop="code">
|
||||||
|
<el-input v-model="queryParams.code" placeholder="请输入模板编码" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信 API 的模板编号" prop="apiTemplateId">
|
||||||
|
<el-input v-model="queryParams.apiTemplateId" placeholder="请输入短信 API 的模板编号" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信渠道" prop="channelId">
|
||||||
|
<el-select v-model="queryParams.channelId" placeholder="请选择短信渠道" clearable size="small">
|
||||||
|
<el-option v-for="channel in channelOptions"
|
||||||
|
:key="channel.id" :value="channel.id"
|
||||||
|
:label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, channel.code) + '】'" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||||
|
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
|
v-hasPermi="['system:sms-template:create']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
|
v-hasPermi="['system:sms-template:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<el-table v-loading="loading" :data="list">
|
||||||
|
<el-table-column label="模板编码" align="center" prop="code" />
|
||||||
|
<el-table-column label="模板名称" align="center" prop="name" />
|
||||||
|
<el-table-column label="模板内容" align="center" prop="content" width="300" />
|
||||||
|
<el-table-column label="短信类型" align="center" prop="type">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE, scope.row.type) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="开启状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, scope.row.status) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="短信 API 的模板编号" align="center" prop="apiTemplateId" width="180" />
|
||||||
|
<el-table-column label="短信渠道" align="center" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div>{{ formatChannelSignature(scope.row.channelId) }}</div>
|
||||||
|
<div>【{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, scope.row.channelCode) }}】</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-share" @click="handleSendSms(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-template:send-sms']">测试</el-button>
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-template:update']">修改</el-button>
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['system:sms-template:delete']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"/>
|
||||||
|
|
||||||
|
<!-- 对话框(添加 / 修改) -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
|
||||||
|
<el-form-item label="短信渠道编号" prop="channelId">
|
||||||
|
<el-select v-model="form.channelId" placeholder="请选择短信渠道编号">
|
||||||
|
<el-option v-for="channel in channelOptions"
|
||||||
|
:key="channel.id" :value="channel.id"
|
||||||
|
:label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, channel.code) + '】'" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信类型" prop="type">
|
||||||
|
<el-select v-model="form.type" placeholder="请选择短信类型">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板编号" prop="code">
|
||||||
|
<el-input v-model="form.code" placeholder="请输入模板编号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="请输入模板名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板内容" prop="content">
|
||||||
|
<el-input type="textarea" v-model="form.content" placeholder="请输入模板内容" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开启状态" prop="status">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
|
||||||
|
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="短信 API 模板编号" prop="apiTemplateId">
|
||||||
|
<el-input v-model="form.apiTemplateId" placeholder="请输入短信 API 的模板编号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 对话框(发送短信) -->
|
||||||
|
<el-dialog title="测试发送短信" :visible.sync="sendSmsOpen" width="500px" append-to-body>
|
||||||
|
<el-form ref="sendSmsForm" :model="sendSmsForm" :rules="sendSmsRules" label-width="140px">
|
||||||
|
<el-form-item label="模板内容" prop="content">
|
||||||
|
<el-input v-model="sendSmsForm.content" type="textarea" placeholder="请输入模板内容" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号" prop="mobile">
|
||||||
|
<el-input v-model="sendSmsForm.mobile" placeholder="请输入手机号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-for="param in sendSmsForm.params" :label="'参数 {' + param + '}'" :prop="'templateParams.' + param">
|
||||||
|
<el-input v-model="sendSmsForm.templateParams[param]" :placeholder="'请输入 ' + param + ' 参数'" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitSendSmsForm">确 定</el-button>
|
||||||
|
<el-button @click="cancelSendSms">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { createSmsTemplate, updateSmsTemplate, deleteSmsTemplate, getSmsTemplate, getSmsTemplatePage,
|
||||||
|
exportSmsTemplateExcel, sendSms } from "@/api/system/sms/smsTemplate";
|
||||||
|
import { getSimpleSmsChannels } from "@/api/system/sms/smsChannel";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "SmsTemplate",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 短信模板列表
|
||||||
|
list: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
dateRangeCreateTime: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
type: null,
|
||||||
|
status: null,
|
||||||
|
code: null,
|
||||||
|
content: null,
|
||||||
|
apiTemplateId: null,
|
||||||
|
channelId: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
type: [{ required: true, message: "短信类型不能为空", trigger: "change" }],
|
||||||
|
status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }],
|
||||||
|
code: [{ required: true, message: "模板编码不能为空", trigger: "blur" }],
|
||||||
|
name: [{ required: true, message: "模板名称不能为空", trigger: "blur" }],
|
||||||
|
content: [{ required: true, message: "模板内容不能为空", trigger: "blur" }],
|
||||||
|
apiTemplateId: [{ required: true, message: "短信 API 的模板编号不能为空", trigger: "blur" }],
|
||||||
|
channelId: [{ required: true, message: "短信渠道编号不能为空", trigger: "change" }],
|
||||||
|
},
|
||||||
|
// 短信渠道
|
||||||
|
channelOptions: [],
|
||||||
|
// 发送短信
|
||||||
|
sendSmsOpen: false,
|
||||||
|
sendSmsForm: {
|
||||||
|
params: [], // 模板的参数列表
|
||||||
|
},
|
||||||
|
sendSmsRules: {
|
||||||
|
mobile: [{ required: true, message: "手机不能为空", trigger: "blur" }],
|
||||||
|
templateCode: [{ required: true, message: "手机不能为空", trigger: "blur" }],
|
||||||
|
templateParams: { }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
// 获得短信渠道
|
||||||
|
getSimpleSmsChannels().then(response => {
|
||||||
|
this.channelOptions = response.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行查询
|
||||||
|
getSmsTemplatePage(params).then(response => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
type: undefined,
|
||||||
|
status: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
content: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
apiTemplateId: undefined,
|
||||||
|
channelId: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNo = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRangeCreateTime = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加短信模板";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id;
|
||||||
|
getSmsTemplate(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改短信模板";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateSmsTemplate(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
createSmsTemplate(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const id = row.id;
|
||||||
|
this.$confirm('是否确认删除短信模板编号为"' + id + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return deleteSmsTemplate(id);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let params = {...this.queryParams};
|
||||||
|
params.pageNo = undefined;
|
||||||
|
params.pageSize = undefined;
|
||||||
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
|
// 执行导出
|
||||||
|
this.$confirm('是否确认导出所有短信模板数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportSmsTemplateExcel(params);
|
||||||
|
}).then(response => {
|
||||||
|
this.downloadExcel(response, '短信模板.xls');
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 发送短息按钮 */
|
||||||
|
handleSendSms(row) {
|
||||||
|
this.resetSendSms(row);
|
||||||
|
// 设置参数
|
||||||
|
this.sendSmsForm.content = row.content;
|
||||||
|
this.sendSmsForm.params = row.params;
|
||||||
|
this.sendSmsForm.templateCode = row.code;
|
||||||
|
this.sendSmsForm.templateParams = row.params.reduce(function(obj, item) {
|
||||||
|
obj[item] = undefined;
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
// 根据 row 重置 rules
|
||||||
|
this.sendSmsRules.templateParams = row.params.reduce(function(obj, item) {
|
||||||
|
obj[item] = { required: true, message: '参数 ' + item + " 不能为空", trigger: "change" };
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
// 设置打开
|
||||||
|
this.sendSmsOpen = true;
|
||||||
|
},
|
||||||
|
/** 重置发送短信的表单 */
|
||||||
|
resetSendSms() {
|
||||||
|
// 根据 row 重置表单
|
||||||
|
this.sendSmsForm = {
|
||||||
|
content: undefined,
|
||||||
|
params: undefined,
|
||||||
|
mobile: undefined,
|
||||||
|
templateCode: undefined,
|
||||||
|
templateParams: {}
|
||||||
|
};
|
||||||
|
this.resetForm("sendSmsForm");
|
||||||
|
},
|
||||||
|
/** 取消发送短信 */
|
||||||
|
cancelSendSms() {
|
||||||
|
this.sendSmsOpen = false;
|
||||||
|
this.resetSendSms();
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitSendSmsForm() {
|
||||||
|
this.$refs["sendSmsForm"].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
sendSms(this.sendSmsForm).then(response => {
|
||||||
|
this.msgSuccess("提交发送成功!发送结果,见发送日志编号:" + response.data);
|
||||||
|
this.sendSmsOpen = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 格式化短信渠道 */
|
||||||
|
formatChannelSignature(channelId) {
|
||||||
|
for (const channel of this.channelOptions) {
|
||||||
|
if (channel.id === channelId) {
|
||||||
|
return channel.signature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '找不到签名:' + channelId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -4,77 +4,32 @@
|
|||||||
<!--部门数据-->
|
<!--部门数据-->
|
||||||
<el-col :span="4" :xs="24">
|
<el-col :span="4" :xs="24">
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-input
|
<el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px"/>
|
||||||
v-model="deptName"
|
|
||||||
placeholder="请输入部门名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
prefix-icon="el-icon-search"
|
|
||||||
style="margin-bottom: 20px"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-tree
|
<el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode"
|
||||||
:data="deptOptions"
|
ref="tree" default-expand-all @node-click="handleNodeClick"/>
|
||||||
:props="defaultProps"
|
|
||||||
:expand-on-click-node="false"
|
|
||||||
:filter-node-method="filterNode"
|
|
||||||
ref="tree"
|
|
||||||
default-expand-all
|
|
||||||
@node-click="handleNodeClick"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!--用户数据-->
|
<!--用户数据-->
|
||||||
<el-col :span="20" :xs="24">
|
<el-col :span="20" :xs="24">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="用户名称" prop="username">
|
<el-form-item label="用户名称" prop="username">
|
||||||
<el-input
|
<el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable size="small" style="width: 240px"
|
||||||
v-model="queryParams.username"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入用户名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="手机号码" prop="mobile">
|
<el-form-item label="手机号码" prop="mobile">
|
||||||
<el-input
|
<el-input v-model="queryParams.mobile" placeholder="请输入手机号码" clearable size="small" style="width: 240px"
|
||||||
v-model="queryParams.mobile"
|
@keyup.enter.native="handleQuery"/>
|
||||||
placeholder="请输入手机号码"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="queryParams.status" placeholder="用户状态" clearable size="small" style="width: 240px">
|
||||||
v-model="queryParams.status"
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
placeholder="用户状态"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间">
|
<el-form-item label="创建时间">
|
||||||
<el-date-picker
|
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
|
||||||
v-model="dateRange"
|
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -84,31 +39,16 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:user:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:user:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport"
|
||||||
type="info"
|
v-hasPermi="['system:user:import']">导入</el-button>
|
||||||
icon="el-icon-upload2"
|
|
||||||
size="mini"
|
|
||||||
@click="handleImport"
|
|
||||||
v-hasPermi="['system:user:import']"
|
|
||||||
>导入</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:user:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:user:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -121,12 +61,7 @@
|
|||||||
<el-table-column label="手机号码" align="center" prop="mobile" width="120" />
|
<el-table-column label="手机号码" align="center" prop="mobile" width="120" />
|
||||||
<el-table-column label="状态" align="center">
|
<el-table-column label="状态" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch
|
<el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row)" />
|
||||||
v-model="scope.row.status"
|
|
||||||
:active-value="0"
|
|
||||||
:inactive-value="1"
|
|
||||||
@change="handleStatusChange(scope.row)"
|
|
||||||
></el-switch>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
|
||||||
@ -134,53 +69,29 @@
|
|||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
|
||||||
label="操作"
|
|
||||||
align="center"
|
|
||||||
width="160"
|
|
||||||
class-name="small-padding fixed-width"
|
|
||||||
>
|
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="large" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:role:update']">修改</el-button>
|
||||||
type="text"
|
<el-dropdown @command="(command) => handleCommand(command, scope.$index, scope.row)">
|
||||||
icon="el-icon-edit"
|
<span class="el-dropdown-link">
|
||||||
@click="handleUpdate(scope.row)"
|
更多操作<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
v-hasPermi="['system:user:edit']"
|
</span>
|
||||||
>修改</el-button>
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-button
|
<el-dropdown-item command="handleDelete" v-if="scope.row.id !== 1" size="mini" type="text" icon="el-icon-delete"
|
||||||
v-if="scope.row.id !== 1"
|
v-hasPermi="['system:user:delete']">删除</el-dropdown-item>
|
||||||
size="mini"
|
<el-dropdown-item command="handleResetPwd" size="mini" type="text" icon="el-icon-key"
|
||||||
type="text"
|
v-hasPermi="['system:user:update-password']">重置密码</el-dropdown-item>
|
||||||
icon="el-icon-delete"
|
<el-dropdown-item command="handleRole" size="mini" type="text" icon="el-icon-circle-check"
|
||||||
@click="handleDelete(scope.row)"
|
v-hasPermi="['system:permission:assign-user-role']">分配角色</el-dropdown-item>
|
||||||
v-hasPermi="['system:user:remove']"
|
</el-dropdown-menu>
|
||||||
>删除</el-button>
|
</el-dropdown>
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-key"
|
|
||||||
@click="handleResetPwd(scope.row)"
|
|
||||||
v-hasPermi="['system:user:resetPwd']"
|
|
||||||
>重置</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-circle-check"
|
|
||||||
@click="handleRole(scope.row)"
|
|
||||||
v-hasPermi="['system:permission:assign-user-role']"
|
|
||||||
>分配角色</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@ -196,8 +107,7 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="归属部门" prop="deptId">
|
<el-form-item label="归属部门" prop="deptId">
|
||||||
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true"
|
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true"
|
||||||
placeholder="请选择归属部门" :normalizer="normalizer"
|
placeholder="请选择归属部门" :normalizer="normalizer"/>
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -229,12 +139,7 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="用户性别">
|
<el-form-item label="用户性别">
|
||||||
<el-select v-model="form.sex" placeholder="请选择">
|
<el-select v-model="form.sex" placeholder="请选择">
|
||||||
<el-option
|
<el-option v-for="dict in sexDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in sexDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
></el-option>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -326,7 +231,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus, importTemplate } from "@/api/system/user";
|
import {
|
||||||
|
addUser,
|
||||||
|
changeUserStatus,
|
||||||
|
delUser,
|
||||||
|
exportUser,
|
||||||
|
getUser,
|
||||||
|
importTemplate,
|
||||||
|
listUser,
|
||||||
|
resetUserPwd,
|
||||||
|
updateUser
|
||||||
|
} from "@/api/system/user";
|
||||||
import {getToken} from "@/utils/auth";
|
import {getToken} from "@/utils/auth";
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
@ -452,6 +367,25 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 更多操作
|
||||||
|
handleCommand(command, index, row) {
|
||||||
|
switch (command) {
|
||||||
|
case 'handleUpdate':
|
||||||
|
this.handleUpdate(row);//修改客户信息
|
||||||
|
break;
|
||||||
|
case 'handleDelete':
|
||||||
|
this.handleDelete(row);//红号变更
|
||||||
|
break;
|
||||||
|
case 'handleResetPwd':
|
||||||
|
this.handleResetPwd(row);
|
||||||
|
break;
|
||||||
|
case 'handleRole':
|
||||||
|
this.handleRole(row);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@ -713,3 +647,13 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style>
|
||||||
|
.el-dropdown-link {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #1890ff;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
.el-icon-arrow-down {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
<ul class="list-group list-group-striped">
|
<ul class="list-group list-group-striped">
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="user" />用户名称
|
<svg-icon icon-class="user" />用户名称
|
||||||
<div class="pull-right">{{ user.userName }}</div>
|
<div class="pull-right">{{ user.username }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="phone" />手机号码
|
<svg-icon icon-class="phone" />手机号码
|
||||||
<div class="pull-right">{{ user.phonenumber }}</div>
|
<div class="pull-right">{{ user.mobile }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="email" />用户邮箱
|
<svg-icon icon-class="email" />用户邮箱
|
||||||
@ -25,15 +25,19 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="tree" />所属部门
|
<svg-icon icon-class="tree" />所属部门
|
||||||
<div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
|
<div class="pull-right" v-if="user.dept">{{ user.dept.name }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="tree" />所属岗位
|
||||||
|
<div class="pull-right" v-if="user.posts">{{ user.posts.map(post => post.name).join(',') }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="peoples" />所属角色
|
<svg-icon icon-class="peoples" />所属角色
|
||||||
<div class="pull-right">{{ roleGroup }}</div>
|
<div class="pull-right">{{ user.roles.map(post => post.name).join(',') }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="date" />创建日期
|
<svg-icon icon-class="date" />创建日期
|
||||||
<div class="pull-right">{{ user.createTime }}</div>
|
<div class="pull-right">{{ parseTime(user.createTime) }}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -82,8 +86,6 @@ export default {
|
|||||||
getUser() {
|
getUser() {
|
||||||
getUserProfile().then(response => {
|
getUserProfile().then(response => {
|
||||||
this.user = response.data;
|
this.user = response.data;
|
||||||
this.roleGroup = response.roleGroup;
|
|
||||||
this.postGroup = response.postGroup;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
||||||
<el-form-item label="用户昵称" prop="nickName">
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
<el-input v-model="user.nickName" />
|
<el-input v-model="user.nickname" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="手机号码" prop="phonenumber">
|
<el-form-item label="手机号码" prop="mobile">
|
||||||
<el-input v-model="user.phonenumber" maxlength="11" />
|
<el-input v-model="user.mobile" maxlength="11" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="邮箱" prop="email">
|
<el-form-item label="邮箱" prop="email">
|
||||||
<el-input v-model="user.email" maxlength="50" />
|
<el-input v-model="user.email" maxlength="50" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="性别">
|
<el-form-item label="性别">
|
||||||
<el-radio-group v-model="user.sex">
|
<el-radio-group v-model="user.sex">
|
||||||
<el-radio label="0">男</el-radio>
|
<el-radio :label="1">男</el-radio>
|
||||||
<el-radio label="1">女</el-radio>
|
<el-radio :label="2">女</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -35,7 +35,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
nickName: [
|
nickname: [
|
||||||
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
|
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
|
||||||
],
|
],
|
||||||
email: [
|
email: [
|
||||||
@ -46,7 +46,7 @@ export default {
|
|||||||
trigger: ["blur", "change"]
|
trigger: ["blur", "change"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
phonenumber: [
|
mobile: [
|
||||||
{ required: true, message: "手机号码不能为空", trigger: "blur" },
|
{ required: true, message: "手机号码不能为空", trigger: "blur" },
|
||||||
{
|
{
|
||||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleExportHtml">导出 HTML</el-button>
|
||||||
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleExportWord">导出 Word</el-button>
|
||||||
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleExportMarkdown">导出 Markdown</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 展示文档 -->
|
||||||
<div v-loading="loading" :style="'height:'+ height">
|
<div v-loading="loading" :style="'height:'+ height">
|
||||||
<iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
|
<iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {exportHtml} from "@/api/infra/dbDoc";
|
import { exportHtml, exportWord, exportMarkdown} from "@/api/infra/dbDoc";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "DBDoc",
|
name: "DBDoc",
|
||||||
@ -25,10 +36,31 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
// 加载 Html,进行预览
|
||||||
exportHtml().then(response => {
|
exportHtml().then(response => {
|
||||||
// var blob = new Blob(['<a id="a"><b id="b">hey!</b></a>'], {type : 'text/html'});
|
let blob = new Blob([response], {type : 'text/html'});
|
||||||
this.src = window.URL.createObjectURL(response);
|
this.src = window.URL.createObjectURL(blob);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
/** 处理导出 HTML */
|
||||||
|
handleExportHtml() {
|
||||||
|
exportHtml().then(response => {
|
||||||
|
this.downloadHtml(response, '数据库文档.html');
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 处理导出 Word */
|
||||||
|
handleExportWord() {
|
||||||
|
exportWord().then(response => {
|
||||||
|
this.downloadWord(response, '数据库文档.doc');
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 处理导出 Markdown */
|
||||||
|
handleExportMarkdown() {
|
||||||
|
exportMarkdown().then(response => {
|
||||||
|
this.downloadMarkdown(response, '数据库文档.md');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -178,3 +178,11 @@ CREATE INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIG
|
|||||||
CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
|
CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
|
-- 初始化默认任务 用户 Session 超时 Job
|
||||||
|
INSERT INTO QRTZ_JOB_DETAILS VALUES ('schedulerName', 'sysUserSessionTimeoutJob', 'DEFAULT', NULL, 'cn.iocoder.dashboard.framework.quartz.core.handler.JobHandlerInvoker', '0', '1', '1', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400064A4F425F49447372000E6A6176612E6C616E672E4C6F6E673B8BE490CC8F23DF0200014A000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B020000787000000000000000047400104A4F425F48414E444C45525F4E414D457400187379735573657253657373696F6E54696D656F75744A6F627800);
|
||||||
|
commit;
|
||||||
|
INSERT INTO QRTZ_TRIGGERS VALUES ('schedulerName', 'sysUserSessionTimeoutJob', 'DEFAULT', 'sysUserSessionTimeoutJob', 'DEFAULT', NULL, 1615706340000, 1615706280000, 5, 'WAITING', 'CRON', 1615706125000, 0, NULL, 0, 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000037400114A4F425F48414E444C45525F504152414D707400124A4F425F52455452595F494E54455256414C737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000007D074000F4A4F425F52455452595F434F554E547371007E0009000000037800);
|
||||||
|
commit;
|
||||||
|
INSERT INTO QRTZ_CRON_TRIGGERS VALUES ('schedulerName', 'sysUserSessionTimeoutJob', 'DEFAULT', '0 * * * * ? *', 'Asia/Shanghai');
|
||||||
|
commit;
|
||||||
|
File diff suppressed because one or more lines are too long
20
src/main/java/cn/iocoder/dashboard/common/core/KeyValue.java
Normal file
20
src/main/java/cn/iocoder/dashboard/common/core/KeyValue.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.dashboard.common.core;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key Value 的键值对
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class KeyValue<K, V> {
|
||||||
|
|
||||||
|
private K key;
|
||||||
|
private V value;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.dashboard.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用状态枚举
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum DefaultBitFieldEnum {
|
||||||
|
|
||||||
|
NO(0, "否"),
|
||||||
|
YES(1, "是");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态值
|
||||||
|
*/
|
||||||
|
private final Integer val;
|
||||||
|
/**
|
||||||
|
* 状态名
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,13 @@
|
|||||||
package cn.iocoder.dashboard.common.exception;
|
package cn.iocoder.dashboard.common.exception;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cn.iocoder.dashboard.common.exception.enums.ServiceErrorCodeRange;
|
import cn.iocoder.dashboard.common.exception.enums.ServiceErrorCodeRange;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误码对象
|
* 错误码对象
|
||||||
*
|
*
|
||||||
* 全局错误码,占用 [0, 999],参见 {@link GlobalException}
|
* 全局错误码,占用 [0, 999], 参见 {@link GlobalErrorCodeConstants}
|
||||||
* 业务异常错误码,占用 [1 000 000 000, +∞),参见 {@link ServiceErrorCodeRange}
|
* 业务异常错误码,占用 [1 000 000 000, +∞),参见 {@link ServiceErrorCodeRange}
|
||||||
*
|
*
|
||||||
* TODO 错误码设计成对象的原因,为未来的 i18 国际化做准备
|
* TODO 错误码设计成对象的原因,为未来的 i18 国际化做准备
|
||||||
@ -21,11 +22,11 @@ public class ErrorCode {
|
|||||||
/**
|
/**
|
||||||
* 错误提示
|
* 错误提示
|
||||||
*/
|
*/
|
||||||
private final String message;
|
private final String msg;
|
||||||
|
|
||||||
public ErrorCode(Integer code, String message) {
|
public ErrorCode(Integer code, String message) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.message = message;
|
this.msg = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package cn.iocoder.dashboard.common.exception;
|
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局异常 Exception
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class GlobalException extends RuntimeException {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局错误码
|
|
||||||
*
|
|
||||||
* @see GlobalErrorCodeConstants
|
|
||||||
*/
|
|
||||||
private Integer code;
|
|
||||||
/**
|
|
||||||
* 错误提示
|
|
||||||
*/
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 空构造方法,避免反序列化问题
|
|
||||||
*/
|
|
||||||
public GlobalException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalException(ErrorCode errorCode) {
|
|
||||||
this.code = errorCode.getCode();
|
|
||||||
this.message = errorCode.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalException(Integer code, String message) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -30,7 +30,7 @@ public final class ServiceException extends RuntimeException {
|
|||||||
|
|
||||||
public ServiceException(ErrorCode errorCode) {
|
public ServiceException(ErrorCode errorCode) {
|
||||||
this.code = errorCode.getCode();
|
this.code = errorCode.getCode();
|
||||||
this.message = errorCode.getMessage();
|
this.message = errorCode.getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceException(Integer code, String message) {
|
public ServiceException(Integer code, String message) {
|
||||||
|
@ -32,6 +32,7 @@ public interface GlobalErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== 自定义错误段 ==========
|
// ========== 自定义错误段 ==========
|
||||||
ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求
|
ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求
|
||||||
|
ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式,禁止写操作");
|
||||||
|
|
||||||
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
|
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.dashboard.common.exception.util;
|
|||||||
|
|
||||||
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
import cn.iocoder.dashboard.common.exception.ServiceException;
|
import cn.iocoder.dashboard.common.exception.ServiceException;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -46,12 +47,12 @@ public class ServiceExceptionUtil {
|
|||||||
// ========== 和 ServiceException 的集成 ==========
|
// ========== 和 ServiceException 的集成 ==========
|
||||||
|
|
||||||
public static ServiceException exception(ErrorCode errorCode) {
|
public static ServiceException exception(ErrorCode errorCode) {
|
||||||
String messagePattern = MESSAGES.getOrDefault(errorCode.getCode(), errorCode.getMessage());
|
String messagePattern = MESSAGES.getOrDefault(errorCode.getCode(), errorCode.getMsg());
|
||||||
return exception0(errorCode.getCode(), messagePattern);
|
return exception0(errorCode.getCode(), messagePattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServiceException exception(ErrorCode errorCode, Object... params) {
|
public static ServiceException exception(ErrorCode errorCode, Object... params) {
|
||||||
String messagePattern = MESSAGES.getOrDefault(errorCode.getCode(), errorCode.getMessage());
|
String messagePattern = MESSAGES.getOrDefault(errorCode.getCode(), errorCode.getMsg());
|
||||||
return exception0(errorCode.getCode(), messagePattern, params);
|
return exception0(errorCode.getCode(), messagePattern, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +92,8 @@ public class ServiceExceptionUtil {
|
|||||||
* @param params 参数
|
* @param params 参数
|
||||||
* @return 格式化后的提示
|
* @return 格式化后的提示
|
||||||
*/
|
*/
|
||||||
private static String doFormat(int code, String messagePattern, Object... params) {
|
@VisibleForTesting
|
||||||
|
public static String doFormat(int code, String messagePattern, Object... params) {
|
||||||
StringBuilder sbuf = new StringBuilder(messagePattern.length() + 50);
|
StringBuilder sbuf = new StringBuilder(messagePattern.length() + 50);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j;
|
int j;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.dashboard.common.pojo;
|
package cn.iocoder.dashboard.common.pojo;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
import cn.iocoder.dashboard.common.exception.GlobalException;
|
|
||||||
import cn.iocoder.dashboard.common.exception.ServiceException;
|
import cn.iocoder.dashboard.common.exception.ServiceException;
|
||||||
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
@ -9,6 +8,7 @@ import lombok.Data;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用返回
|
* 通用返回
|
||||||
@ -16,7 +16,7 @@ import java.io.Serializable;
|
|||||||
* @param <T> 数据泛型
|
* @param <T> 数据泛型
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public final class CommonResult<T> implements Serializable {
|
public class CommonResult<T> implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误码
|
* 错误码
|
||||||
@ -31,7 +31,7 @@ public final class CommonResult<T> implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 错误提示,用户可阅读
|
* 错误提示,用户可阅读
|
||||||
*
|
*
|
||||||
* @see ErrorCode#getMessage() ()
|
* @see ErrorCode#getMsg() ()
|
||||||
*/
|
*/
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public final class CommonResult<T> implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> CommonResult<T> error(ErrorCode errorCode) {
|
public static <T> CommonResult<T> error(ErrorCode errorCode) {
|
||||||
return error(errorCode.getCode(), errorCode.getMessage());
|
return error(errorCode.getCode(), errorCode.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> CommonResult<T> success(T data) {
|
public static <T> CommonResult<T> success(T data) {
|
||||||
@ -68,9 +68,13 @@ public final class CommonResult<T> implements Serializable {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSuccess(Integer code) {
|
||||||
|
return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore // 避免 jackson 序列化
|
@JsonIgnore // 避免 jackson 序列化
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return GlobalErrorCodeConstants.SUCCESS.getCode().equals(code);
|
return isSuccess(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore // 避免 jackson 序列化
|
@JsonIgnore // 避免 jackson 序列化
|
||||||
@ -81,16 +85,12 @@ public final class CommonResult<T> implements Serializable {
|
|||||||
// ========= 和 Exception 异常体系集成 =========
|
// ========= 和 Exception 异常体系集成 =========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否有异常。如果有,则抛出 {@link GlobalException} 或 {@link ServiceException} 异常
|
* 判断是否有异常。如果有,则抛出 {@link ServiceException} 异常
|
||||||
*/
|
*/
|
||||||
public void checkError() throws GlobalException, ServiceException {
|
public void checkError() throws ServiceException {
|
||||||
if (isSuccess()) {
|
if (isSuccess()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 全局异常
|
|
||||||
if (GlobalErrorCodeConstants.isMatch(code)) {
|
|
||||||
throw new GlobalException(code, msg);
|
|
||||||
}
|
|
||||||
// 业务异常
|
// 业务异常
|
||||||
throw new ServiceException(code, msg);
|
throw new ServiceException(code, msg);
|
||||||
}
|
}
|
||||||
@ -99,8 +99,4 @@ public final class CommonResult<T> implements Serializable {
|
|||||||
return error(serviceException.getCode(), serviceException.getMessage());
|
return error(serviceException.getCode(), serviceException.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> CommonResult<T> error(GlobalException globalException) {
|
|
||||||
return error(globalException.getCode(), globalException.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,17 @@ import java.io.Serializable;
|
|||||||
@Data
|
@Data
|
||||||
public class PageParam implements Serializable {
|
public class PageParam implements Serializable {
|
||||||
|
|
||||||
|
private static final Integer PAGE_NO = 1;
|
||||||
|
private static final Integer PAGE_SIZE = 10;
|
||||||
|
|
||||||
@ApiModelProperty(value = "页码,从 1 开始", required = true,example = "1")
|
@ApiModelProperty(value = "页码,从 1 开始", required = true,example = "1")
|
||||||
@NotNull(message = "页码不能为空")
|
@NotNull(message = "页码不能为空")
|
||||||
@Min(value = 1, message = "页码最小值为 1")
|
@Min(value = 1, message = "页码最小值为 1")
|
||||||
private Integer pageNo;
|
private Integer pageNo = PAGE_NO;
|
||||||
|
|
||||||
@ApiModelProperty(value = "每页条数,最大值为 100", required = true, example = "10")
|
@ApiModelProperty(value = "每页条数,最大值为 100", required = true, example = "10")
|
||||||
@NotNull(message = "每页条数不能为空")
|
@NotNull(message = "每页条数不能为空")
|
||||||
@Range(min = 1, max = 100, message = "条数范围为 [1, 100]")
|
@Range(min = 1, max = 100, message = "条数范围为 [1, 100]")
|
||||||
private Integer pageSize;
|
private Integer pageSize = PAGE_SIZE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,11 @@ import com.alibaba.excel.metadata.GlobalConfiguration;
|
|||||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel {@link SysDictDataDO} 数据字典转换器
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DictConvert implements Converter<Object> {
|
public class DictConvert implements Converter<Object> {
|
||||||
|
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.excel.core.convert;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
|
import com.alibaba.excel.converters.Converter;
|
||||||
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.CellData;
|
||||||
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel Json 转换器
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class JsonConvert implements Converter<Object> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> supportJavaTypeKey() {
|
||||||
|
throw new UnsupportedOperationException("暂不支持,也不需要");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
throw new UnsupportedOperationException("暂不支持,也不需要");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
throw new UnsupportedOperationException("暂不支持,也不需要");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellData<String> convertToExcelData(Object value, ExcelContentProperty contentProperty,
|
||||||
|
GlobalConfiguration globalConfiguration) {
|
||||||
|
// 生成 Excel 小表格
|
||||||
|
return new CellData<>(JsonUtils.toJsonString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.dashboard.framework.file.config;
|
package cn.iocoder.dashboard.framework.file.config;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.common.SysFileController;
|
import cn.iocoder.dashboard.modules.infra.controller.file.InfFileController;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -13,7 +13,7 @@ import javax.validation.constraints.NotNull;
|
|||||||
public class FileProperties {
|
public class FileProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应 {@link SysFileController#}
|
* 对应 {@link InfFileController#}
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "基础文件路径不能为空")
|
@NotNull(message = "基础文件路径不能为空")
|
||||||
private String basePath;
|
private String basePath;
|
||||||
|
@ -1,18 +1,35 @@
|
|||||||
package cn.iocoder.dashboard.framework.jackson.config;
|
package cn.iocoder.dashboard.framework.jackson.config;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.jackson.deser.LocalDateTimeDeserializer;
|
||||||
|
import cn.iocoder.dashboard.framework.jackson.ser.LocalDateTimeSerializer;
|
||||||
import cn.iocoder.dashboard.util.json.JsonUtils;
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class JacksonConfig {
|
public class JacksonConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@SuppressWarnings("InstantiationOfUtilityClass")
|
@SuppressWarnings("InstantiationOfUtilityClass")
|
||||||
public JsonUtils jsonUtils(ObjectMapper objectMapper) {
|
public JsonUtils jsonUtils(ObjectMapper objectMapper) {
|
||||||
|
SimpleModule simpleModule = new SimpleModule();
|
||||||
|
/*
|
||||||
|
* 1. 新增Long类型序列化规则,数值超过2^53-1,在JS会出现精度丢失问题,因此Long自动序列化为字符串类型
|
||||||
|
* 2. 新增LocalDateTime序列化、反序列化规则
|
||||||
|
*/
|
||||||
|
simpleModule
|
||||||
|
// .addSerializer(Long.class, ToStringSerializer.instance)
|
||||||
|
// .addSerializer(Long.TYPE, ToStringSerializer.instance)
|
||||||
|
.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE)
|
||||||
|
.addDeserializer(LocalDateTime.class, LocalDateTimeDeserializer.INSTANCE);
|
||||||
|
|
||||||
|
objectMapper.registerModules(simpleModule);
|
||||||
|
|
||||||
JsonUtils.init(objectMapper);
|
JsonUtils.init(objectMapper);
|
||||||
return new JsonUtils();
|
return new JsonUtils();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.jackson.deser;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LocalDateTime反序列化规则
|
||||||
|
* <p>
|
||||||
|
* 会将毫秒级时间戳反序列化为LocalDateTime
|
||||||
|
*/
|
||||||
|
public class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
|
||||||
|
|
||||||
|
public static final LocalDateTimeDeserializer INSTANCE = new LocalDateTimeDeserializer();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||||
|
return LocalDateTime.ofInstant(Instant.ofEpochMilli(p.getValueAsLong()), ZoneId.systemDefault());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.jackson.ser;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LocalDateTime序列化规则
|
||||||
|
* <p>
|
||||||
|
* 会将LocalDateTime序列化为毫秒级时间戳
|
||||||
|
*/
|
||||||
|
public class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
|
||||||
|
|
||||||
|
public static final LocalDateTimeSerializer INSTANCE = new LocalDateTimeSerializer();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
|
gen.writeNumber(value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||||
|
}
|
||||||
|
}
|
@ -81,7 +81,7 @@ public class ApiAccessLogFilter extends OncePerRequestFilter {
|
|||||||
Map<String, String> queryString, String requestBody, Exception ex) {
|
Map<String, String> queryString, String requestBody, Exception ex) {
|
||||||
// 处理用户信息
|
// 处理用户信息
|
||||||
accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
|
accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
|
||||||
accessLog.setUserType(WebFrameworkUtils.getUesrType(request));
|
accessLog.setUserType(WebFrameworkUtils.getUserType(request));
|
||||||
// 设置访问结果
|
// 设置访问结果
|
||||||
CommonResult<?> result = WebFrameworkUtils.getCommonResult(request);
|
CommonResult<?> result = WebFrameworkUtils.getCommonResult(request);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.framework.logger.apilog.core.service;
|
|||||||
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiAccessLogCreateDTO;
|
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiAccessLogCreateDTO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 访问日志 Framework Service 接口
|
* API 访问日志 Framework Service 接口
|
||||||
@ -15,7 +16,8 @@ public interface ApiAccessLogFrameworkService {
|
|||||||
* 创建 API 访问日志
|
* 创建 API 访问日志
|
||||||
*
|
*
|
||||||
* @param createDTO 创建信息
|
* @param createDTO 创建信息
|
||||||
|
* @return 是否创建成功
|
||||||
*/
|
*/
|
||||||
void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO);
|
Future<Boolean> createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.framework.logger.apilog.core.service;
|
|||||||
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiErrorLogCreateDTO;
|
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiErrorLogCreateDTO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 错误日志 Framework Service 接口
|
* API 错误日志 Framework Service 接口
|
||||||
@ -15,7 +16,8 @@ public interface ApiErrorLogFrameworkService {
|
|||||||
* 创建 API 错误日志
|
* 创建 API 错误日志
|
||||||
*
|
*
|
||||||
* @param createDTO 创建信息
|
* @param createDTO 创建信息
|
||||||
|
* @return 是否创建成功
|
||||||
*/
|
*/
|
||||||
void createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO);
|
Future<Boolean> createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,16 @@ package cn.iocoder.dashboard.framework.logger.operatelog.core.service;
|
|||||||
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.operatelog.SysOperateLogCreateReqVO;
|
import cn.iocoder.dashboard.modules.system.controller.logger.vo.operatelog.SysOperateLogCreateReqVO;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
public interface OperateLogFrameworkService {
|
public interface OperateLogFrameworkService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 要不记录操作日志
|
* 异步记录操作日志
|
||||||
*
|
*
|
||||||
* @param reqVO 操作日志请求
|
* @param reqVO 操作日志请求
|
||||||
|
* @return true: 记录成功,false: 记录失败
|
||||||
*/
|
*/
|
||||||
void createOperateLogAsync(SysOperateLogCreateReqVO reqVO);
|
Future<Boolean> createOperateLogAsync(SysOperateLogCreateReqVO reqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.dashboard.framework.mybatis.config;
|
package cn.iocoder.dashboard.framework.mybatis.config;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.handler.DefaultDBFieldHandler;
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -13,7 +15,8 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class)
|
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class,
|
||||||
|
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
|
||||||
public class MybatisConfiguration {
|
public class MybatisConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -23,4 +26,9 @@ public class MybatisConfiguration {
|
|||||||
return mybatisPlusInterceptor;
|
return mybatisPlusInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MetaObjectHandler defaultMetaObjectHandler(){
|
||||||
|
return new DefaultDBFieldHandler(); // 自动填充参数类
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.dashboard.framework.mybatis.core.dataobject;
|
package cn.iocoder.dashboard.framework.mybatis.core.dataobject;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -15,19 +17,27 @@ public class BaseDO implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
/**
|
/**
|
||||||
* 最后更新时间
|
* 最后更新时间
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
/**
|
/**
|
||||||
* 创建者 TODO 芋艿:迁移成编号
|
* 创建者,目前使用 SysUser 的 id 编号
|
||||||
|
*
|
||||||
|
* 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。
|
||||||
*/
|
*/
|
||||||
private String createBy;
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private String creator;
|
||||||
/**
|
/**
|
||||||
* 更新者 TODO 芋艿:迁移成编号
|
* 更新者,目前使用 SysUser 的 id 编号
|
||||||
|
*
|
||||||
|
* 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。
|
||||||
*/
|
*/
|
||||||
private String updateBy;
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private String updater;
|
||||||
/**
|
/**
|
||||||
* 是否删除
|
* 是否删除
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.mybatis.core.handler;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import cn.iocoder.dashboard.framework.security.core.LoginUser;
|
||||||
|
import cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用参数填充实现类
|
||||||
|
*
|
||||||
|
* 如果没有显式的对通用参数进行赋值,这里会对通用参数进行填充、赋值
|
||||||
|
*
|
||||||
|
* @author hexiaowu
|
||||||
|
*/
|
||||||
|
public class DefaultDBFieldHandler implements MetaObjectHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertFill(MetaObject metaObject) {
|
||||||
|
if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO) {
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
BaseDO baseDO = (BaseDO) metaObject.getOriginalObject();
|
||||||
|
Date current = new Date();
|
||||||
|
|
||||||
|
// 创建时间为空,则以当前时间为插入时间
|
||||||
|
if (Objects.isNull(baseDO.getCreateTime())) {
|
||||||
|
baseDO.setCreateTime(current);
|
||||||
|
}
|
||||||
|
// 更新时间为空,则以当前时间为更新时间
|
||||||
|
if (Objects.isNull(baseDO.getUpdateTime())) {
|
||||||
|
baseDO.setUpdateTime(current);
|
||||||
|
}
|
||||||
|
// 当前登录用户不为空,创建人为空,则当前登录用户为创建人
|
||||||
|
if (Objects.nonNull(loginUser) && Objects.isNull(baseDO.getCreator())) {
|
||||||
|
baseDO.setCreator(loginUser.getId().toString());
|
||||||
|
}
|
||||||
|
// 当前登录用户不为空,更新人为空,则当前登录用户为更新人
|
||||||
|
if (Objects.nonNull(loginUser) && Objects.isNull(baseDO.getUpdater())) {
|
||||||
|
baseDO.setUpdater(loginUser.getId().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFill(MetaObject metaObject) {
|
||||||
|
Object modifyTime = getFieldValByName("updateTime", metaObject);
|
||||||
|
Object modifier = getFieldValByName("updater", metaObject);
|
||||||
|
// 获取登录用户信息
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
|
||||||
|
// 更新时间为空,则以当前时间为更新时间
|
||||||
|
if (Objects.isNull(modifyTime)) {
|
||||||
|
setFieldValByName("updateTime", new Date(), metaObject);
|
||||||
|
}
|
||||||
|
// 当前登录用户不为空,更新人为空,则当前登录用户为更新人
|
||||||
|
if (Objects.nonNull(loginUser) && Objects.isNull(modifier)) {
|
||||||
|
setFieldValByName("updater", loginUser.getId().toString(), metaObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,12 +24,16 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
|||||||
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<T> selectList() {
|
|
||||||
return selectList(new QueryWrapper<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
default T selectOne(String field, Object value) {
|
default T selectOne(String field, Object value) {
|
||||||
return selectOne(new QueryWrapper<T>().eq(field, value));
|
return selectOne(new QueryWrapper<T>().eq(field, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Integer selectCount(String field, Object value) {
|
||||||
|
return selectCount(new QueryWrapper<T>().eq(field, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<T> selectList() {
|
||||||
|
return selectList(new QueryWrapper<>());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package cn.iocoder.dashboard.framework.redis.config;
|
package cn.iocoder.dashboard.framework.redis.config;
|
||||||
|
|
||||||
|
import cn.hutool.system.SystemUtil;
|
||||||
import cn.iocoder.dashboard.framework.redis.core.pubsub.AbstractChannelMessageListener;
|
import cn.iocoder.dashboard.framework.redis.core.pubsub.AbstractChannelMessageListener;
|
||||||
|
import cn.iocoder.dashboard.framework.redis.core.stream.AbstractStreamMessageListener;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.connection.stream.Consumer;
|
||||||
|
import org.springframework.data.redis.connection.stream.ObjectRecord;
|
||||||
|
import org.springframework.data.redis.connection.stream.ReadOffset;
|
||||||
|
import org.springframework.data.redis.connection.stream.StreamOffset;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.listener.ChannelTopic;
|
import org.springframework.data.redis.listener.ChannelTopic;
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
|
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -19,6 +26,9 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class RedisConfig {
|
public class RedisConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 RedisTemplate Bean,使用 JSON 序列化方式
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||||
// 创建 RedisTemplate 对象
|
// 创建 RedisTemplate 对象
|
||||||
@ -27,14 +37,19 @@ public class RedisConfig {
|
|||||||
template.setConnectionFactory(factory);
|
template.setConnectionFactory(factory);
|
||||||
// 使用 String 序列化方式,序列化 KEY 。
|
// 使用 String 序列化方式,序列化 KEY 。
|
||||||
template.setKeySerializer(RedisSerializer.string());
|
template.setKeySerializer(RedisSerializer.string());
|
||||||
|
template.setHashKeySerializer(RedisSerializer.string());
|
||||||
// 使用 JSON 序列化方式(库是 Jackson ),序列化 VALUE 。
|
// 使用 JSON 序列化方式(库是 Jackson ),序列化 VALUE 。
|
||||||
template.setValueSerializer(RedisSerializer.json());
|
template.setValueSerializer(RedisSerializer.json());
|
||||||
|
template.setHashValueSerializer(RedisSerializer.json());
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 Redis Pub/Sub 广播消费的容器
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory factory,
|
public RedisMessageListenerContainer redisMessageListenerContainer(
|
||||||
List<AbstractChannelMessageListener<?>> listeners) {
|
RedisConnectionFactory factory, List<AbstractChannelMessageListener<?>> listeners) {
|
||||||
// 创建 RedisMessageListenerContainer 对象
|
// 创建 RedisMessageListenerContainer 对象
|
||||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||||
// 设置 RedisConnection 工厂。
|
// 设置 RedisConnection 工厂。
|
||||||
@ -48,4 +63,57 @@ public class RedisConfig {
|
|||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 Redis Stream 集群消费的容器
|
||||||
|
*
|
||||||
|
* Redis Stream 的 xreadgroup 命令:https://www.geek-book.com/src/docs/redis/redis/redis.io/commands/xreadgroup.html
|
||||||
|
*/
|
||||||
|
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||||
|
public StreamMessageListenerContainer<String, ObjectRecord<String, String>> redisStreamMessageListenerContainer(
|
||||||
|
RedisTemplate<String, Object> redisTemplate, List<AbstractStreamMessageListener<?>> listeners) {
|
||||||
|
// 第一步,创建 StreamMessageListenerContainer 容器
|
||||||
|
// 创建 options 配置
|
||||||
|
StreamMessageListenerContainer.StreamMessageListenerContainerOptions<String, ObjectRecord<String, String>> containerOptions =
|
||||||
|
StreamMessageListenerContainer.StreamMessageListenerContainerOptions.builder()
|
||||||
|
.batchSize(10) // 一次性最多拉取多少条消息
|
||||||
|
.targetType(String.class) // 目标类型。统一使用 String,通过自己封装的 AbstractStreamMessageListener 去反序列化
|
||||||
|
.build();
|
||||||
|
// 创建 container 对象
|
||||||
|
StreamMessageListenerContainer<String, ObjectRecord<String, String>> container = StreamMessageListenerContainer.create(
|
||||||
|
redisTemplate.getRequiredConnectionFactory(), containerOptions);
|
||||||
|
|
||||||
|
// 第二步,注册监听器,消费对应的 Stream 主题
|
||||||
|
String consumerName = buildConsumerName();
|
||||||
|
// String consumerName = "110";
|
||||||
|
listeners.forEach(listener -> {
|
||||||
|
// 创建 listener 对应的消费者分组
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForStream().createGroup(listener.getStreamKey(), listener.getGroup());
|
||||||
|
} catch (Exception ignore) {}
|
||||||
|
// 设置 listener 对应的 redisTemplate
|
||||||
|
listener.setRedisTemplate(redisTemplate);
|
||||||
|
// 创建 Consumer 对象
|
||||||
|
Consumer consumer = Consumer.from(listener.getGroup(), consumerName);
|
||||||
|
// 设置 Consumer 消费进度,以最小消费进度为准
|
||||||
|
StreamOffset<String> streamOffset = StreamOffset.create(listener.getStreamKey(), ReadOffset.lastConsumed());
|
||||||
|
// 设置 Consumer 监听
|
||||||
|
StreamMessageListenerContainer.StreamReadRequestBuilder<String> builder = StreamMessageListenerContainer.StreamReadRequest
|
||||||
|
.builder(streamOffset).consumer(consumer)
|
||||||
|
.autoAcknowledge(false) // 不自动 ack
|
||||||
|
.cancelOnError(throwable -> false); // 默认配置,发生异常就取消消费,显然不符合预期;因此,我们设置为 false
|
||||||
|
container.register(builder.build(), listener);
|
||||||
|
});
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建消费者名字,使用本地 IP + 进程编号的方式。
|
||||||
|
* 参考自 RocketMQ clientId 的实现
|
||||||
|
*
|
||||||
|
* @return 消费者名字
|
||||||
|
*/
|
||||||
|
private static String buildConsumerName() {
|
||||||
|
return String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package cn.iocoder.dashboard.framework.redis.core.pubsub;
|
package cn.iocoder.dashboard.framework.redis.core.pubsub;
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.TypeUtil;
|
||||||
import cn.iocoder.dashboard.util.json.JsonUtils;
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.data.redis.connection.Message;
|
import org.springframework.data.redis.connection.Message;
|
||||||
import org.springframework.data.redis.connection.MessageListener;
|
import org.springframework.data.redis.connection.MessageListener;
|
||||||
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
@ -62,21 +61,11 @@ public abstract class AbstractChannelMessageListener<T extends ChannelMessage> i
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Class<T> getMessageClass() {
|
private Class<T> getMessageClass() {
|
||||||
Class<?> targetClass = getClass();
|
Type type = TypeUtil.getTypeArgument(getClass(), 0);
|
||||||
while (targetClass.getSuperclass() != null) {
|
if (type == null) {
|
||||||
// 如果不是 AbstractMessageListener 父类,继续向上查找
|
|
||||||
if (targetClass.getSuperclass() != AbstractChannelMessageListener.class) {
|
|
||||||
targetClass = targetClass.getSuperclass();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 如果是 AbstractMessageListener 父类,则解析泛型
|
|
||||||
Type[] types = ((ParameterizedTypeImpl) targetClass.getGenericSuperclass()).getActualTypeArguments();
|
|
||||||
if (ArrayUtil.isEmpty(types)) {
|
|
||||||
throw new IllegalStateException(String.format("类型(%s) 需要设置消息类型", getClass().getName()));
|
throw new IllegalStateException(String.format("类型(%s) 需要设置消息类型", getClass().getName()));
|
||||||
}
|
}
|
||||||
return (Class<T>) types[0];
|
return (Class<T>) type;
|
||||||
}
|
|
||||||
throw new IllegalStateException(String.format("类型(%s) 找不到 AbstractMessageListener 父类", getClass().getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis Channel Message 接口
|
* Redis Channel Message 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
public interface ChannelMessage {
|
public interface ChannelMessage {
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ public interface ChannelMessage {
|
|||||||
*
|
*
|
||||||
* @return Channel
|
* @return Channel
|
||||||
*/
|
*/
|
||||||
@JsonIgnore // 必须序列化
|
@JsonIgnore // 避免序列化
|
||||||
String getChannel();
|
String getChannel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.redis.core.stream;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.TypeUtil;
|
||||||
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.redis.connection.stream.ObjectRecord;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.stream.StreamListener;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis Stream 监听器抽象类,用于实现集群消费
|
||||||
|
*
|
||||||
|
* @param <T> 消息类型。一定要填写噢,不然会报错
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public abstract class AbstractStreamMessageListener<T extends StreamMessage>
|
||||||
|
implements StreamListener<String, ObjectRecord<String, String>> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
*/
|
||||||
|
private final Class<T> messageType;
|
||||||
|
/**
|
||||||
|
* Redis Channel
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final String streamKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis 消费者分组,默认使用 spring.application.name 名字
|
||||||
|
*/
|
||||||
|
@Value("${spring.application.name}")
|
||||||
|
@Getter
|
||||||
|
private String group;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private RedisTemplate<String, ?> redisTemplate;
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
protected AbstractStreamMessageListener() {
|
||||||
|
this.messageType = getMessageClass();
|
||||||
|
this.streamKey = messageType.newInstance().getStreamKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(ObjectRecord<String, String> message) {
|
||||||
|
// 消费消息
|
||||||
|
T messageObj = JsonUtils.parseObject(message.getValue(), messageType);
|
||||||
|
this.onMessage(messageObj);
|
||||||
|
// ack 消息消费完成
|
||||||
|
redisTemplate.opsForStream().acknowledge(group, message);
|
||||||
|
// TODO 芋艿:需要额外考虑以下几个点:
|
||||||
|
// 1. 处理异常的情况
|
||||||
|
// 2. 发送日志;以及事务的结合
|
||||||
|
// 3. 消费日志;以及通用的幂等性
|
||||||
|
// 4. 消费失败的重试,https://zhuanlan.zhihu.com/p/60501638
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理消息
|
||||||
|
*
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
|
public abstract void onMessage(T message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过解析类上的泛型,获得消息类型
|
||||||
|
*
|
||||||
|
* @return 消息类型
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Class<T> getMessageClass() {
|
||||||
|
Type type = TypeUtil.getTypeArgument(getClass(), 0);
|
||||||
|
if (type == null) {
|
||||||
|
throw new IllegalStateException(String.format("类型(%s) 需要设置消息类型", getClass().getName()));
|
||||||
|
}
|
||||||
|
return (Class<T>) type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.redis.core.stream;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis Stream Message 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface StreamMessage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得 Redis Stream Key
|
||||||
|
*
|
||||||
|
* @return Channel
|
||||||
|
*/
|
||||||
|
@JsonIgnore // 避免序列化
|
||||||
|
String getStreamKey();
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,10 @@
|
|||||||
package cn.iocoder.dashboard.framework.redis.core.util;
|
package cn.iocoder.dashboard.framework.redis.core.util;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.framework.redis.core.pubsub.ChannelMessage;
|
import cn.iocoder.dashboard.framework.redis.core.pubsub.ChannelMessage;
|
||||||
|
import cn.iocoder.dashboard.framework.redis.core.stream.StreamMessage;
|
||||||
import cn.iocoder.dashboard.util.json.JsonUtils;
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
|
import org.springframework.data.redis.connection.stream.RecordId;
|
||||||
|
import org.springframework.data.redis.connection.stream.StreamRecords;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,4 +24,17 @@ public class RedisMessageUtils {
|
|||||||
redisTemplate.convertAndSend(message.getChannel(), JsonUtils.toJsonString(message));
|
redisTemplate.convertAndSend(message.getChannel(), JsonUtils.toJsonString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送 Redis 消息,基于 Redis Stream 实现
|
||||||
|
*
|
||||||
|
* @param redisTemplate Redis 操作模板
|
||||||
|
* @param message 消息
|
||||||
|
* @return 消息记录的编号对象
|
||||||
|
*/
|
||||||
|
public static <T extends StreamMessage> RecordId sendStreamMessage(RedisTemplate<String, ?> redisTemplate, T message) {
|
||||||
|
return redisTemplate.opsForStream().add(StreamRecords.newRecord()
|
||||||
|
.ofObject(JsonUtils.toJsonString(message)) // 设置内容
|
||||||
|
.withStreamKey(message.getStreamKey())); // 设置 stream key
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<http://www.iocoder.cn/Spring-Boot/Spring-Security/?github>
|
|
@ -0,0 +1 @@
|
|||||||
|
<https://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao>
|
@ -128,13 +128,13 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
// 设置每个请求的权限
|
// 设置每个请求的权限
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 登陆的接口,可匿名访问
|
// 登陆的接口,可匿名访问
|
||||||
.antMatchers(webProperties.getApiPrefix() + "/login").anonymous()
|
.antMatchers(api("/login")).anonymous()
|
||||||
// 通用的接口,可匿名访问
|
// 通用的接口,可匿名访问
|
||||||
.antMatchers( webProperties.getApiPrefix() + "/system/captcha/**").anonymous()
|
.antMatchers(api("/system/captcha/**")).anonymous()
|
||||||
// 静态资源,可匿名访问
|
// 静态资源,可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
||||||
// 文件的获取接口,可匿名访问
|
// 文件的获取接口,可匿名访问
|
||||||
.antMatchers(webProperties.getApiPrefix() + "/system/file/get/**").anonymous()
|
.antMatchers(api("/infra/file/get/**")).anonymous()
|
||||||
// Swagger 接口文档
|
// Swagger 接口文档
|
||||||
.antMatchers("/swagger-ui.html").anonymous()
|
.antMatchers("/swagger-ui.html").anonymous()
|
||||||
.antMatchers("/swagger-resources/**").anonymous()
|
.antMatchers("/swagger-resources/**").anonymous()
|
||||||
@ -148,13 +148,19 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
.antMatchers("/actuator/**").anonymous()
|
.antMatchers("/actuator/**").anonymous()
|
||||||
// Druid 监控
|
// Druid 监控
|
||||||
.antMatchers("/druid/**").anonymous()
|
.antMatchers("/druid/**").anonymous()
|
||||||
|
// 短信回调 API
|
||||||
|
.antMatchers(api("/system/sms/callback/**")).anonymous()
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
.and()
|
.and()
|
||||||
.headers().frameOptions().disable();
|
.headers().frameOptions().disable();
|
||||||
httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
|
httpSecurity.logout().logoutUrl(api("/logout")).logoutSuccessHandler(logoutSuccessHandler);
|
||||||
// 添加 JWT Filter
|
// 添加 JWT Filter
|
||||||
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String api(String url) {
|
||||||
|
return webProperties.getApiPrefix() + url;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.dashboard.framework.security.core.handler;
|
package cn.iocoder.dashboard.framework.security.core.handler;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
import cn.iocoder.dashboard.framework.security.config.SecurityProperties;
|
import cn.iocoder.dashboard.framework.security.config.SecurityProperties;
|
||||||
import cn.iocoder.dashboard.framework.security.core.service.SecurityAuthFrameworkService;
|
import cn.iocoder.dashboard.framework.security.core.service.SecurityAuthFrameworkService;
|
||||||
import cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
@ -36,6 +37,6 @@ public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
|
|||||||
securityFrameworkService.logout(token);
|
securityFrameworkService.logout(token);
|
||||||
}
|
}
|
||||||
// 返回成功
|
// 返回成功
|
||||||
ServletUtils.writeJSON(response, null);
|
ServletUtils.writeJSON(response, CommonResult.success(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ package cn.iocoder.dashboard.framework.security.core.util;
|
|||||||
|
|
||||||
import cn.iocoder.dashboard.framework.security.core.LoginUser;
|
import cn.iocoder.dashboard.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.dashboard.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.dashboard.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -40,9 +43,20 @@ public class SecurityFrameworkUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户
|
* 获取当前用户
|
||||||
|
*
|
||||||
|
* @return 当前用户
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static LoginUser getLoginUser() {
|
public static LoginUser getLoginUser() {
|
||||||
return (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
SecurityContext context = SecurityContextHolder.getContext();
|
||||||
|
if (context == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Authentication authentication = context.getAuthentication();
|
||||||
|
if (authentication == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return authentication.getPrincipal() instanceof LoginUser ? (LoginUser) authentication.getPrincipal() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,8 +64,10 @@ public class SecurityFrameworkUtils {
|
|||||||
*
|
*
|
||||||
* @return 用户编号
|
* @return 用户编号
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static Long getLoginUserId() {
|
public static Long getLoginUserId() {
|
||||||
return getLoginUser().getId();
|
LoginUser loginUser = getLoginUser();
|
||||||
|
return loginUser != null ? loginUser.getId() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,8 +75,10 @@ public class SecurityFrameworkUtils {
|
|||||||
*
|
*
|
||||||
* @return 角色编号数组
|
* @return 角色编号数组
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static Set<Long> getLoginUserRoleIds() {
|
public static Set<Long> getLoginUserRoleIds() {
|
||||||
return getLoginUser().getRoleIds();
|
LoginUser loginUser = getLoginUser();
|
||||||
|
return loginUser != null ? loginUser.getRoleIds() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.config;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsClientFactory;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.SmsClientFactoryImpl;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信配置类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class SmsConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SmsClientFactory smsClientFactory() {
|
||||||
|
return new SmsClientFactoryImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.core.KeyValue;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsTemplateRespDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端接口
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 2021/1/25 14:14
|
||||||
|
*/
|
||||||
|
public interface SmsClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得渠道编号
|
||||||
|
*
|
||||||
|
* @return 渠道编号
|
||||||
|
*/
|
||||||
|
Long getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
*
|
||||||
|
* @param logId 日志编号
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @param apiTemplateId 短信 API 的模板编号
|
||||||
|
* @param templateParams 短信模板参数。通过 List 数组,保证参数的顺序
|
||||||
|
* @return 短信发送结果
|
||||||
|
*/
|
||||||
|
SmsCommonResult<SmsSendRespDTO> sendSms(Long logId, String mobile, String apiTemplateId,
|
||||||
|
List<KeyValue<String, Object>> templateParams);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析接收短信的接收结果
|
||||||
|
*
|
||||||
|
* @param text 结果
|
||||||
|
* @return 结果内容
|
||||||
|
* @throws Throwable 当解析 text 发生异常时,则会抛出异常
|
||||||
|
*/
|
||||||
|
List<SmsReceiveRespDTO> parseSmsReceiveStatus(String text) throws Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定的短信模板
|
||||||
|
*
|
||||||
|
* @param apiTemplateId 短信 API 的模板编号
|
||||||
|
* @return 短信模板
|
||||||
|
*/
|
||||||
|
SmsCommonResult<SmsTemplateRespDTO> getSmsTemplate(String apiTemplateId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端工厂接口
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 2021/1/28 14:01
|
||||||
|
*/
|
||||||
|
public interface SmsClientFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得短信 Client
|
||||||
|
*
|
||||||
|
* @param channelId 渠道编号
|
||||||
|
* @return 短信 Client
|
||||||
|
*/
|
||||||
|
SmsClient getSmsClient(Long channelId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得短信 Client
|
||||||
|
*
|
||||||
|
* @param channelCode 渠道编码
|
||||||
|
* @return 短信 Client
|
||||||
|
*/
|
||||||
|
SmsClient getSmsClient(String channelCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建短信 Client
|
||||||
|
*
|
||||||
|
* @param properties 配置对象
|
||||||
|
*/
|
||||||
|
void createOrUpdateSmsClient(SmsChannelProperties properties);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsFrameworkErrorCodeConstants;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 API 的错误码,转换为通用的错误码
|
||||||
|
*
|
||||||
|
* @see SmsCommonResult
|
||||||
|
* @see SmsFrameworkErrorCodeConstants
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface SmsCodeMapping extends Function<String, ErrorCode> {
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client;
|
||||||
|
|
||||||
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsFrameworkErrorCodeConstants;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信的 CommonResult 拓展类
|
||||||
|
*
|
||||||
|
* 考虑到不同的平台,返回的 code 和 msg 是不同的,所以统一额外返回 {@link #apiCode} 和 {@link #apiMsg} 字段
|
||||||
|
*
|
||||||
|
* 另外,一些短信平台(例如说阿里云、腾讯云)会返回一个请求编号,用于排查请求失败的问题,我们设置到 {@link #apiRequestId} 字段
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class SmsCommonResult<T> extends CommonResult<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API 返回错误码
|
||||||
|
*
|
||||||
|
* 由于第三方的错误码可能是字符串,所以使用 String 类型
|
||||||
|
*/
|
||||||
|
private String apiCode;
|
||||||
|
/**
|
||||||
|
* API 返回提示
|
||||||
|
*/
|
||||||
|
private String apiMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API 请求编号
|
||||||
|
*/
|
||||||
|
private String apiRequestId;
|
||||||
|
|
||||||
|
private SmsCommonResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> SmsCommonResult<T> build(String apiCode, String apiMsg, String apiRequestId,
|
||||||
|
T data, SmsCodeMapping codeMapping) {
|
||||||
|
Assert.notNull(codeMapping, "参数 codeMapping 不能为空");
|
||||||
|
SmsCommonResult<T> result = new SmsCommonResult<T>().setApiCode(apiCode).setApiMsg(apiMsg).setApiRequestId(apiRequestId);
|
||||||
|
result.setData(data);
|
||||||
|
// 翻译错误码
|
||||||
|
if (codeMapping != null) {
|
||||||
|
ErrorCode errorCode = codeMapping.apply(apiCode);
|
||||||
|
if (errorCode == null) {
|
||||||
|
errorCode = SmsFrameworkErrorCodeConstants.SMS_UNKNOWN;
|
||||||
|
}
|
||||||
|
result.setCode(errorCode.getCode()).setMsg(errorCode.getMsg());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> SmsCommonResult<T> error(Throwable ex) {
|
||||||
|
SmsCommonResult<T> result = new SmsCommonResult<>();
|
||||||
|
result.setCode(SmsFrameworkErrorCodeConstants.EXCEPTION.getCode());
|
||||||
|
result.setMsg(ExceptionUtil.getRootCauseMessage(ex));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息接收 Response DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmsReceiveRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否接收成功
|
||||||
|
*/
|
||||||
|
private Boolean success;
|
||||||
|
/**
|
||||||
|
* API 接收结果的编码
|
||||||
|
*/
|
||||||
|
private String errorCode;
|
||||||
|
/**
|
||||||
|
* API 接收结果的说明
|
||||||
|
*/
|
||||||
|
private String errorMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 用户接收时间
|
||||||
|
*/
|
||||||
|
private Date receiveTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信 API 发送返回的序号
|
||||||
|
*/
|
||||||
|
private String serialNo;
|
||||||
|
/**
|
||||||
|
* 短信日志编号
|
||||||
|
*
|
||||||
|
* 对应 SysSmsLogDO 的编号
|
||||||
|
*/
|
||||||
|
private Long logId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送 Response DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmsSendRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信 API 发送返回的序号
|
||||||
|
*/
|
||||||
|
private String serialNo;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.dto;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信模板 Response DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmsTemplateRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板编号
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 短信内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 审核状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link SmsTemplateAuditStatusEnum}
|
||||||
|
*/
|
||||||
|
private Integer auditStatus;
|
||||||
|
/**
|
||||||
|
* 审核未通过的理由
|
||||||
|
*/
|
||||||
|
private String auditReason;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,122 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.core.KeyValue;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCodeMapping;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsTemplateRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端抽象类
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 2021/2/1 9:28
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public abstract class AbstractSmsClient implements SmsClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信渠道配置
|
||||||
|
*/
|
||||||
|
protected volatile SmsChannelProperties properties;
|
||||||
|
/**
|
||||||
|
* 错误码枚举类
|
||||||
|
*/
|
||||||
|
protected final SmsCodeMapping codeMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端有参构造函数
|
||||||
|
*
|
||||||
|
* @param properties 短信配置
|
||||||
|
*/
|
||||||
|
public AbstractSmsClient(SmsChannelProperties properties, SmsCodeMapping codeMapping) {
|
||||||
|
this.properties = properties;
|
||||||
|
this.codeMapping = codeMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*/
|
||||||
|
public final void init() {
|
||||||
|
doInit();
|
||||||
|
log.info("[init][配置({}) 初始化完成]", properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void refresh(SmsChannelProperties properties) {
|
||||||
|
// 判断是否更新
|
||||||
|
if (properties.equals(this.properties)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("[refresh][配置({})发生变化,重新初始化]", properties);
|
||||||
|
this.properties = properties;
|
||||||
|
// 初始化
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义初始化
|
||||||
|
*/
|
||||||
|
protected abstract void doInit();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getId() {
|
||||||
|
return properties.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final SmsCommonResult<SmsSendRespDTO> sendSms(Long logId, String mobile,
|
||||||
|
String apiTemplateId, List<KeyValue<String, Object>> templateParams) {
|
||||||
|
// 执行短信发送
|
||||||
|
SmsCommonResult<SmsSendRespDTO> result;
|
||||||
|
try {
|
||||||
|
result = doSendSms(logId, mobile, apiTemplateId, templateParams);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
// 打印异常日志
|
||||||
|
log.error("[sendSms][发送短信异常,sendLogId({}) mobile({}) apiTemplateId({}) templateParams({})]",
|
||||||
|
logId, mobile, apiTemplateId, templateParams, ex);
|
||||||
|
// 封装返回
|
||||||
|
return SmsCommonResult.error(ex);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract SmsCommonResult<SmsSendRespDTO> doSendSms(Long sendLogId, String mobile,
|
||||||
|
String apiTemplateId, List<KeyValue<String, Object>> templateParams)
|
||||||
|
throws Throwable;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SmsReceiveRespDTO> parseSmsReceiveStatus(String text) throws Throwable {
|
||||||
|
try {
|
||||||
|
return doParseSmsReceiveStatus(text);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
log.error("[parseSmsReceiveStatus][text({}) 解析发生异常]", text, ex);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract List<SmsReceiveRespDTO> doParseSmsReceiveStatus(String text) throws Throwable;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SmsCommonResult<SmsTemplateRespDTO> getSmsTemplate(String apiTemplateId) {
|
||||||
|
// 执行短信发送
|
||||||
|
SmsCommonResult<SmsTemplateRespDTO> result;
|
||||||
|
try {
|
||||||
|
result = doGetSmsTemplate(apiTemplateId);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
// 打印异常日志
|
||||||
|
log.error("[getSmsTemplate][获得短信模板({}) 发生异常]", apiTemplateId, ex);
|
||||||
|
// 封装返回
|
||||||
|
return SmsCommonResult.error(ex);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract SmsCommonResult<SmsTemplateRespDTO> doGetSmsTemplate(String apiTemplateId) throws Throwable;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsClientFactory;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun.AliyunSmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.debug.DebugDingTalkSmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.yunpian.YunpianSmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端工厂接口
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class SmsClientFactoryImpl implements SmsClientFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端 Map
|
||||||
|
* key:渠道编号,使用 {@link SmsChannelProperties#getId()}
|
||||||
|
*/
|
||||||
|
private final ConcurrentMap<Long, AbstractSmsClient> channelIdClients = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信客户端 Map
|
||||||
|
* key:渠道编码,使用 {@link SmsChannelProperties#getCode()} ()}
|
||||||
|
*
|
||||||
|
* 注意,一些场景下,需要获得某个渠道类型的客户端,所以需要使用它。
|
||||||
|
* 例如说,解析短信接收结果,是相对通用的,不需要使用某个渠道编号的 {@link #channelIdClients}
|
||||||
|
*/
|
||||||
|
private final ConcurrentMap<String, AbstractSmsClient> channelCodeClients = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public SmsClientFactoryImpl() {
|
||||||
|
// 初始化 channelCodeClients 集合
|
||||||
|
Arrays.stream(SmsChannelEnum.values()).forEach(channel -> {
|
||||||
|
// 创建一个空的 SmsChannelProperties 对象
|
||||||
|
SmsChannelProperties properties = new SmsChannelProperties().setCode(channel.getCode())
|
||||||
|
.setApiKey("default").setApiSecret("default");
|
||||||
|
// 创建 Sms 客户端
|
||||||
|
AbstractSmsClient smsClient = createSmsClient(properties);
|
||||||
|
channelCodeClients.put(channel.getCode(), smsClient);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SmsClient getSmsClient(Long channelId) {
|
||||||
|
return channelIdClients.get(channelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SmsClient getSmsClient(String channelCode) {
|
||||||
|
return channelCodeClients.get(channelCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createOrUpdateSmsClient(SmsChannelProperties properties) {
|
||||||
|
AbstractSmsClient client = channelIdClients.get(properties.getId());
|
||||||
|
if (client == null) {
|
||||||
|
client = this.createSmsClient(properties);
|
||||||
|
client.init();
|
||||||
|
channelIdClients.put(client.getId(), client);
|
||||||
|
} else {
|
||||||
|
client.refresh(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractSmsClient createSmsClient(SmsChannelProperties properties) {
|
||||||
|
SmsChannelEnum channelEnum = SmsChannelEnum.getByCode(properties.getCode());
|
||||||
|
Assert.notNull(channelEnum, String.format("渠道类型(%s) 为空", channelEnum));
|
||||||
|
// 创建客户端
|
||||||
|
switch (channelEnum) {
|
||||||
|
case ALIYUN: return new AliyunSmsClient(properties);
|
||||||
|
case YUN_PIAN: return new YunpianSmsClient(properties);
|
||||||
|
case DEBUG_DING_TALK: return new DebugDingTalkSmsClient(properties);
|
||||||
|
}
|
||||||
|
// 创建失败,错误日志 + 抛出异常
|
||||||
|
log.error("[createSmsClient][配置({}) 找不到合适的客户端实现]", properties);
|
||||||
|
throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,212 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.dashboard.common.core.KeyValue;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsTemplateRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
import cn.iocoder.dashboard.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
|
import com.aliyuncs.AcsRequest;
|
||||||
|
import com.aliyuncs.AcsResponse;
|
||||||
|
import com.aliyuncs.DefaultAcsClient;
|
||||||
|
import com.aliyuncs.IAcsClient;
|
||||||
|
import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateRequest;
|
||||||
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||||
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
|
import com.aliyuncs.profile.DefaultProfile;
|
||||||
|
import com.aliyuncs.profile.IClientProfile;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
import static cn.iocoder.dashboard.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里短信客户端的实现类
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 2021/1/25 14:17
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class AliyunSmsClient extends AbstractSmsClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REGION, 使用杭州
|
||||||
|
*/
|
||||||
|
private static final String ENDPOINT = "cn-hangzhou";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云客户端
|
||||||
|
*/
|
||||||
|
private volatile IAcsClient client;
|
||||||
|
|
||||||
|
public AliyunSmsClient(SmsChannelProperties properties) {
|
||||||
|
super(properties, new AliyunSmsCodeMapping());
|
||||||
|
Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空");
|
||||||
|
Assert.notEmpty(properties.getApiSecret(), "apiSecret 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doInit() {
|
||||||
|
IClientProfile profile = DefaultProfile.getProfile(ENDPOINT, properties.getApiKey(), properties.getApiSecret());
|
||||||
|
client = new DefaultAcsClient(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SmsCommonResult<SmsSendRespDTO> doSendSms(Long sendLogId, String mobile,
|
||||||
|
String apiTemplateId, List<KeyValue<String, Object>> templateParams) {
|
||||||
|
// 构建参数
|
||||||
|
SendSmsRequest request = new SendSmsRequest();
|
||||||
|
request.setPhoneNumbers(mobile);
|
||||||
|
request.setSignName(properties.getSignature());
|
||||||
|
request.setTemplateCode(apiTemplateId);
|
||||||
|
request.setTemplateParam(JsonUtils.toJsonString(MapUtils.convertMap(templateParams)));
|
||||||
|
request.setOutId(String.valueOf(sendLogId));
|
||||||
|
// 执行请求
|
||||||
|
return invoke(request, response -> new SmsSendRespDTO().setSerialNo(response.getBizId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SmsReceiveRespDTO> doParseSmsReceiveStatus(String text) throws Throwable {
|
||||||
|
List<SmsReceiveStatus> statuses = JsonUtils.parseArray(text, SmsReceiveStatus.class);
|
||||||
|
return statuses.stream().map(status -> {
|
||||||
|
SmsReceiveRespDTO resp = new SmsReceiveRespDTO();
|
||||||
|
resp.setSuccess(status.getSuccess());
|
||||||
|
resp.setErrorCode(status.getErrCode()).setErrorMsg(status.getErrMsg());
|
||||||
|
resp.setMobile(status.getPhoneNumber()).setReceiveTime(status.getReportTime());
|
||||||
|
resp.setSerialNo(status.getBizId()).setLogId(Long.valueOf(status.getOutId()));
|
||||||
|
return resp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SmsCommonResult<SmsTemplateRespDTO> doGetSmsTemplate(String apiTemplateId) {
|
||||||
|
// 构建参数
|
||||||
|
QuerySmsTemplateRequest request = new QuerySmsTemplateRequest();
|
||||||
|
request.setTemplateCode(apiTemplateId);
|
||||||
|
// 执行请求
|
||||||
|
return invoke(request, response -> {
|
||||||
|
SmsTemplateRespDTO data = new SmsTemplateRespDTO();
|
||||||
|
data.setId(response.getTemplateCode()).setContent(response.getTemplateContent());
|
||||||
|
data.setAuditStatus(convertSmsTemplateAuditStatus(response.getTemplateStatus())).setAuditReason(response.getReason());
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
Integer convertSmsTemplateAuditStatus(Integer templateStatus) {
|
||||||
|
switch (templateStatus) {
|
||||||
|
case 0: return SmsTemplateAuditStatusEnum.CHECKING.getStatus();
|
||||||
|
case 1: return SmsTemplateAuditStatusEnum.SUCCESS.getStatus();
|
||||||
|
case 2: return SmsTemplateAuditStatusEnum.FAIL.getStatus();
|
||||||
|
default: throw new IllegalArgumentException(String.format("未知审核状态(%d)", templateStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
<T extends AcsResponse, R> SmsCommonResult<R> invoke(AcsRequest<T> request, Function<T, R> responseConsumer) {
|
||||||
|
try {
|
||||||
|
// 执行发送. 由于阿里云 sms 短信没有统一的 Response,但是有统一的 code、message、requestId 属性,所以只好反射
|
||||||
|
T sendResult = client.getAcsResponse(request);
|
||||||
|
String code = (String) ReflectUtil.getFieldValue(sendResult, "code");
|
||||||
|
String message = (String) ReflectUtil.getFieldValue(sendResult, "message");
|
||||||
|
String requestId = (String) ReflectUtil.getFieldValue(sendResult, "requestId");
|
||||||
|
// 解析结果
|
||||||
|
R data = null;
|
||||||
|
if (Objects.equals(code, "OK")) { // 请求成功的情况下
|
||||||
|
data = responseConsumer.apply(sendResult);
|
||||||
|
}
|
||||||
|
// 拼接结果
|
||||||
|
return SmsCommonResult.build(code, message, requestId, data, codeMapping);
|
||||||
|
} catch (ClientException ex) {
|
||||||
|
return SmsCommonResult.build(ex.getErrCode(), formatResultMsg(ex), ex.getRequestId(), null, codeMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatResultMsg(ClientException ex) {
|
||||||
|
if (StrUtil.isEmpty(ex.getErrorDescription())) {
|
||||||
|
return ex.getErrMsg();
|
||||||
|
}
|
||||||
|
return ex.getErrMsg() + " => " + ex.getErrorDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接收状态
|
||||||
|
*
|
||||||
|
* 参见 https://help.aliyun.com/document_detail/101867.html 文档
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class SmsReceiveStatus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
@JsonProperty("phone_number")
|
||||||
|
private String phoneNumber;
|
||||||
|
/**
|
||||||
|
* 发送时间
|
||||||
|
*/
|
||||||
|
@JsonProperty("send_time")
|
||||||
|
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||||
|
private Date sendTime;
|
||||||
|
/**
|
||||||
|
* 状态报告时间
|
||||||
|
*/
|
||||||
|
@JsonProperty("report_time")
|
||||||
|
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||||
|
private Date reportTime;
|
||||||
|
/**
|
||||||
|
* 是否接收成功
|
||||||
|
*/
|
||||||
|
private Boolean success;
|
||||||
|
/**
|
||||||
|
* 状态报告说明
|
||||||
|
*/
|
||||||
|
@JsonProperty("err_msg")
|
||||||
|
private String errMsg;
|
||||||
|
/**
|
||||||
|
* 状态报告编码
|
||||||
|
*/
|
||||||
|
@JsonProperty("err_code")
|
||||||
|
private String errCode;
|
||||||
|
/**
|
||||||
|
* 发送序列号
|
||||||
|
*/
|
||||||
|
@JsonProperty("biz_id")
|
||||||
|
private String bizId;
|
||||||
|
/**
|
||||||
|
* 用户序列号
|
||||||
|
*
|
||||||
|
* 这里我们传递的是 SysSmsLogDO 的日志编号
|
||||||
|
*/
|
||||||
|
@JsonProperty("out_id")
|
||||||
|
private String outId;
|
||||||
|
/**
|
||||||
|
* 短信长度,例如说 1、2、3
|
||||||
|
*
|
||||||
|
* 140 字节算一条短信,短信长度超过 140 字节时会拆分成多条短信发送
|
||||||
|
*/
|
||||||
|
@JsonProperty("sms_size")
|
||||||
|
private Integer smsSize;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCodeMapping;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.framework.sms.core.enums.SmsFrameworkErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云的 SmsCodeMapping 实现类
|
||||||
|
*
|
||||||
|
* 参见 https://help.aliyun.com/document_detail/101346.htm 文档
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class AliyunSmsCodeMapping implements SmsCodeMapping {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorCode apply(String apiCode) {
|
||||||
|
switch (apiCode) {
|
||||||
|
case "OK": return GlobalErrorCodeConstants.SUCCESS;
|
||||||
|
case "isv.ACCOUNT_NOT_EXISTS":
|
||||||
|
case "isv.ACCOUNT_ABNORMAL":
|
||||||
|
case "MissingAccessKeyId": return SMS_ACCOUNT_INVALID;
|
||||||
|
case "isp.RAM_PERMISSION_DENY": return SMS_PERMISSION_DENY;
|
||||||
|
case "isv.INVALID_JSON_PARAM":
|
||||||
|
case "isv.INVALID_PARAMETERS": return SMS_API_PARAM_ERROR;
|
||||||
|
case "isv.BUSINESS_LIMIT_CONTROL": return SMS_SEND_BUSINESS_LIMIT_CONTROL;
|
||||||
|
case "isv.DAY_LIMIT_CONTROL": return SMS_SEND_DAY_LIMIT_CONTROL;
|
||||||
|
case "isv.SMS_CONTENT_ILLEGAL": return SMS_SEND_CONTENT_INVALID;
|
||||||
|
case "isv.SMS_TEMPLATE_ILLEGAL": return SMS_TEMPLATE_INVALID;
|
||||||
|
case "isv.SMS_SIGNATURE_ILLEGAL":
|
||||||
|
case "isv.SIGN_NAME_ILLEGAL":
|
||||||
|
case "isv.SMS_SIGN_ILLEGAL": return SMS_SIGN_INVALID;
|
||||||
|
case "isv.AMOUNT_NOT_ENOUGH":
|
||||||
|
case "isv.OUT_OF_SERVICE": return SMS_ACCOUNT_MONEY_NOT_ENOUGH;
|
||||||
|
case "isv.MOBILE_NUMBER_ILLEGAL": return SMS_MOBILE_INVALID;
|
||||||
|
case "isv.TEMPLATE_MISSING_PARAMETERS": return SMS_TEMPLATE_PARAM_ERROR;
|
||||||
|
}
|
||||||
|
return SMS_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.debug;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCodeMapping;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.framework.sms.core.enums.SmsFrameworkErrorCodeConstants.SMS_UNKNOWN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钉钉的 SmsCodeMapping 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class DebugDingTalkCodeMapping implements SmsCodeMapping {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorCode apply(String apiCode) {
|
||||||
|
return Objects.equals(apiCode, "0") ? GlobalErrorCodeConstants.SUCCESS : SMS_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.debug;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
|
import cn.hutool.crypto.digest.HmacAlgorithm;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import cn.iocoder.dashboard.common.core.KeyValue;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsTemplateRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
import cn.iocoder.dashboard.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基于钉钉 WebHook 实现的调试的短信客户端实现类
|
||||||
|
*
|
||||||
|
* 考虑到省钱,我们使用钉钉 WebHook 模拟发送短信,方便调试。
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class DebugDingTalkSmsClient extends AbstractSmsClient {
|
||||||
|
|
||||||
|
public DebugDingTalkSmsClient(SmsChannelProperties properties) {
|
||||||
|
super(properties, new DebugDingTalkCodeMapping());
|
||||||
|
Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空");
|
||||||
|
Assert.notEmpty(properties.getApiSecret(), "apiSecret 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SmsCommonResult<SmsSendRespDTO> doSendSms(Long sendLogId, String mobile,
|
||||||
|
String apiTemplateId, List<KeyValue<String, Object>> templateParams) throws Throwable {
|
||||||
|
// 构建请求
|
||||||
|
String url = buildUrl("robot/send");
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("msgtype", "text");
|
||||||
|
String content = String.format("【模拟短信】\n手机号:%s\n短信日志编号:%d\n模板参数:%s",
|
||||||
|
mobile, sendLogId, MapUtils.convertMap(templateParams));
|
||||||
|
params.put("text", MapUtil.builder().put("content", content).build());
|
||||||
|
// 执行请求
|
||||||
|
String responseText = HttpUtil.post(url, JsonUtils.toJsonString(params));
|
||||||
|
// 解析结果
|
||||||
|
Map<?, ?> responseObj = JsonUtils.parseObject(responseText, Map.class);
|
||||||
|
return SmsCommonResult.build(MapUtil.getStr(responseObj, "errcode"), MapUtil.getStr(responseObj, "errorMsg"),
|
||||||
|
null, new SmsSendRespDTO().setSerialNo(StrUtil.uuid()), codeMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建请求地址
|
||||||
|
*
|
||||||
|
* 参见 https://developers.dingtalk.com/document/app/custom-robot-access/title-nfv-794-g71 文档
|
||||||
|
*
|
||||||
|
* @param path 请求路径
|
||||||
|
* @return 请求地址
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private String buildUrl(String path) {
|
||||||
|
// 生成 timestamp
|
||||||
|
long timestamp = System.currentTimeMillis();
|
||||||
|
// 生成 sign
|
||||||
|
String secret = properties.getApiSecret();
|
||||||
|
String stringToSign = timestamp + "\n" + secret;
|
||||||
|
byte[] signData = DigestUtil.hmac(HmacAlgorithm.HmacSHA256, StrUtil.bytes(secret)).digest(stringToSign);
|
||||||
|
String sign = Base64.encode(signData);
|
||||||
|
// 构建最终 URL
|
||||||
|
return String.format("https://oapi.dingtalk.com/%s?access_token=%s×tamp=%d&sign=%s",
|
||||||
|
path, properties.getApiKey(), timestamp, sign);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SmsReceiveRespDTO> doParseSmsReceiveStatus(String text) throws Throwable {
|
||||||
|
throw new UnsupportedOperationException("模拟短信客户端,暂时无需解析回调");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SmsCommonResult<SmsTemplateRespDTO> doGetSmsTemplate(String apiTemplateId) {
|
||||||
|
SmsTemplateRespDTO data = new SmsTemplateRespDTO().setId(apiTemplateId).setContent("")
|
||||||
|
.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus()).setAuditReason("");
|
||||||
|
return SmsCommonResult.build("0", "success", null, data, codeMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,204 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.yunpian;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.core.util.URLUtil;
|
||||||
|
import cn.iocoder.dashboard.common.core.KeyValue;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsTemplateRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
import cn.iocoder.dashboard.util.json.JsonUtils;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.yunpian.sdk.YunpianClient;
|
||||||
|
import com.yunpian.sdk.constant.YunpianConstant;
|
||||||
|
import com.yunpian.sdk.model.Result;
|
||||||
|
import com.yunpian.sdk.model.Template;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
import static cn.iocoder.dashboard.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云片短信客户端的实现类
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 9:48 2021/3/5
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class YunpianSmsClient extends AbstractSmsClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云信短信客户端
|
||||||
|
*/
|
||||||
|
private volatile YunpianClient client;
|
||||||
|
|
||||||
|
public YunpianSmsClient(SmsChannelProperties properties) {
|
||||||
|
super(properties, new YunpianSmsCodeMapping());
|
||||||
|
Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doInit() {
|
||||||
|
YunpianClient oldClient = client;
|
||||||
|
// 初始化新的客户端
|
||||||
|
YunpianClient newClient = new YunpianClient(properties.getApiKey());
|
||||||
|
newClient.init();
|
||||||
|
this.client = newClient;
|
||||||
|
// 销毁老的客户端
|
||||||
|
if (oldClient != null) {
|
||||||
|
oldClient.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SmsCommonResult<SmsSendRespDTO> doSendSms(Long sendLogId, String mobile,
|
||||||
|
String apiTemplateId, List<KeyValue<String, Object>> templateParams) throws Throwable {
|
||||||
|
return invoke(() -> {
|
||||||
|
Map<String, String> request = new HashMap<>();
|
||||||
|
request.put(YunpianConstant.MOBILE, mobile);
|
||||||
|
request.put(YunpianConstant.TPL_ID, apiTemplateId);
|
||||||
|
request.put(YunpianConstant.TPL_VALUE, formatTplValue(templateParams));
|
||||||
|
request.put(YunpianConstant.UID, String.valueOf(sendLogId));
|
||||||
|
request.put(YunpianConstant.CALLBACK_URL, properties.getCallbackUrl());
|
||||||
|
return client.sms().tpl_single_send(request);
|
||||||
|
}, response -> new SmsSendRespDTO().setSerialNo(String.valueOf(response.getSid())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatTplValue(List<KeyValue<String, Object>> templateParams) {
|
||||||
|
if (CollUtil.isEmpty(templateParams)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
// 参考 https://www.yunpian.com/official/document/sms/zh_cn/introduction_demos_encode_sample 格式化
|
||||||
|
StringJoiner joiner = new StringJoiner("&");
|
||||||
|
templateParams.forEach(param -> joiner.add(String.format("#%s#=%s", param.getKey(), URLUtil.encode(String.valueOf(param.getValue())))));
|
||||||
|
return joiner.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SmsReceiveRespDTO> doParseSmsReceiveStatus(String text) throws Throwable {
|
||||||
|
List<SmsReceiveStatus> statuses = JsonUtils.parseArray(text, SmsReceiveStatus.class);
|
||||||
|
return statuses.stream().map(status -> {
|
||||||
|
SmsReceiveRespDTO resp = new SmsReceiveRespDTO();
|
||||||
|
resp.setSuccess(Objects.equals(status.getReportStatus(), "SUCCESS"));
|
||||||
|
resp.setErrorCode(status.getErrorMsg()).setErrorMsg(status.getErrorDetail());
|
||||||
|
resp.setMobile(status.getMobile()).setReceiveTime(status.getUserReceiveTime());
|
||||||
|
resp.setSerialNo(String.valueOf(status.getSid())).setLogId(status.getUid());
|
||||||
|
return resp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SmsCommonResult<SmsTemplateRespDTO> doGetSmsTemplate(String apiTemplateId) throws Throwable {
|
||||||
|
return invoke(() -> {
|
||||||
|
Map<String, String> request = new HashMap<>();
|
||||||
|
request.put(YunpianConstant.APIKEY, properties.getApiKey());
|
||||||
|
request.put(YunpianConstant.TPL_ID, apiTemplateId);
|
||||||
|
return client.tpl().get(request);
|
||||||
|
}, response -> {
|
||||||
|
Template template = response.get(0);
|
||||||
|
return new SmsTemplateRespDTO().setId(String.valueOf(template.getTpl_id())).setContent(template.getTpl_content())
|
||||||
|
.setAuditStatus(convertSmsTemplateAuditStatus(template.getCheck_status())).setAuditReason(template.getReason());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
Integer convertSmsTemplateAuditStatus(String checkStatus) {
|
||||||
|
switch (checkStatus) {
|
||||||
|
case "CHECKING": return SmsTemplateAuditStatusEnum.CHECKING.getStatus();
|
||||||
|
case "SUCCESS": return SmsTemplateAuditStatusEnum.SUCCESS.getStatus();
|
||||||
|
case "FAIL": return SmsTemplateAuditStatusEnum.FAIL.getStatus();
|
||||||
|
default: throw new IllegalArgumentException(String.format("未知审核状态(%s)", checkStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
<T, R> SmsCommonResult<R> invoke(Supplier<Result<T>> requestConsumer, Function<T, R> responseConsumer) throws Throwable {
|
||||||
|
// 执行请求
|
||||||
|
Result<T> result = requestConsumer.get();
|
||||||
|
if (result.getThrowable() != null) {
|
||||||
|
throw result.getThrowable();
|
||||||
|
}
|
||||||
|
// 解析结果
|
||||||
|
R data = null;
|
||||||
|
if (result.getData() != null) {
|
||||||
|
data = responseConsumer.apply(result.getData());
|
||||||
|
}
|
||||||
|
// 拼接结果
|
||||||
|
return SmsCommonResult.build(String.valueOf(result.getCode()), formatResultMsg(result), null, data, codeMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatResultMsg(Result<?> sendResult) {
|
||||||
|
if (StrUtil.isEmpty(sendResult.getDetail())) {
|
||||||
|
return sendResult.getMsg();
|
||||||
|
}
|
||||||
|
return sendResult.getMsg() + " => " + sendResult.getDetail();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接收状态
|
||||||
|
*
|
||||||
|
* 参见 https://www.yunpian.com/official/document/sms/zh_cn/domestic_push_report 文档
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class SmsReceiveStatus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收状态
|
||||||
|
*
|
||||||
|
* 目前仅有 SUCCESS / FAIL,所以使用 Boolean 接收
|
||||||
|
*/
|
||||||
|
@JsonProperty("report_status")
|
||||||
|
private String reportStatus;
|
||||||
|
/**
|
||||||
|
* 接收手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 运营商返回的代码,如:"DB:0103"
|
||||||
|
*
|
||||||
|
* 由于不同运营商信息不同,此字段仅供参考;
|
||||||
|
*/
|
||||||
|
@JsonProperty("error_msg")
|
||||||
|
private String errorMsg;
|
||||||
|
/**
|
||||||
|
* 运营商反馈代码的中文解释
|
||||||
|
*
|
||||||
|
* 默认不推送此字段,如需推送,请联系客服
|
||||||
|
*/
|
||||||
|
@JsonProperty("error_detail")
|
||||||
|
private String errorDetail;
|
||||||
|
/**
|
||||||
|
* 短信编号
|
||||||
|
*/
|
||||||
|
private Long sid;
|
||||||
|
/**
|
||||||
|
* 用户自定义 id
|
||||||
|
*
|
||||||
|
* 这里我们传递的是 SysSmsLogDO 的日志编号
|
||||||
|
*/
|
||||||
|
private Long uid;
|
||||||
|
/**
|
||||||
|
* 用户接收时间
|
||||||
|
*/
|
||||||
|
@JsonProperty("user_receive_time")
|
||||||
|
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||||
|
private Date userReceiveTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.yunpian;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCodeMapping;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants.SUCCESS;
|
||||||
|
import static cn.iocoder.dashboard.framework.sms.core.enums.SmsFrameworkErrorCodeConstants.*;
|
||||||
|
import static com.yunpian.sdk.constant.Code.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云片的 SmsCodeMapping 实现类
|
||||||
|
*
|
||||||
|
* 参见 https://www.yunpian.com/official/document/sms/zh_CN/returnvalue_common 文档
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class YunpianSmsCodeMapping implements SmsCodeMapping {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorCode apply(String apiCode) {
|
||||||
|
int code = Integer.parseInt(apiCode);
|
||||||
|
switch (code) {
|
||||||
|
case OK: return SUCCESS;
|
||||||
|
case ARGUMENT_MISSING: return SMS_API_PARAM_ERROR;
|
||||||
|
case BAD_ARGUMENT_FORMAT: return SMS_TEMPLATE_PARAM_ERROR;
|
||||||
|
case TPL_NOT_FOUND:
|
||||||
|
case TPL_NOT_VALID: return SMS_TEMPLATE_INVALID;
|
||||||
|
case MONEY_NOT_ENOUGH: return SMS_ACCOUNT_MONEY_NOT_ENOUGH;
|
||||||
|
case BLACK_WORD: return SMS_SEND_CONTENT_INVALID;
|
||||||
|
case DUP_IN_SHORT_TIME:
|
||||||
|
case TOO_MANY_TIME_IN_5:
|
||||||
|
case DAY_LIMIT_PER_MOBILE:
|
||||||
|
case HOUR_LIMIT_PER_MOBILE: return SMS_SEND_BUSINESS_LIMIT_CONTROL;
|
||||||
|
case BLACK_PHONE_FILTER: return SMS_MOBILE_BLACK;
|
||||||
|
case SIGN_NOT_MATCH:
|
||||||
|
case BAD_SIGN_FORMAT:
|
||||||
|
case SIGN_NOT_VALID: return SMS_SIGN_INVALID;
|
||||||
|
case BAD_API_KEY: return SMS_ACCOUNT_INVALID;
|
||||||
|
case API_NOT_ALLOWED: return SMS_PERMISSION_DENY;
|
||||||
|
case IP_NOT_ALLOWED: return SMS_IP_DENY;
|
||||||
|
}
|
||||||
|
return SMS_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信渠道枚举
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 2021/1/25 10:56
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum SmsChannelEnum {
|
||||||
|
|
||||||
|
DEBUG_DING_TALK("DEBUG_DING_TALK", "调试(钉钉)"),
|
||||||
|
YUN_PIAN("YUN_PIAN", "云片"),
|
||||||
|
ALIYUN("ALIYUN", "阿里云"),
|
||||||
|
// TENCENT("TENCENT", "腾讯云"),
|
||||||
|
// HUA_WEI("HUA_WEI", "华为云"),
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private final String code;
|
||||||
|
/**
|
||||||
|
* 名字
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public static SmsChannelEnum getByCode(String code) {
|
||||||
|
return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.enums;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信框架的错误码枚举
|
||||||
|
*
|
||||||
|
* 短信框架,使用 2-001-000-000 段
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface SmsFrameworkErrorCodeConstants {
|
||||||
|
|
||||||
|
ErrorCode SMS_UNKNOWN = new ErrorCode(2001000000, "未知错误,需要解析");
|
||||||
|
|
||||||
|
// ========== 权限 / 限流等相关 2001000100 ==========
|
||||||
|
|
||||||
|
ErrorCode SMS_PERMISSION_DENY = new ErrorCode(2001000100, "没有发送短信的权限");
|
||||||
|
// 云片:可以配置 IP 白名单,只有在白名单中才可以发送短信
|
||||||
|
ErrorCode SMS_IP_DENY = new ErrorCode(2001000100, "IP 不允许发送短信");
|
||||||
|
|
||||||
|
// 阿里云:将短信发送频率限制在正常的业务限流范围内。默认短信验证码:使用同一签名,对同一个手机号验证码,支持 1 条 / 分钟,5 条 / 小时,累计 10 条 / 天。
|
||||||
|
ErrorCode SMS_SEND_BUSINESS_LIMIT_CONTROL = new ErrorCode(2001000102, "指定手机的发送限流");
|
||||||
|
// 阿里云:已经达到您在控制台设置的短信日发送量限额值。在国内消息设置 > 安全设置,修改发送总量阈值。
|
||||||
|
ErrorCode SMS_SEND_DAY_LIMIT_CONTROL = new ErrorCode(2001000103, "每天的发送限流");
|
||||||
|
|
||||||
|
ErrorCode SMS_SEND_CONTENT_INVALID = new ErrorCode(2001000104, "短信内容有敏感词");
|
||||||
|
|
||||||
|
// ========== 模板相关 2001000200 ==========
|
||||||
|
ErrorCode SMS_TEMPLATE_INVALID = new ErrorCode(2001000200, "短信模板不合法"); // 包括短信模板不存在
|
||||||
|
ErrorCode SMS_TEMPLATE_PARAM_ERROR = new ErrorCode(2001000201, "模板参数不正确");
|
||||||
|
|
||||||
|
// ========== 签名相关 2001000300 ==========
|
||||||
|
ErrorCode SMS_SIGN_INVALID = new ErrorCode(2001000300, "短信签名不可用");
|
||||||
|
|
||||||
|
// ========== 账户相关 2001000400 ==========
|
||||||
|
ErrorCode SMS_ACCOUNT_MONEY_NOT_ENOUGH = new ErrorCode(2001000400, "账户余额不足");
|
||||||
|
ErrorCode SMS_ACCOUNT_INVALID = new ErrorCode(2001000401, "apiKey 不存在");
|
||||||
|
|
||||||
|
// ========== 其它相关 2001000900 开头 ==========
|
||||||
|
ErrorCode SMS_API_PARAM_ERROR = new ErrorCode(2001000900, "请求参数缺失");
|
||||||
|
ErrorCode SMS_MOBILE_INVALID = new ErrorCode(2001000901, "手机格式不正确");
|
||||||
|
ErrorCode SMS_MOBILE_BLACK = new ErrorCode(2001000902, "手机号在黑名单中");
|
||||||
|
|
||||||
|
ErrorCode EXCEPTION = new ErrorCode(2001000999, "调用异常");
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信模板的审核状态枚举
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum SmsTemplateAuditStatusEnum {
|
||||||
|
|
||||||
|
CHECKING(1),
|
||||||
|
SUCCESS(2),
|
||||||
|
FAIL(3);
|
||||||
|
|
||||||
|
private final Integer status;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.property;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信渠道配置类
|
||||||
|
*
|
||||||
|
* @author zzf
|
||||||
|
* @date 2021/1/25 17:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Validated
|
||||||
|
public class SmsChannelProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "短信渠道 ID 不能为空")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 短信签名
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "短信签名不能为空")
|
||||||
|
private String signature;
|
||||||
|
/**
|
||||||
|
* 渠道编码
|
||||||
|
*
|
||||||
|
* 枚举 {@link SmsChannelEnum}
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "渠道编码不能为空")
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 短信 API 的账号
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "短信 API 的账号不能为空")
|
||||||
|
private String apiKey;
|
||||||
|
/**
|
||||||
|
* 短信 API 的秘钥
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "短信 API 的秘钥不能为空")
|
||||||
|
private String apiSecret;
|
||||||
|
/**
|
||||||
|
* 短信发送回调 URL
|
||||||
|
*/
|
||||||
|
private String callbackUrl;
|
||||||
|
|
||||||
|
}
|
@ -10,15 +10,17 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.service.*;
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.ApiKey;
|
||||||
|
import springfox.documentation.service.AuthorizationScope;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.service.SecurityReference;
|
||||||
|
import springfox.documentation.service.SecurityScheme;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
import springfox.documentation.service.ApiKey;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@ package cn.iocoder.dashboard.framework.web.config;
|
|||||||
|
|
||||||
import cn.iocoder.dashboard.framework.web.core.enums.FilterOrderEnum;
|
import cn.iocoder.dashboard.framework.web.core.enums.FilterOrderEnum;
|
||||||
import cn.iocoder.dashboard.framework.web.core.filter.CacheRequestBodyFilter;
|
import cn.iocoder.dashboard.framework.web.core.filter.CacheRequestBodyFilter;
|
||||||
|
import cn.iocoder.dashboard.framework.web.core.filter.DemoFilter;
|
||||||
import cn.iocoder.dashboard.framework.web.core.filter.XssFilter;
|
import cn.iocoder.dashboard.framework.web.core.filter.XssFilter;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -27,9 +29,10 @@ public class WebConfiguration implements WebMvcConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
|
// 设置 API 前缀,仅仅匹配 controller 包下的
|
||||||
configurer.addPathPrefix(webProperties.getApiPrefix(), clazz ->
|
configurer.addPathPrefix(webProperties.getApiPrefix(), clazz ->
|
||||||
clazz.isAnnotationPresent(RestController.class)
|
clazz.isAnnotationPresent(RestController.class)
|
||||||
&& clazz.getPackage().getName().startsWith(webProperties.getControllerPackage()));
|
&& clazz.getPackage().getName().startsWith(webProperties.getControllerPackage())); // 仅仅匹配 controller 包
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Filter 相关 ==========
|
// ========== Filter 相关 ==========
|
||||||
@ -67,6 +70,15 @@ public class WebConfiguration implements WebMvcConfigurer {
|
|||||||
return createFilterBean(new XssFilter(properties, pathMatcher), FilterOrderEnum.XSS_FILTER);
|
return createFilterBean(new XssFilter(properties, pathMatcher), FilterOrderEnum.XSS_FILTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 DemoFilter Bean,演示模式
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(value = "yudao.demo", havingValue = "true")
|
||||||
|
public FilterRegistrationBean<DemoFilter> demoFilter() {
|
||||||
|
return createFilterBean(new DemoFilter(), FilterOrderEnum.DEMO_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
private static <T extends Filter> FilterRegistrationBean<T> createFilterBean(T filter, Integer order) {
|
private static <T extends Filter> FilterRegistrationBean<T> createFilterBean(T filter, Integer order) {
|
||||||
FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter);
|
FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter);
|
||||||
bean.setOrder(order);
|
bean.setOrder(order);
|
||||||
|
@ -9,6 +9,7 @@ public interface FilterOrderEnum {
|
|||||||
|
|
||||||
int CORS_FILTER = Integer.MIN_VALUE;
|
int CORS_FILTER = Integer.MIN_VALUE;
|
||||||
|
|
||||||
|
|
||||||
int REQUEST_BODY_CACHE_FILTER = Integer.MIN_VALUE + 500;
|
int REQUEST_BODY_CACHE_FILTER = Integer.MIN_VALUE + 500;
|
||||||
|
|
||||||
// OrderedRequestContextFilter 默认为 -105,用于国际化上下文等等
|
// OrderedRequestContextFilter 默认为 -105,用于国际化上下文等等
|
||||||
@ -19,4 +20,6 @@ public interface FilterOrderEnum {
|
|||||||
|
|
||||||
// Spring Security Filter 默认为 -100,可见 SecurityProperties 配置属性类
|
// Spring Security Filter 默认为 -100,可见 SecurityProperties 配置属性类
|
||||||
|
|
||||||
|
int DEMO_FILTER = Integer.MAX_VALUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user