mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-20 10:16:40 +08:00
Merge remote-tracking branch 'origin/dev' into 4.X
This commit is contained in:
commit
ebf780617a
@ -10,7 +10,7 @@ end_of_line = lf
|
|||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
[*.{json,yml}]
|
[*.{json,yml,yaml}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
|
12
.run/ruoyi-monitor-admin.run.xml
Normal file
12
.run/ruoyi-monitor-admin.run.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ruoyi-monitor-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||||
|
<deployment type="dockerfile">
|
||||||
|
<settings>
|
||||||
|
<option name="imageTag" value="ruoyi/ruoyi-monitor-admin:4.4.0" />
|
||||||
|
<option name="buildOnly" value="true" />
|
||||||
|
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-monitor-admin/Dockerfile" />
|
||||||
|
</settings>
|
||||||
|
</deployment>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
12
.run/ruoyi-server.run.xml
Normal file
12
.run/ruoyi-server.run.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ruoyi-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||||
|
<deployment type="dockerfile">
|
||||||
|
<settings>
|
||||||
|
<option name="imageTag" value="ruoyi/ruoyi-server:4.4.0" />
|
||||||
|
<option name="buildOnly" value="true" />
|
||||||
|
<option name="sourceFilePath" value="ruoyi-admin/Dockerfile" />
|
||||||
|
</settings>
|
||||||
|
</deployment>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
12
.run/ruoyi-xxl-job-admin.run.xml
Normal file
12
.run/ruoyi-xxl-job-admin.run.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ruoyi-xxl-job-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||||
|
<deployment type="dockerfile">
|
||||||
|
<settings>
|
||||||
|
<option name="imageTag" value="ruoyi/ruoyi-xxl-job-admin:4.4.0" />
|
||||||
|
<option name="buildOnly" value="true" />
|
||||||
|
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-xxl-job-admin/Dockerfile" />
|
||||||
|
</settings>
|
||||||
|
</deployment>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
26
README.md
26
README.md
@ -4,14 +4,17 @@
|
|||||||
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/blob/master/LICENSE)
|
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/blob/master/LICENSE)
|
||||||
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
||||||
<br>
|
<br>
|
||||||
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
|
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
|
|
||||||
> RuoYi-Vue-Plus 是重写 RuoYi-Vue 针对 `分布式集群` 场景全方位升级(不兼容原框架)
|
> RuoYi-Vue-Plus 是重写 RuoYi-Vue 针对 `分布式集群` 场景全方位升级(不兼容原框架)
|
||||||
|
|
||||||
> 系统演示: [传送门](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/系统演示?sort_id=4836388)
|
> 项目代码、文档 均开源免费可商用 遵循开源协议在项目中保留开源协议文件即可<br>
|
||||||
|
活到老写到老 为兴趣而开源 为学习而开源 为让大家真正可以学到技术而开源
|
||||||
|
|
||||||
|
> 系统演示: [传送门](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4836388&doc_id=1469725)
|
||||||
|
|
||||||
| 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 |
|
| 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 |
|
||||||
|----------|---------------------|---------------------------------------------------------------------------------------------------|----------------------------|
|
|----------|---------------------|---------------------------------------------------------------------------------------------------|----------------------------|
|
||||||
@ -38,7 +41,7 @@
|
|||||||
| 分布式队列 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 普通队列、延迟队列、优先队列 等 |
|
| 分布式队列 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 普通队列、延迟队列、优先队列 等 |
|
||||||
| 分布式锁 | Lock4j | [Lock4j官网](https://gitee.com/baomidou/lock4j) | 注解锁、工具锁 多种多样 |
|
| 分布式锁 | Lock4j | [Lock4j官网](https://gitee.com/baomidou/lock4j) | 注解锁、工具锁 多种多样 |
|
||||||
| 分布式幂等 | Redisson | [Lock4j文档](https://gitee.com/baomidou/lock4j) | 拦截重复提交 |
|
| 分布式幂等 | Redisson | [Lock4j文档](https://gitee.com/baomidou/lock4j) | 拦截重复提交 |
|
||||||
| 分布式日志 | TLog | [TLog文档](https://yomahub.com/tlog/docs) | 支持跟踪链路日志记录、性能分析、链路排查 |
|
| 分布式链路追踪 | Apache SkyWalking | [Apache SkyWalking文档](https://skywalking.apache.org/docs/) | 链路追踪、网格分析、度量聚合、可视化 |
|
||||||
| 分布式任务调度 | Xxl-Job | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/) | 高性能 高可靠 易扩展 |
|
| 分布式任务调度 | Xxl-Job | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/) | 高性能 高可靠 易扩展 |
|
||||||
| 文件存储 | Minio | [Minio文档](https://docs.min.io/) | 本地存储 |
|
| 文件存储 | Minio | [Minio文档](https://docs.min.io/) | 本地存储 |
|
||||||
| 文件存储 | 七牛、阿里、腾讯 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725) | 云存储 |
|
| 文件存储 | 七牛、阿里、腾讯 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725) | 云存储 |
|
||||||
@ -46,9 +49,9 @@
|
|||||||
| 监控框架 | SpringBoot-Admin | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/) | 全方位服务监控 |
|
| 监控框架 | SpringBoot-Admin | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/) | 全方位服务监控 |
|
||||||
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
|
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
|
||||||
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
|
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
|
||||||
| 文档框架 | Knife4j | [Knife4j文档](https://doc.xiaominfo.com/knife4j/documentation/) | 美化接口文档 |
|
| 文档框架 | SpringDoc、javadoc | [接口文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5805266&doc_id=1469725) | 无注解零入侵基于java注释 |
|
||||||
| 工具类框架 | Hutool、Lombok | [Hutool文档](https://www.hutool.cn/docs/) | 减少代码冗余 增加安全性 |
|
| 工具类框架 | Hutool、Lombok | [Hutool文档](https://www.hutool.cn/docs/) | 减少代码冗余 增加安全性 |
|
||||||
| 代码生成器 | 适配MP、Knife4j规范化代码 | [Hutool文档](https://www.hutool.cn/docs/) | 一键生成前后端代码 |
|
| 代码生成器 | 适配MP、SpringDoc规范化代码 | [代码生成文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5522329&doc_id=1469725) | 一键生成前后端代码 |
|
||||||
| 部署方式 | Docker | [Docker文档](https://docs.docker.com/) | 容器编排 一键部署业务集群 |
|
| 部署方式 | Docker | [Docker文档](https://docs.docker.com/) | 容器编排 一键部署业务集群 |
|
||||||
| 国际化 | SpringMessage | [SpringMVC文档](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc) | Spring标准国际化方案 |
|
| 国际化 | SpringMessage | [SpringMVC文档](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc) | Spring标准国际化方案 |
|
||||||
|
|
||||||
@ -56,11 +59,14 @@
|
|||||||
|
|
||||||
使用框架前请仔细阅读文档重点注意事项
|
使用框架前请仔细阅读文档重点注意事项
|
||||||
<br>
|
<br>
|
||||||
>[初始化项目 必看](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/关于初始化项目?sort_id=4164117)
|
>[初始化项目 必看](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4164117&doc_id=1469725)
|
||||||
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/关于初始化项目?sort_id=4164117](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/关于初始化项目?sort_id=4164117)
|
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4164117&doc_id=1469725](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4164117&doc_id=1469725)
|
||||||
>
|
>
|
||||||
>[部署项目 必看](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/关于应用部署?sort_id=4219382)
|
>[专栏与视频 入门必看](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5473272&doc_id=1469725)
|
||||||
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/关于应用部署?sort_id=4219382](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/关于应用部署?sort_id=4219382)
|
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5473272&doc_id=1469725](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5473272&doc_id=1469725)
|
||||||
|
>
|
||||||
|
>[部署项目 必看](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4219382&doc_id=1469725)
|
||||||
|
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4219382&doc_id=1469725](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4219382&doc_id=1469725)
|
||||||
>
|
>
|
||||||
>[参考文档 Wiki](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages)
|
>[参考文档 Wiki](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages)
|
||||||
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages)
|
>>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages)
|
||||||
|
160
pom.xml
160
pom.xml
@ -6,53 +6,47 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<version>4.2.0</version>
|
<version>4.4.0</version>
|
||||||
|
|
||||||
<name>RuoYi-Vue-Plus</name>
|
<name>RuoYi-Vue-Plus</name>
|
||||||
<url>https://gitee.com/JavaLionLi/RuoYi-Vue-Plus</url>
|
<url>https://gitee.com/JavaLionLi/RuoYi-Vue-Plus</url>
|
||||||
<description>RuoYi-Vue-Plus后台管理系统</description>
|
<description>RuoYi-Vue-Plus后台管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi-vue-plus.version>4.2.0</ruoyi-vue-plus.version>
|
<ruoyi-vue-plus.version>4.4.0</ruoyi-vue-plus.version>
|
||||||
<spring-boot.version>2.6.9</spring-boot.version>
|
<spring-boot.version>2.7.6</spring-boot.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
||||||
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
|
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
|
||||||
<druid.version>1.2.11</druid.version>
|
<springdoc.version>1.6.13</springdoc.version>
|
||||||
<knife4j.version>3.0.3</knife4j.version>
|
<poi.version>5.2.3</poi.version>
|
||||||
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
<easyexcel.version>3.1.3</easyexcel.version>
|
||||||
<poi.version>5.2.2</poi.version>
|
|
||||||
<easyexcel.version>3.1.1</easyexcel.version>
|
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<satoken.version>1.30.0</satoken.version>
|
<satoken.version>1.33.0</satoken.version>
|
||||||
<mybatis-plus.version>3.5.2</mybatis-plus.version>
|
<mybatis-plus.version>3.5.2</mybatis-plus.version>
|
||||||
<p6spy.version>3.9.1</p6spy.version>
|
<p6spy.version>3.9.1</p6spy.version>
|
||||||
<hutool.version>5.8.3</hutool.version>
|
<hutool.version>5.8.10</hutool.version>
|
||||||
<okhttp.version>4.9.3</okhttp.version>
|
<okhttp.version>4.10.0</okhttp.version>
|
||||||
<spring-boot-admin.version>2.6.7</spring-boot-admin.version>
|
<spring-boot-admin.version>2.7.7</spring-boot-admin.version>
|
||||||
<redisson.version>3.17.4</redisson.version>
|
<redisson.version>3.18.0</redisson.version>
|
||||||
<lock4j.version>2.2.1</lock4j.version>
|
<lock4j.version>2.2.3</lock4j.version>
|
||||||
<dynamic-ds.version>3.5.1</dynamic-ds.version>
|
<dynamic-ds.version>3.5.2</dynamic-ds.version>
|
||||||
<tlog.version>1.4.3</tlog.version>
|
<alibaba-ttl.version>2.14.2</alibaba-ttl.version>
|
||||||
<xxl-job.version>2.3.1</xxl-job.version>
|
<xxl-job.version>2.3.1</xxl-job.version>
|
||||||
|
<lombok.version>1.18.24</lombok.version>
|
||||||
|
|
||||||
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
||||||
<guava.version>30.0-jre</guava.version>
|
<guava.version>31.1-jre</guava.version>
|
||||||
|
<!-- 临时修复 snakeyaml 漏洞 -->
|
||||||
|
<snakeyaml.version>1.32</snakeyaml.version>
|
||||||
|
|
||||||
<!-- OSS 配置 -->
|
<!-- OSS 配置 -->
|
||||||
<aws-java-sdk-s3.version>1.12.248</aws-java-sdk-s3.version>
|
<aws-java-sdk-s3.version>1.12.349</aws-java-sdk-s3.version>
|
||||||
<!-- SMS 配置 -->
|
<!-- SMS 配置 -->
|
||||||
<aliyun.sms.version>2.0.9</aliyun.sms.version>
|
<aliyun.sms.version>2.0.22</aliyun.sms.version>
|
||||||
<tencent.sms.version>3.1.537</tencent.sms.version>
|
<tencent.sms.version>3.1.635</tencent.sms.version>
|
||||||
|
|
||||||
<!-- docker 配置 -->
|
|
||||||
<docker.registry.url>localhost</docker.registry.url>
|
|
||||||
<docker.registry.host>http://${docker.registry.url}:2375</docker.registry.host>
|
|
||||||
<docker.namespace>ruoyi</docker.namespace>
|
|
||||||
<docker.plugin.version>1.2.2</docker.plugin.version>
|
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
@ -77,29 +71,22 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 阿里数据库连接池 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>springdoc-openapi-webmvc-core</artifactId>
|
||||||
<version>${druid.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
<artifactId>springdoc-openapi-javadoc</artifactId>
|
||||||
<version>${knife4j.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>swagger-annotations</artifactId>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${swagger-annotations.version}</version>
|
<version>${lombok.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -142,6 +129,12 @@
|
|||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-jwt</artifactId>
|
<artifactId>sa-token-jwt</artifactId>
|
||||||
<version>${satoken.version}</version>
|
<version>${satoken.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- dynamic-datasource 多数据源-->
|
<!-- dynamic-datasource 多数据源-->
|
||||||
@ -188,7 +181,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tencentcloudapi</groupId>
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
<artifactId>tencentcloud-sdk-java-sms</artifactId>
|
||||||
<version>${tencent.sms.version}</version>
|
<version>${tencent.sms.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -223,29 +216,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.yomahub</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>tlog-web-spring-boot-starter</artifactId>
|
<artifactId>transmittable-thread-local</artifactId>
|
||||||
<version>${tlog.version}</version>
|
<version>${alibaba-ttl.version}</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<groupId>dom4j</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-beanutils</artifactId>
|
|
||||||
<groupId>commons-beanutils</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yomahub</groupId>
|
|
||||||
<artifactId>tlog-xxljob-spring-boot-starter</artifactId>
|
|
||||||
<version>${tlog.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
||||||
@ -255,6 +228,13 @@
|
|||||||
<version>${guava.version}</version>
|
<version>${guava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 临时修复 snakeyaml 漏洞 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<version>${snakeyaml.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务 -->
|
<!-- 定时任务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -338,6 +318,36 @@
|
|||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>com.github.therapi</groupId>
|
||||||
|
<artifactId>therapi-runtime-javadoc-scribe</artifactId>
|
||||||
|
<version>0.15.0</version>
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<!-- 单元测试使用 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.2</version>
|
||||||
|
<configuration>
|
||||||
|
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||||
|
<!-- 根据打包环境执行对应的@Tag测试方法 -->
|
||||||
|
<groups>${profiles.active}</groups>
|
||||||
|
<!-- 排除标签 -->
|
||||||
|
<excludedGroups>exclude</excludedGroups>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -364,8 +374,8 @@
|
|||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
<name>aliyun nexus</name>
|
<name>huawei nexus</name>
|
||||||
<url>https://maven.aliyun.com/repository/public/</url>
|
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -375,8 +385,8 @@
|
|||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
<name>aliyun nexus</name>
|
<name>huawei nexus</name>
|
||||||
<url>https://maven.aliyun.com/repository/public/</url>
|
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -393,8 +403,6 @@
|
|||||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||||
<profiles.active>local</profiles.active>
|
<profiles.active>local</profiles.active>
|
||||||
<logging.level>debug</logging.level>
|
<logging.level>debug</logging.level>
|
||||||
<knife4j.production>false</knife4j.production>
|
|
||||||
<endpoints.include>'*'</endpoints.include>
|
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
@ -403,8 +411,6 @@
|
|||||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||||
<profiles.active>dev</profiles.active>
|
<profiles.active>dev</profiles.active>
|
||||||
<logging.level>debug</logging.level>
|
<logging.level>debug</logging.level>
|
||||||
<knife4j.production>false</knife4j.production>
|
|
||||||
<endpoints.include>'*'</endpoints.include>
|
|
||||||
</properties>
|
</properties>
|
||||||
<activation>
|
<activation>
|
||||||
<!-- 默认环境 -->
|
<!-- 默认环境 -->
|
||||||
@ -416,10 +422,10 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<profiles.active>prod</profiles.active>
|
<profiles.active>prod</profiles.active>
|
||||||
<logging.level>warn</logging.level>
|
<logging.level>warn</logging.level>
|
||||||
<knife4j.production>true</knife4j.production>
|
|
||||||
<endpoints.include>health, info, logfile</endpoints.include>
|
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,14 +2,22 @@ FROM anapsix/alpine-java:8_server-jre_unlimited
|
|||||||
|
|
||||||
MAINTAINER Lion Li
|
MAINTAINER Lion Li
|
||||||
|
|
||||||
RUN mkdir -p /ruoyi/server
|
RUN mkdir -p /ruoyi/server/logs \
|
||||||
RUN mkdir -p /ruoyi/server/logs
|
/ruoyi/server/temp \
|
||||||
RUN mkdir -p /ruoyi/server/temp
|
/ruoyi/skywalking/agent
|
||||||
|
|
||||||
WORKDIR /ruoyi/server
|
WORKDIR /ruoyi/server
|
||||||
|
|
||||||
EXPOSE 8080
|
ENV SERVER_PORT=8080
|
||||||
|
|
||||||
|
EXPOSE ${SERVER_PORT}
|
||||||
|
|
||||||
ADD ./target/ruoyi-admin.jar ./app.jar
|
ADD ./target/ruoyi-admin.jar ./app.jar
|
||||||
|
|
||||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
ENTRYPOINT ["java", \
|
||||||
|
"-Djava.security.egd=file:/dev/./urandom", \
|
||||||
|
"-Dserver.port=${SERVER_PORT}", \
|
||||||
|
# 应用名称 如果想区分集群节点监控 改成不同的名称即可
|
||||||
|
# "-Dskywalking.agent.service_name=ruoyi-server", \
|
||||||
|
# "-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar", \
|
||||||
|
"-jar", "app.jar"]
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.2.0</version>
|
<version>4.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
<!-- Mysql驱动包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Oracle -->
|
<!-- Oracle -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -78,6 +78,24 @@
|
|||||||
<artifactId>ruoyi-demo</artifactId>
|
<artifactId>ruoyi-demo</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- skywalking 整合 logback -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.apache.skywalking</groupId>-->
|
||||||
|
<!-- <artifactId>apm-toolkit-logback-1.x</artifactId>-->
|
||||||
|
<!-- <version>${与你的agent探针版本保持一致}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.apache.skywalking</groupId>-->
|
||||||
|
<!-- <artifactId>apm-toolkit-trace</artifactId>-->
|
||||||
|
<!-- <version>${与你的agent探针版本保持一致}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -107,25 +125,6 @@
|
|||||||
<warName>${project.artifactId}</warName>
|
<warName>${project.artifactId}</warName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>com.spotify</groupId>
|
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
|
||||||
<version>${docker.plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<imageName>${docker.namespace}/ruoyi-server:${project.version}</imageName>
|
|
||||||
<dockerDirectory>${project.basedir}</dockerDirectory>
|
|
||||||
<dockerHost>${docker.registry.host}</dockerHost>
|
|
||||||
<registryUrl>${docker.registry.url}</registryUrl>
|
|
||||||
<serverId>${docker.registry.url}</serverId>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<targetPath>/</targetPath>
|
|
||||||
<directory>${project.build.directory}</directory>
|
|
||||||
<include>${project.build.finalName}.jar</include>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.ruoyi.web.controller.common;
|
package com.ruoyi.web.controller.common;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.hutool.captcha.AbstractCaptcha;
|
import cn.hutool.captcha.AbstractCaptcha;
|
||||||
import cn.hutool.captcha.generator.CodeGenerator;
|
import cn.hutool.captcha.generator.CodeGenerator;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.ruoyi.common.annotation.Anonymous;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.enums.CaptchaType;
|
import com.ruoyi.common.enums.CaptchaType;
|
||||||
@ -18,9 +19,6 @@ import com.ruoyi.sms.config.properties.SmsProperties;
|
|||||||
import com.ruoyi.sms.core.SmsTemplate;
|
import com.ruoyi.sms.core.SmsTemplate;
|
||||||
import com.ruoyi.sms.entity.SmsResult;
|
import com.ruoyi.sms.entity.SmsResult;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -37,10 +35,9 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@SaIgnore
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "验证码操作处理", tags = {"验证码管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
public class CaptchaController {
|
public class CaptchaController {
|
||||||
@ -51,16 +48,16 @@ public class CaptchaController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信验证码
|
* 短信验证码
|
||||||
|
*
|
||||||
|
* @param phonenumber 用户手机号
|
||||||
*/
|
*/
|
||||||
@ApiOperation("短信验证码")
|
|
||||||
@GetMapping("/captchaSms")
|
@GetMapping("/captchaSms")
|
||||||
public R<Void> smsCaptcha(@ApiParam("用户手机号")
|
public R<Void> smsCaptcha(@NotBlank(message = "{user.phonenumber.not.blank}")
|
||||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
|
||||||
String phonenumber) {
|
String phonenumber) {
|
||||||
if (smsProperties.getEnabled()) {
|
if (!smsProperties.getEnabled()) {
|
||||||
R.fail("当前系统没有开启短信功能!");
|
return R.fail("当前系统没有开启短信功能!");
|
||||||
}
|
}
|
||||||
String key = Constants.CAPTCHA_CODE_KEY + phonenumber;
|
String key = CacheConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||||
String code = RandomUtil.randomNumbers(4);
|
String code = RandomUtil.randomNumbers(4);
|
||||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||||
@ -79,18 +76,17 @@ public class CaptchaController {
|
|||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@ApiOperation("生成验证码")
|
|
||||||
@GetMapping("/captchaImage")
|
@GetMapping("/captchaImage")
|
||||||
public R<Map<String, Object>> getCode() {
|
public R<Map<String, Object>> getCode() {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||||
ajax.put("captchaOnOff", captchaOnOff);
|
ajax.put("captchaEnabled", captchaEnabled);
|
||||||
if (!captchaOnOff) {
|
if (!captchaEnabled) {
|
||||||
return R.ok(ajax);
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtil.simpleUUID();
|
String uuid = IdUtil.simpleUUID();
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
||||||
// 生成验证码
|
// 生成验证码
|
||||||
CaptchaType captchaType = captchaProperties.getType();
|
CaptchaType captchaType = captchaProperties.getType();
|
||||||
boolean isMath = CaptchaType.MATH == captchaType;
|
boolean isMath = CaptchaType.MATH == captchaType;
|
||||||
|
@ -1,40 +1,59 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
|
import com.ruoyi.common.constant.CacheNames;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.utils.JsonUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.annotations.Api;
|
import com.ruoyi.common.utils.redis.CacheUtils;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
|
import com.ruoyi.system.domain.SysCache;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
import org.redisson.spring.data.connection.RedissonConnectionFactory;
|
||||||
import org.springframework.data.redis.core.RedisCallback;
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存监控
|
* 缓存监控
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "缓存监控", tags = {"缓存监控管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/cache")
|
@RequestMapping("/monitor/cache")
|
||||||
public class CacheController {
|
public class CacheController {
|
||||||
|
|
||||||
private final RedisTemplate<String, String> redisTemplate;
|
private final RedissonConnectionFactory connectionFactory;
|
||||||
|
|
||||||
@ApiOperation("获取缓存监控详细信息")
|
private final static List<SysCache> CACHES = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
CACHES.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
|
||||||
|
CACHES.add(new SysCache(CacheConstants.ONLINE_TOKEN_KEY, "在线用户"));
|
||||||
|
CACHES.add(new SysCache(CacheNames.SYS_CONFIG, "配置信息"));
|
||||||
|
CACHES.add(new SysCache(CacheNames.SYS_DICT, "数据字典"));
|
||||||
|
CACHES.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
||||||
|
CACHES.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
|
||||||
|
CACHES.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
|
||||||
|
CACHES.add(new SysCache(CacheNames.SYS_OSS_CONFIG, "OSS配置"));
|
||||||
|
CACHES.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存监控列表
|
||||||
|
*/
|
||||||
@SaCheckPermission("monitor:cache:list")
|
@SaCheckPermission("monitor:cache:list")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public R<Map<String, Object>> getInfo() throws Exception {
|
public R<Map<String, Object>> getInfo() throws Exception {
|
||||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info);
|
RedisConnection connection = connectionFactory.getConnection();
|
||||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
Properties info = connection.info();
|
||||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize);
|
Properties commandStats = connection.info("commandstats");
|
||||||
|
Long dbSize = connection.dbSize();
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>(3);
|
Map<String, Object> result = new HashMap<>(3);
|
||||||
result.put("info", info);
|
result.put("info", info);
|
||||||
@ -53,4 +72,98 @@ public class CacheController {
|
|||||||
result.put("commandStats", pieList);
|
result.put("commandStats", pieList);
|
||||||
return R.ok(result);
|
return R.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存监控缓存名列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("monitor:cache:list")
|
||||||
|
@GetMapping("/getNames")
|
||||||
|
public R<List<SysCache>> cache() {
|
||||||
|
return R.ok(CACHES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存监控Key列表
|
||||||
|
*
|
||||||
|
* @param cacheName 缓存名
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("monitor:cache:list")
|
||||||
|
@GetMapping("/getKeys/{cacheName}")
|
||||||
|
public R<Collection<String>> getCacheKeys(@PathVariable String cacheName) {
|
||||||
|
Collection<String> cacheKeys = new HashSet<>(0);
|
||||||
|
if (isCacheNames(cacheName)) {
|
||||||
|
Set<Object> keys = CacheUtils.keys(cacheName);
|
||||||
|
if (CollUtil.isNotEmpty(keys)) {
|
||||||
|
cacheKeys = keys.stream().map(Object::toString).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cacheKeys = RedisUtils.keys(cacheName + "*");
|
||||||
|
}
|
||||||
|
return R.ok(cacheKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存监控缓存值详情
|
||||||
|
*
|
||||||
|
* @param cacheName 缓存名
|
||||||
|
* @param cacheKey 缓存key
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("monitor:cache:list")
|
||||||
|
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||||
|
public R<SysCache> getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||||
|
Object cacheValue;
|
||||||
|
if (isCacheNames(cacheName)) {
|
||||||
|
cacheValue = CacheUtils.get(cacheName, cacheKey);
|
||||||
|
} else {
|
||||||
|
cacheValue = RedisUtils.getCacheObject(cacheKey);
|
||||||
|
}
|
||||||
|
SysCache sysCache = new SysCache(cacheName, cacheKey, JsonUtils.toJsonString(cacheValue));
|
||||||
|
return R.ok(sysCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理缓存监控缓存名
|
||||||
|
*
|
||||||
|
* @param cacheName 缓存名
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("monitor:cache:list")
|
||||||
|
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||||
|
public R<Void> clearCacheName(@PathVariable String cacheName) {
|
||||||
|
if (isCacheNames(cacheName)) {
|
||||||
|
CacheUtils.clear(cacheName);
|
||||||
|
} else {
|
||||||
|
RedisUtils.deleteKeys(cacheName + "*");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理缓存监控Key
|
||||||
|
*
|
||||||
|
* @param cacheKey key名
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("monitor:cache:list")
|
||||||
|
@DeleteMapping("/clearCacheKey/{cacheName}/{cacheKey}")
|
||||||
|
public R<Void> clearCacheKey(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||||
|
if (isCacheNames(cacheName)) {
|
||||||
|
CacheUtils.evict(cacheName, cacheKey);
|
||||||
|
} else {
|
||||||
|
RedisUtils.deleteObject(cacheKey);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理全部缓存监控
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("monitor:cache:list")
|
||||||
|
@DeleteMapping("/clearCacheAll")
|
||||||
|
public R<Void> clearCacheAll() {
|
||||||
|
RedisUtils.deleteKeys("*");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isCacheNames(String cacheName) {
|
||||||
|
return !StringUtils.contains(cacheName, ":");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,16 @@ package com.ruoyi.web.controller.monitor;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "系统访问记录", tags = {"系统访问记录管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/logininfor")
|
@RequestMapping("/monitor/logininfor")
|
||||||
@ -33,14 +32,18 @@ public class SysLogininforController extends BaseController {
|
|||||||
|
|
||||||
private final ISysLogininforService logininforService;
|
private final ISysLogininforService logininforService;
|
||||||
|
|
||||||
@ApiOperation("查询系统访问记录列表")
|
/**
|
||||||
|
* 获取系统访问记录列表
|
||||||
|
*/
|
||||||
@SaCheckPermission("monitor:logininfor:list")
|
@SaCheckPermission("monitor:logininfor:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) {
|
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) {
|
||||||
return logininforService.selectPageLogininforList(logininfor, pageQuery);
|
return logininforService.selectPageLogininforList(logininfor, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出系统访问记录列表")
|
/**
|
||||||
|
* 导出系统访问记录列表
|
||||||
|
*/
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("monitor:logininfor:export")
|
@SaCheckPermission("monitor:logininfor:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -49,7 +52,10 @@ public class SysLogininforController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除系统访问记录")
|
/**
|
||||||
|
* 批量删除登录日志
|
||||||
|
* @param infoIds 日志ids
|
||||||
|
*/
|
||||||
@SaCheckPermission("monitor:logininfor:remove")
|
@SaCheckPermission("monitor:logininfor:remove")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{infoIds}")
|
@DeleteMapping("/{infoIds}")
|
||||||
@ -57,7 +63,9 @@ public class SysLogininforController extends BaseController {
|
|||||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("清空系统访问记录")
|
/**
|
||||||
|
* 清理系统访问记录
|
||||||
|
*/
|
||||||
@SaCheckPermission("monitor:logininfor:remove")
|
@SaCheckPermission("monitor:logininfor:remove")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
@ -65,4 +73,16 @@ public class SysLogininforController extends BaseController {
|
|||||||
logininforService.cleanLogininfor();
|
logininforService.cleanLogininfor();
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SaCheckPermission("monitor:logininfor:unlock")
|
||||||
|
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||||
|
@GetMapping("/unlock/{userName}")
|
||||||
|
public R<Void> unlock(@PathVariable("userName") String userName) {
|
||||||
|
String loginName = CacheConstants.PWD_ERR_CNT_KEY + userName;
|
||||||
|
if (RedisUtils.hasKey(loginName)) {
|
||||||
|
RedisUtils.deleteObject(loginName);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,13 @@ package com.ruoyi.web.controller.monitor;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysOperLog;
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.system.service.ISysOperLogService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -25,7 +23,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "操作日志记录", tags = {"操作日志记录管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/operlog")
|
@RequestMapping("/monitor/operlog")
|
||||||
@ -33,14 +30,18 @@ public class SysOperlogController extends BaseController {
|
|||||||
|
|
||||||
private final ISysOperLogService operLogService;
|
private final ISysOperLogService operLogService;
|
||||||
|
|
||||||
@ApiOperation("查询操作日志记录列表")
|
/**
|
||||||
|
* 获取操作日志记录列表
|
||||||
|
*/
|
||||||
@SaCheckPermission("monitor:operlog:list")
|
@SaCheckPermission("monitor:operlog:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) {
|
public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) {
|
||||||
return operLogService.selectPageOperLogList(operLog, pageQuery);
|
return operLogService.selectPageOperLogList(operLog, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出操作日志记录列表")
|
/**
|
||||||
|
* 导出操作日志记录列表
|
||||||
|
*/
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("monitor:operlog:export")
|
@SaCheckPermission("monitor:operlog:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -49,7 +50,10 @@ public class SysOperlogController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除操作日志记录")
|
/**
|
||||||
|
* 批量删除操作日志记录
|
||||||
|
* @param operIds 日志ids
|
||||||
|
*/
|
||||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
@SaCheckPermission("monitor:operlog:remove")
|
@SaCheckPermission("monitor:operlog:remove")
|
||||||
@DeleteMapping("/{operIds}")
|
@DeleteMapping("/{operIds}")
|
||||||
@ -57,7 +61,9 @@ public class SysOperlogController extends BaseController {
|
|||||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("清空操作日志记录")
|
/**
|
||||||
|
* 清理操作日志记录
|
||||||
|
*/
|
||||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||||
@SaCheckPermission("monitor:operlog:remove")
|
@SaCheckPermission("monitor:operlog:remove")
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
|
@ -5,64 +5,66 @@ import cn.dev33.satoken.exception.NotLoginException;
|
|||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.domain.dto.UserOnlineDTO;
|
import com.ruoyi.common.core.domain.dto.UserOnlineDTO;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.StreamUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import com.ruoyi.system.domain.SysUserOnline;
|
import com.ruoyi.system.domain.SysUserOnline;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户监控
|
* 在线用户监控
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "在线用户监控", tags = {"在线用户监控管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/online")
|
@RequestMapping("/monitor/online")
|
||||||
public class SysUserOnlineController extends BaseController {
|
public class SysUserOnlineController extends BaseController {
|
||||||
|
|
||||||
@ApiOperation("在线用户列表")
|
/**
|
||||||
|
* 获取在线用户监控列表
|
||||||
|
*
|
||||||
|
* @param ipaddr IP地址
|
||||||
|
* @param userName 用户名
|
||||||
|
*/
|
||||||
@SaCheckPermission("monitor:online:list")
|
@SaCheckPermission("monitor:online:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
||||||
// 获取所有未过期的 token
|
// 获取所有未过期的 token
|
||||||
List<String> keys = StpUtil.searchTokenValue("", -1, 0);
|
List<String> keys = StpUtil.searchTokenValue("", 0, -1, false);
|
||||||
List<UserOnlineDTO> userOnlineDTOList = new ArrayList<>();
|
List<UserOnlineDTO> userOnlineDTOList = new ArrayList<>();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
String token = key.replace(Constants.LOGIN_TOKEN_KEY, "");
|
String token = key.replace(CacheConstants.LOGIN_TOKEN_KEY, "");
|
||||||
// 如果已经过期则踢下线
|
// 如果已经过期则跳过
|
||||||
if (StpUtil.stpLogic.getTokenActivityTimeoutByToken(token) < 0) {
|
if (StpUtil.stpLogic.getTokenActivityTimeoutByToken(token) < -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
userOnlineDTOList.add(RedisUtils.getCacheObject(Constants.ONLINE_TOKEN_KEY + token));
|
userOnlineDTOList.add(RedisUtils.getCacheObject(CacheConstants.ONLINE_TOKEN_KEY + token));
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||||
userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline ->
|
userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline ->
|
||||||
StringUtils.equals(ipaddr, userOnline.getIpaddr()) &&
|
StringUtils.equals(ipaddr, userOnline.getIpaddr()) &&
|
||||||
StringUtils.equals(userName, userOnline.getUserName())
|
StringUtils.equals(userName, userOnline.getUserName())
|
||||||
).collect(Collectors.toList());
|
);
|
||||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||||
userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline ->
|
userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline ->
|
||||||
StringUtils.equals(ipaddr, userOnline.getIpaddr()))
|
StringUtils.equals(ipaddr, userOnline.getIpaddr())
|
||||||
.collect(Collectors.toList());
|
);
|
||||||
} else if (StringUtils.isNotEmpty(userName)) {
|
} else if (StringUtils.isNotEmpty(userName)) {
|
||||||
userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline ->
|
userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline ->
|
||||||
StringUtils.equals(userName, userOnline.getUserName())
|
StringUtils.equals(userName, userOnline.getUserName())
|
||||||
).collect(Collectors.toList());
|
);
|
||||||
}
|
}
|
||||||
Collections.reverse(userOnlineDTOList);
|
Collections.reverse(userOnlineDTOList);
|
||||||
userOnlineDTOList.removeAll(Collections.singleton(null));
|
userOnlineDTOList.removeAll(Collections.singleton(null));
|
||||||
@ -72,15 +74,16 @@ public class SysUserOnlineController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 强退用户
|
* 强退用户
|
||||||
|
*
|
||||||
|
* @param tokenId token值
|
||||||
*/
|
*/
|
||||||
@ApiOperation("强退用户")
|
|
||||||
@SaCheckPermission("monitor:online:forceLogout")
|
@SaCheckPermission("monitor:online:forceLogout")
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public R<Void> forceLogout(@PathVariable String tokenId) {
|
public R<Void> forceLogout(@PathVariable String tokenId) {
|
||||||
try {
|
try {
|
||||||
StpUtil.kickoutByTokenValue(tokenId);
|
StpUtil.kickoutByTokenValue(tokenId);
|
||||||
} catch (NotLoginException e) {
|
} catch (NotLoginException ignored) {
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,13 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -27,7 +24,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "参数配置控制器", tags = {"参数配置管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/config")
|
@RequestMapping("/system/config")
|
||||||
@ -38,14 +34,15 @@ public class SysConfigController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取参数配置列表
|
* 获取参数配置列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取参数配置列表")
|
|
||||||
@SaCheckPermission("system:config:list")
|
@SaCheckPermission("system:config:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) {
|
public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) {
|
||||||
return configService.selectPageConfigList(config, pageQuery);
|
return configService.selectPageConfigList(config, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出参数配置列表")
|
/**
|
||||||
|
* 导出参数配置列表
|
||||||
|
*/
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:config:export")
|
@SaCheckPermission("system:config:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -56,27 +53,28 @@ public class SysConfigController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数编号获取详细信息
|
* 根据参数编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param configId 参数ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据参数编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:config:query")
|
@SaCheckPermission("system:config:query")
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public R<SysConfig> getInfo(@ApiParam("参数ID") @PathVariable Long configId) {
|
public R<SysConfig> getInfo(@PathVariable Long configId) {
|
||||||
return R.ok(configService.selectConfigById(configId));
|
return R.ok(configService.selectConfigById(configId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数键名查询参数值
|
* 根据参数键名查询参数值
|
||||||
|
*
|
||||||
|
* @param configKey 参数Key
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据参数键名查询参数值")
|
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
public R<Void> getConfigKey(@ApiParam("参数Key") @PathVariable String configKey) {
|
public R<Void> getConfigKey(@PathVariable String configKey) {
|
||||||
return R.ok(configService.selectConfigByKey(configKey));
|
return R.ok(configService.selectConfigByKey(configKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增参数配置")
|
|
||||||
@SaCheckPermission("system:config:add")
|
@SaCheckPermission("system:config:add")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -84,13 +82,13 @@ public class SysConfigController extends BaseController {
|
|||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
return toAjax(configService.insertConfig(config));
|
configService.insertConfig(config);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改参数配置")
|
|
||||||
@SaCheckPermission("system:config:edit")
|
@SaCheckPermission("system:config:edit")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -98,28 +96,30 @@ public class SysConfigController extends BaseController {
|
|||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
return toAjax(configService.updateConfig(config));
|
configService.updateConfig(config);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数键名修改参数配置
|
* 根据参数键名修改参数配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据参数键名修改参数配置")
|
|
||||||
@SaCheckPermission("system:config:edit")
|
@SaCheckPermission("system:config:edit")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updateByKey")
|
@PutMapping("/updateByKey")
|
||||||
public R<Void> updateByKey(@RequestBody SysConfig config) {
|
public R<Void> updateByKey(@RequestBody SysConfig config) {
|
||||||
return toAjax(configService.updateConfig(config));
|
configService.updateConfig(config);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除参数配置
|
* 删除参数配置
|
||||||
|
*
|
||||||
|
* @param configIds 参数ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除参数配置")
|
|
||||||
@SaCheckPermission("system:config:remove")
|
@SaCheckPermission("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{configIds}")
|
@DeleteMapping("/{configIds}")
|
||||||
public R<Void> remove(@ApiParam("参数ID串") @PathVariable Long[] configIds) {
|
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||||
configService.deleteConfigByIds(configIds);
|
configService.deleteConfigByIds(configIds);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -127,7 +127,6 @@ public class SysConfigController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 刷新参数缓存
|
* 刷新参数缓存
|
||||||
*/
|
*/
|
||||||
@ApiOperation("刷新参数缓存")
|
|
||||||
@SaCheckPermission("system:config:remove")
|
@SaCheckPermission("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
@ -11,16 +10,11 @@ import com.ruoyi.common.core.domain.entity.SysDept;
|
|||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门信息
|
* 部门信息
|
||||||
@ -28,7 +22,6 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "部门控制器", tags = {"部门管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
@ -39,7 +32,6 @@ public class SysDeptController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取部门列表")
|
|
||||||
@SaCheckPermission("system:dept:list")
|
@SaCheckPermission("system:dept:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<SysDept>> list(SysDept dept) {
|
public R<List<SysDept>> list(SysDept dept) {
|
||||||
@ -49,11 +41,12 @@ public class SysDeptController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门列表(排除节点)
|
* 查询部门列表(排除节点)
|
||||||
|
*
|
||||||
|
* @param deptId 部门ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询部门列表(排除节点)")
|
|
||||||
@SaCheckPermission("system:dept:list")
|
@SaCheckPermission("system:dept:list")
|
||||||
@GetMapping("/list/exclude/{deptId}")
|
@GetMapping("/list/exclude/{deptId}")
|
||||||
public R<List<SysDept>> excludeChild(@ApiParam("部门ID") @PathVariable(value = "deptId", required = false) Long deptId) {
|
public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
||||||
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
||||||
@ -62,42 +55,19 @@ public class SysDeptController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门编号获取详细信息
|
* 根据部门编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param deptId 部门ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据部门编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:dept:query")
|
@SaCheckPermission("system:dept:query")
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public R<SysDept> getInfo(@ApiParam("部门ID") @PathVariable Long deptId) {
|
public R<SysDept> getInfo(@PathVariable Long deptId) {
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return R.ok(deptService.selectDeptById(deptId));
|
return R.ok(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门下拉树列表
|
|
||||||
*/
|
|
||||||
@ApiOperation("获取部门下拉树列表")
|
|
||||||
@GetMapping("/treeselect")
|
|
||||||
public R<List<Tree<Long>>> treeselect(SysDept dept) {
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
|
||||||
return R.ok(deptService.buildDeptTreeSelect(depts));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加载对应角色部门列表树
|
|
||||||
*/
|
|
||||||
@ApiOperation("加载对应角色部门列表树")
|
|
||||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
|
||||||
public R<Map<String, Object>> roleDeptTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
|
||||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
|
||||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
|
||||||
return R.ok(ajax);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增部门")
|
|
||||||
@SaCheckPermission("system:dept:add")
|
@SaCheckPermission("system:dept:add")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -111,7 +81,6 @@ public class SysDeptController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改部门")
|
|
||||||
@SaCheckPermission("system:dept:edit")
|
@SaCheckPermission("system:dept:edit")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -131,17 +100,18 @@ public class SysDeptController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除部门
|
* 删除部门
|
||||||
|
*
|
||||||
|
* @param deptId 部门ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除部门")
|
|
||||||
@SaCheckPermission("system:dept:remove")
|
@SaCheckPermission("system:dept:remove")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{deptId}")
|
@DeleteMapping("/{deptId}")
|
||||||
public R<Void> remove(@ApiParam("部门ID串") @PathVariable Long deptId) {
|
public R<Void> remove(@PathVariable Long deptId) {
|
||||||
if (deptService.hasChildByDeptId(deptId)) {
|
if (deptService.hasChildByDeptId(deptId)) {
|
||||||
return R.fail("存在下级部门,不允许删除");
|
return R.warn("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId)) {
|
if (deptService.checkDeptExistUser(deptId)) {
|
||||||
return R.fail("部门存在用户,不允许删除");
|
return R.warn("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
|
@ -4,17 +4,14 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -29,7 +26,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/data")
|
@RequestMapping("/system/dict/data")
|
||||||
@ -38,14 +34,18 @@ public class SysDictDataController extends BaseController {
|
|||||||
private final ISysDictDataService dictDataService;
|
private final ISysDictDataService dictDataService;
|
||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@ApiOperation("查询字典数据列表")
|
/**
|
||||||
|
* 查询字典数据列表
|
||||||
|
*/
|
||||||
@SaCheckPermission("system:dict:list")
|
@SaCheckPermission("system:dict:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) {
|
public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) {
|
||||||
return dictDataService.selectPageDictDataList(dictData, pageQuery);
|
return dictDataService.selectPageDictDataList(dictData, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出字典数据列表")
|
/**
|
||||||
|
* 导出字典数据列表
|
||||||
|
*/
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:dict:export")
|
@SaCheckPermission("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -56,20 +56,22 @@ public class SysDictDataController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字典数据详细
|
* 查询字典数据详细
|
||||||
|
*
|
||||||
|
* @param dictCode 字典code
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询字典数据详细")
|
|
||||||
@SaCheckPermission("system:dict:query")
|
@SaCheckPermission("system:dict:query")
|
||||||
@GetMapping(value = "/{dictCode}")
|
@GetMapping(value = "/{dictCode}")
|
||||||
public R<SysDictData> getInfo(@ApiParam("字典code") @PathVariable Long dictCode) {
|
public R<SysDictData> getInfo(@PathVariable Long dictCode) {
|
||||||
return R.ok(dictDataService.selectDictDataById(dictCode));
|
return R.ok(dictDataService.selectDictDataById(dictCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字典类型查询字典数据信息
|
* 根据字典类型查询字典数据信息
|
||||||
|
*
|
||||||
|
* @param dictType 字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据字典类型查询字典数据信息")
|
|
||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public R<List<SysDictData>> dictType(@ApiParam("字典类型") @PathVariable String dictType) {
|
public R<List<SysDictData>> dictType(@PathVariable String dictType) {
|
||||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
if (ObjectUtil.isNull(data)) {
|
if (ObjectUtil.isNull(data)) {
|
||||||
data = new ArrayList<>();
|
data = new ArrayList<>();
|
||||||
@ -80,33 +82,34 @@ public class SysDictDataController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增字典类型")
|
|
||||||
@SaCheckPermission("system:dict:add")
|
@SaCheckPermission("system:dict:add")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysDictData dict) {
|
public R<Void> add(@Validated @RequestBody SysDictData dict) {
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
dictDataService.insertDictData(dict);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改保存字典类型")
|
|
||||||
@SaCheckPermission("system:dict:edit")
|
@SaCheckPermission("system:dict:edit")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysDictData dict) {
|
public R<Void> edit(@Validated @RequestBody SysDictData dict) {
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
dictDataService.updateDictData(dict);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
|
*
|
||||||
|
* @param dictCodes 字典code串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除字典类型")
|
|
||||||
@SaCheckPermission("system:dict:remove")
|
@SaCheckPermission("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictCodes}")
|
@DeleteMapping("/{dictCodes}")
|
||||||
public R<Void> remove(@ApiParam("字典code串") @PathVariable Long[] dictCodes) {
|
public R<Void> remove(@PathVariable Long[] dictCodes) {
|
||||||
dictDataService.deleteDictDataByIds(dictCodes);
|
dictDataService.deleteDictDataByIds(dictCodes);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,13 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -27,7 +24,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/type")
|
@RequestMapping("/system/dict/type")
|
||||||
@ -35,14 +31,18 @@ public class SysDictTypeController extends BaseController {
|
|||||||
|
|
||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@ApiOperation("查询字典类型列表")
|
/**
|
||||||
|
* 查询字典类型列表
|
||||||
|
*/
|
||||||
@SaCheckPermission("system:dict:list")
|
@SaCheckPermission("system:dict:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) {
|
public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) {
|
||||||
return dictTypeService.selectPageDictTypeList(dictType, pageQuery);
|
return dictTypeService.selectPageDictTypeList(dictType, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出字典类型列表")
|
/**
|
||||||
|
* 导出字典类型列表
|
||||||
|
*/
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:dict:export")
|
@SaCheckPermission("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -53,18 +53,18 @@ public class SysDictTypeController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字典类型详细
|
* 查询字典类型详细
|
||||||
|
*
|
||||||
|
* @param dictId 字典ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询字典类型详细")
|
|
||||||
@SaCheckPermission("system:dict:query")
|
@SaCheckPermission("system:dict:query")
|
||||||
@GetMapping(value = "/{dictId}")
|
@GetMapping(value = "/{dictId}")
|
||||||
public R<SysDictType> getInfo(@ApiParam("字典ID") @PathVariable Long dictId) {
|
public R<SysDictType> getInfo(@PathVariable Long dictId) {
|
||||||
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增字典类型")
|
|
||||||
@SaCheckPermission("system:dict:add")
|
@SaCheckPermission("system:dict:add")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -72,13 +72,13 @@ public class SysDictTypeController extends BaseController {
|
|||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
return toAjax(dictTypeService.insertDictType(dict));
|
dictTypeService.insertDictType(dict);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改字典类型")
|
|
||||||
@SaCheckPermission("system:dict:edit")
|
@SaCheckPermission("system:dict:edit")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -86,17 +86,19 @@ public class SysDictTypeController extends BaseController {
|
|||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
return toAjax(dictTypeService.updateDictType(dict));
|
dictTypeService.updateDictType(dict);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
|
*
|
||||||
|
* @param dictIds 字典ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除字典类型")
|
|
||||||
@SaCheckPermission("system:dict:remove")
|
@SaCheckPermission("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictIds}")
|
@DeleteMapping("/{dictIds}")
|
||||||
public R<Void> remove(@ApiParam("字典ID串") @PathVariable Long[] dictIds) {
|
public R<Void> remove(@PathVariable Long[] dictIds) {
|
||||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -104,7 +106,6 @@ public class SysDictTypeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 刷新字典缓存
|
* 刷新字典缓存
|
||||||
*/
|
*/
|
||||||
@ApiOperation("刷新字典缓存")
|
|
||||||
@SaCheckPermission("system:dict:remove")
|
@SaCheckPermission("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
@ -116,7 +117,6 @@ public class SysDictTypeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取字典选择框列表
|
* 获取字典选择框列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取字典选择框列表")
|
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysDictType>> optionselect() {
|
public R<List<SysDictType>> optionselect() {
|
||||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -13,7 +12,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "首页控制器", tags = {"首页管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
public class SysIndexController {
|
public class SysIndexController {
|
||||||
@ -26,7 +24,7 @@ public class SysIndexController {
|
|||||||
/**
|
/**
|
||||||
* 访问首页,提示语
|
* 访问首页,提示语
|
||||||
*/
|
*/
|
||||||
@ApiOperation("访问首页,提示语")
|
@SaIgnore
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index() {
|
public String index() {
|
||||||
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
|
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import com.ruoyi.common.annotation.Anonymous;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.domain.model.SmsLoginBody;
|
import com.ruoyi.common.core.domain.model.SmsLoginBody;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
import com.ruoyi.system.domain.vo.RouterVo;
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
@ -15,8 +14,6 @@ import com.ruoyi.system.service.ISysMenuService;
|
|||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import com.ruoyi.system.service.SysLoginService;
|
import com.ruoyi.system.service.SysLoginService;
|
||||||
import com.ruoyi.system.service.SysPermissionService;
|
import com.ruoyi.system.service.SysPermissionService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -28,7 +25,6 @@ import javax.validation.constraints.NotBlank;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
@ -36,7 +32,6 @@ import java.util.Set;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "登录验证控制器", tags = {"登录验证管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
public class SysLoginController {
|
public class SysLoginController {
|
||||||
@ -52,8 +47,7 @@ public class SysLoginController {
|
|||||||
* @param loginBody 登录信息
|
* @param loginBody 登录信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@SaIgnore
|
||||||
@ApiOperation("登录方法")
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
|
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
@ -70,8 +64,7 @@ public class SysLoginController {
|
|||||||
* @param smsLoginBody 登录信息
|
* @param smsLoginBody 登录信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@SaIgnore
|
||||||
@ApiOperation("短信登录(示例)")
|
|
||||||
@PostMapping("/smsLogin")
|
@PostMapping("/smsLogin")
|
||||||
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
|
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
@ -87,8 +80,7 @@ public class SysLoginController {
|
|||||||
* @param xcxCode 小程序code
|
* @param xcxCode 小程序code
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@SaIgnore
|
||||||
@ApiOperation("小程序登录(示例)")
|
|
||||||
@PostMapping("/xcxLogin")
|
@PostMapping("/xcxLogin")
|
||||||
public R<Map<String, Object>> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
|
public R<Map<String, Object>> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
@ -98,16 +90,13 @@ public class SysLoginController {
|
|||||||
return R.ok(ajax);
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Anonymous
|
/**
|
||||||
@ApiOperation("登出方法")
|
* 退出登录
|
||||||
|
*/
|
||||||
|
@SaIgnore
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public R<Void> logout() {
|
public R<Void> logout() {
|
||||||
try {
|
loginService.logout();
|
||||||
String username = LoginHelper.getUsername();
|
|
||||||
StpUtil.logout();
|
|
||||||
loginService.logout(username);
|
|
||||||
} catch (NotLoginException e) {
|
|
||||||
}
|
|
||||||
return R.ok("退出成功");
|
return R.ok("退出成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,18 +105,14 @@ public class SysLoginController {
|
|||||||
*
|
*
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取用户信息")
|
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public R<Map<String, Object>> getInfo() {
|
public R<Map<String, Object>> getInfo() {
|
||||||
SysUser user = userService.selectUserById(LoginHelper.getUserId());
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
// 角色集合
|
SysUser user = userService.selectUserById(loginUser.getUserId());
|
||||||
Set<String> roles = permissionService.getRolePermission(user);
|
|
||||||
// 权限集合
|
|
||||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("user", user);
|
ajax.put("user", user);
|
||||||
ajax.put("roles", roles);
|
ajax.put("roles", loginUser.getRolePermission());
|
||||||
ajax.put("permissions", permissions);
|
ajax.put("permissions", loginUser.getMenuPermission());
|
||||||
return R.ok(ajax);
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +121,6 @@ public class SysLoginController {
|
|||||||
*
|
*
|
||||||
* @return 路由信息
|
* @return 路由信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取路由信息")
|
|
||||||
@GetMapping("getRouters")
|
@GetMapping("getRouters")
|
||||||
public R<List<RouterVo>> getRouters() {
|
public R<List<RouterVo>> getRouters() {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
|
@ -10,9 +10,6 @@ import com.ruoyi.common.core.domain.entity.SysMenu;
|
|||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -27,7 +24,6 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "菜单信息控制器", tags = {"菜单信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/menu")
|
@RequestMapping("/system/menu")
|
||||||
@ -38,7 +34,6 @@ public class SysMenuController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取菜单列表
|
* 获取菜单列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取菜单列表")
|
|
||||||
@SaCheckPermission("system:menu:list")
|
@SaCheckPermission("system:menu:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<SysMenu>> list(SysMenu menu) {
|
public R<List<SysMenu>> list(SysMenu menu) {
|
||||||
@ -48,18 +43,18 @@ public class SysMenuController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单编号获取详细信息
|
* 根据菜单编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param menuId 菜单ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据菜单编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:menu:query")
|
@SaCheckPermission("system:menu:query")
|
||||||
@GetMapping(value = "/{menuId}")
|
@GetMapping(value = "/{menuId}")
|
||||||
public R<SysMenu> getInfo(@ApiParam("菜单ID") @PathVariable Long menuId) {
|
public R<SysMenu> getInfo(@PathVariable Long menuId) {
|
||||||
return R.ok(menuService.selectMenuById(menuId));
|
return R.ok(menuService.selectMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单下拉树列表
|
* 获取菜单下拉树列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取菜单下拉树列表")
|
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public R<List<Tree<Long>>> treeselect(SysMenu menu) {
|
public R<List<Tree<Long>>> treeselect(SysMenu menu) {
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
@ -68,10 +63,11 @@ public class SysMenuController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载对应角色菜单列表树
|
* 加载对应角色菜单列表树
|
||||||
|
*
|
||||||
|
* @param roleId 角色ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("加载对应角色菜单列表树")
|
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public R<Map<String, Object>> roleMenuTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
|
public R<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||||
@ -82,7 +78,6 @@ public class SysMenuController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增菜单
|
* 新增菜单
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增菜单")
|
|
||||||
@SaCheckPermission("system:menu:add")
|
@SaCheckPermission("system:menu:add")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -98,7 +93,6 @@ public class SysMenuController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改菜单
|
* 修改菜单
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改菜单")
|
|
||||||
@SaCheckPermission("system:menu:edit")
|
@SaCheckPermission("system:menu:edit")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -115,17 +109,18 @@ public class SysMenuController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
|
*
|
||||||
|
* @param menuId 菜单ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除菜单")
|
|
||||||
@SaCheckPermission("system:menu:remove")
|
@SaCheckPermission("system:menu:remove")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{menuId}")
|
@DeleteMapping("/{menuId}")
|
||||||
public R<Void> remove(@ApiParam("菜单ID") @PathVariable("menuId") Long menuId) {
|
public R<Void> remove(@PathVariable("menuId") Long menuId) {
|
||||||
if (menuService.hasChildByMenuId(menuId)) {
|
if (menuService.hasChildByMenuId(menuId)) {
|
||||||
return R.fail("存在子菜单,不允许删除");
|
return R.warn("存在子菜单,不允许删除");
|
||||||
}
|
}
|
||||||
if (menuService.checkMenuExistRole(menuId)) {
|
if (menuService.checkMenuExistRole(menuId)) {
|
||||||
return R.fail("菜单已分配,不允许删除");
|
return R.warn("菜单已分配,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,12 @@ package com.ruoyi.web.controller.system;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -22,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "公告信息控制器", tags = {"公告信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/notice")
|
@RequestMapping("/system/notice")
|
||||||
@ -33,7 +29,6 @@ public class SysNoticeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取通知公告列表
|
* 获取通知公告列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取通知公告列表")
|
|
||||||
@SaCheckPermission("system:notice:list")
|
@SaCheckPermission("system:notice:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
||||||
@ -42,18 +37,18 @@ public class SysNoticeController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据通知公告编号获取详细信息
|
* 根据通知公告编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param noticeId 公告ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据通知公告编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:notice:query")
|
@SaCheckPermission("system:notice:query")
|
||||||
@GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/{noticeId}")
|
||||||
public R<SysNotice> getInfo(@ApiParam("公告ID") @PathVariable Long noticeId) {
|
public R<SysNotice> getInfo(@PathVariable Long noticeId) {
|
||||||
return R.ok(noticeService.selectNoticeById(noticeId));
|
return R.ok(noticeService.selectNoticeById(noticeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增通知公告
|
* 新增通知公告
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增通知公告")
|
|
||||||
@SaCheckPermission("system:notice:add")
|
@SaCheckPermission("system:notice:add")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -64,7 +59,6 @@ public class SysNoticeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改通知公告
|
* 修改通知公告
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改通知公告")
|
|
||||||
@SaCheckPermission("system:notice:edit")
|
@SaCheckPermission("system:notice:edit")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -74,12 +68,13 @@ public class SysNoticeController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除通知公告
|
* 删除通知公告
|
||||||
|
*
|
||||||
|
* @param noticeIds 公告ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除通知公告")
|
|
||||||
@SaCheckPermission("system:notice:remove")
|
@SaCheckPermission("system:notice:remove")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{noticeIds}")
|
@DeleteMapping("/{noticeIds}")
|
||||||
public R<Void> remove(@ApiParam("公告ID串") @PathVariable Long[] noticeIds) {
|
public R<Void> remove(@PathVariable Long[] noticeIds) {
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.validate.AddGroup;
|
import com.ruoyi.common.core.validate.AddGroup;
|
||||||
import com.ruoyi.common.core.validate.EditGroup;
|
import com.ruoyi.common.core.validate.EditGroup;
|
||||||
@ -14,9 +14,6 @@ import com.ruoyi.common.enums.BusinessType;
|
|||||||
import com.ruoyi.system.domain.bo.SysOssConfigBo;
|
import com.ruoyi.system.domain.bo.SysOssConfigBo;
|
||||||
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
||||||
import com.ruoyi.system.service.ISysOssConfigService;
|
import com.ruoyi.system.service.ISysOssConfigService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -26,14 +23,13 @@ import javax.validation.constraints.NotNull;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对象存储配置Controller
|
* 对象存储配置
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @author 孤舟烟雨
|
* @author 孤舟烟雨
|
||||||
* @date 2021-08-13
|
* @date 2021-08-13
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "对象存储配置控制器", tags = {"对象存储配置管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/oss/config")
|
@RequestMapping("/system/oss/config")
|
||||||
@ -44,7 +40,6 @@ public class SysOssConfigController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询对象存储配置列表
|
* 查询对象存储配置列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询对象存储配置列表")
|
|
||||||
@SaCheckPermission("system:oss:list")
|
@SaCheckPermission("system:oss:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageQuery pageQuery) {
|
public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageQuery pageQuery) {
|
||||||
@ -53,57 +48,54 @@ public class SysOssConfigController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对象存储配置详细信息
|
* 获取对象存储配置详细信息
|
||||||
|
*
|
||||||
|
* @param ossConfigId OSS配置ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取对象存储配置详细信息")
|
|
||||||
@SaCheckPermission("system:oss:query")
|
@SaCheckPermission("system:oss:query")
|
||||||
@GetMapping("/{ossConfigId}")
|
@GetMapping("/{ossConfigId}")
|
||||||
public R<SysOssConfigVo> getInfo(@ApiParam("OSS配置ID")
|
public R<SysOssConfigVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@NotNull(message = "主键不能为空")
|
@PathVariable Long ossConfigId) {
|
||||||
@PathVariable("ossConfigId") Long ossConfigId) {
|
|
||||||
return R.ok(iSysOssConfigService.queryById(ossConfigId));
|
return R.ok(iSysOssConfigService.queryById(ossConfigId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增对象存储配置
|
* 新增对象存储配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增对象存储配置")
|
|
||||||
@SaCheckPermission("system:oss:add")
|
@SaCheckPermission("system:oss:add")
|
||||||
@Log(title = "对象存储配置", businessType = BusinessType.INSERT)
|
@Log(title = "对象存储配置", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) {
|
||||||
return toAjax(iSysOssConfigService.insertByBo(bo) ? 1 : 0);
|
return toAjax(iSysOssConfigService.insertByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改对象存储配置
|
* 修改对象存储配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改对象存储配置")
|
|
||||||
@SaCheckPermission("system:oss:edit")
|
@SaCheckPermission("system:oss:edit")
|
||||||
@Log(title = "对象存储配置", businessType = BusinessType.UPDATE)
|
@Log(title = "对象存储配置", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) {
|
||||||
return toAjax(iSysOssConfigService.updateByBo(bo) ? 1 : 0);
|
return toAjax(iSysOssConfigService.updateByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除对象存储配置
|
* 删除对象存储配置
|
||||||
|
*
|
||||||
|
* @param ossConfigIds OSS配置ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除对象存储配置")
|
|
||||||
@SaCheckPermission("system:oss:remove")
|
@SaCheckPermission("system:oss:remove")
|
||||||
@Log(title = "对象存储配置", businessType = BusinessType.DELETE)
|
@Log(title = "对象存储配置", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ossConfigIds}")
|
@DeleteMapping("/{ossConfigIds}")
|
||||||
public R<Void> remove(@ApiParam("OSS配置ID串")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@NotEmpty(message = "主键不能为空")
|
|
||||||
@PathVariable Long[] ossConfigIds) {
|
@PathVariable Long[] ossConfigIds) {
|
||||||
return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0);
|
return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@ApiOperation("状态修改")
|
|
||||||
@SaCheckPermission("system:oss:edit")
|
@SaCheckPermission("system:oss:edit")
|
||||||
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
|
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
|
@ -15,11 +15,12 @@ import com.ruoyi.common.core.validate.QueryGroup;
|
|||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.file.FileUtils;
|
import com.ruoyi.common.utils.file.FileUtils;
|
||||||
|
import com.ruoyi.oss.core.OssClient;
|
||||||
|
import com.ruoyi.oss.factory.OssFactory;
|
||||||
import com.ruoyi.system.domain.SysOss;
|
import com.ruoyi.system.domain.SysOss;
|
||||||
import com.ruoyi.system.domain.bo.SysOssBo;
|
import com.ruoyi.system.domain.bo.SysOssBo;
|
||||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||||
import com.ruoyi.system.service.ISysOssService;
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -28,7 +29,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -41,7 +41,6 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "对象存储控制器", tags = {"对象存储管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/oss")
|
@RequestMapping("/system/oss")
|
||||||
@ -52,7 +51,6 @@ public class SysOssController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询OSS对象存储列表
|
* 查询OSS对象存储列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询OSS对象存储列表")
|
|
||||||
@SaCheckPermission("system:oss:list")
|
@SaCheckPermission("system:oss:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) {
|
public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) {
|
||||||
@ -61,12 +59,12 @@ public class SysOssController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询OSS对象基于id串
|
* 查询OSS对象基于id串
|
||||||
|
*
|
||||||
|
* @param ossIds OSS对象ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询OSS对象基于ID")
|
|
||||||
@SaCheckPermission("system:oss:list")
|
@SaCheckPermission("system:oss:list")
|
||||||
@GetMapping("/listByIds/{ossIds}")
|
@GetMapping("/listByIds/{ossIds}")
|
||||||
public R<List<SysOssVo>> listByIds(@ApiParam("OSS对象ID串")
|
public R<List<SysOssVo>> listByIds(@NotEmpty(message = "主键不能为空")
|
||||||
@NotEmpty(message = "主键不能为空")
|
|
||||||
@PathVariable Long[] ossIds) {
|
@PathVariable Long[] ossIds) {
|
||||||
List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds));
|
List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds));
|
||||||
return R.ok(list);
|
return R.ok(list);
|
||||||
@ -74,19 +72,17 @@ public class SysOssController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传OSS对象存储
|
* 上传OSS对象存储
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
*/
|
*/
|
||||||
@ApiOperation("上传OSS对象存储")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataTypeClass = File.class, required = true)
|
|
||||||
})
|
|
||||||
@SaCheckPermission("system:oss:upload")
|
@SaCheckPermission("system:oss:upload")
|
||||||
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/upload")
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
|
public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
|
||||||
if (ObjectUtil.isNull(file)) {
|
if (ObjectUtil.isNull(file)) {
|
||||||
throw new ServiceException("上传文件不能为空");
|
throw new ServiceException("上传文件不能为空");
|
||||||
}
|
}
|
||||||
SysOss oss = iSysOssService.upload(file);
|
SysOssVo oss = iSysOssService.upload(file);
|
||||||
Map<String, String> map = new HashMap<>(2);
|
Map<String, String> map = new HashMap<>(2);
|
||||||
map.put("url", oss.getUrl());
|
map.put("url", oss.getUrl());
|
||||||
map.put("fileName", oss.getOriginalName());
|
map.put("fileName", oss.getOriginalName());
|
||||||
@ -94,41 +90,28 @@ public class SysOssController extends BaseController {
|
|||||||
return R.ok(map);
|
return R.ok(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("下载OSS对象存储")
|
/**
|
||||||
|
* 下载OSS对象
|
||||||
|
*
|
||||||
|
* @param ossId OSS对象ID
|
||||||
|
*/
|
||||||
@SaCheckPermission("system:oss:download")
|
@SaCheckPermission("system:oss:download")
|
||||||
@GetMapping("/download/{ossId}")
|
@GetMapping("/download/{ossId}")
|
||||||
public void download(@ApiParam("OSS对象ID") @PathVariable Long ossId, HttpServletResponse response) throws IOException {
|
public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
|
||||||
SysOss sysOss = iSysOssService.getById(ossId);
|
iSysOssService.download(ossId,response);
|
||||||
if (ObjectUtil.isNull(sysOss)) {
|
|
||||||
throw new ServiceException("文件数据不存在!");
|
|
||||||
}
|
|
||||||
response.reset();
|
|
||||||
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
|
|
||||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
|
|
||||||
long data;
|
|
||||||
try {
|
|
||||||
data = HttpUtil.download(sysOss.getUrl(), response.getOutputStream(), false);
|
|
||||||
} catch (HttpException e) {
|
|
||||||
if (e.getMessage().contains("403")) {
|
|
||||||
throw new ServiceException("无读取权限, 请在对应的OSS开启'公有读'权限!");
|
|
||||||
} else {
|
|
||||||
throw new ServiceException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response.setContentLength(Convert.toInt(data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除OSS对象存储
|
* 删除OSS对象存储
|
||||||
|
*
|
||||||
|
* @param ossIds OSS对象ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除OSS对象存储")
|
|
||||||
@SaCheckPermission("system:oss:remove")
|
@SaCheckPermission("system:oss:remove")
|
||||||
@Log(title = "OSS对象存储", businessType = BusinessType.DELETE)
|
@Log(title = "OSS对象存储", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ossIds}")
|
@DeleteMapping("/{ossIds}")
|
||||||
public R<Void> remove(@ApiParam("OSS对象ID串")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@NotEmpty(message = "主键不能为空")
|
|
||||||
@PathVariable Long[] ossIds) {
|
@PathVariable Long[] ossIds) {
|
||||||
return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0);
|
return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,13 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -27,7 +24,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "岗位信息控制器", tags = {"岗位信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/post")
|
@RequestMapping("/system/post")
|
||||||
@ -38,14 +34,15 @@ public class SysPostController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取岗位列表
|
* 获取岗位列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取岗位列表")
|
|
||||||
@SaCheckPermission("system:post:list")
|
@SaCheckPermission("system:post:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) {
|
public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) {
|
||||||
return postService.selectPagePostList(post, pageQuery);
|
return postService.selectPagePostList(post, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出岗位列表")
|
/**
|
||||||
|
* 导出岗位列表
|
||||||
|
*/
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:post:export")
|
@SaCheckPermission("system:post:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -56,18 +53,18 @@ public class SysPostController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位编号获取详细信息
|
* 根据岗位编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param postId 岗位ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据岗位编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:post:query")
|
@SaCheckPermission("system:post:query")
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public R<SysPost> getInfo(@ApiParam("岗位ID") @PathVariable Long postId) {
|
public R<SysPost> getInfo(@PathVariable Long postId) {
|
||||||
return R.ok(postService.selectPostById(postId));
|
return R.ok(postService.selectPostById(postId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增岗位
|
* 新增岗位
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增岗位")
|
|
||||||
@SaCheckPermission("system:post:add")
|
@SaCheckPermission("system:post:add")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -83,7 +80,6 @@ public class SysPostController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改岗位
|
* 修改岗位
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改岗位")
|
|
||||||
@SaCheckPermission("system:post:edit")
|
@SaCheckPermission("system:post:edit")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -98,19 +94,19 @@ public class SysPostController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除岗位
|
* 删除岗位
|
||||||
|
*
|
||||||
|
* @param postIds 岗位ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除岗位")
|
|
||||||
@SaCheckPermission("system:post:remove")
|
@SaCheckPermission("system:post:remove")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{postIds}")
|
@DeleteMapping("/{postIds}")
|
||||||
public R<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] postIds) {
|
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取岗位选择框列表
|
* 获取岗位选择框列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取岗位选择框列表")
|
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysPost>> optionselect() {
|
public R<List<SysPost>> optionselect() {
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
|
@ -12,18 +12,15 @@ import com.ruoyi.common.helper.LoginHelper;
|
|||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.file.MimeTypeUtils;
|
import com.ruoyi.common.utils.file.MimeTypeUtils;
|
||||||
import com.ruoyi.system.domain.SysOss;
|
import com.ruoyi.system.domain.SysOss;
|
||||||
|
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||||
import com.ruoyi.system.service.ISysOssService;
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -34,7 +31,6 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "个人信息控制器", tags = {"个人信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/user/profile")
|
@RequestMapping("/system/user/profile")
|
||||||
@ -46,7 +42,6 @@ public class SysProfileController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 个人信息
|
* 个人信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("个人信息")
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public R<Map<String, Object>> profile() {
|
public R<Map<String, Object>> profile() {
|
||||||
SysUser user = userService.selectUserById(getUserId());
|
SysUser user = userService.selectUserById(getUserId());
|
||||||
@ -60,7 +55,6 @@ public class SysProfileController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改用户")
|
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> updateProfile(@RequestBody SysUser user) {
|
public R<Void> updateProfile(@RequestBody SysUser user) {
|
||||||
@ -75,6 +69,8 @@ public class SysProfileController extends BaseController {
|
|||||||
user.setUserId(getUserId());
|
user.setUserId(getUserId());
|
||||||
user.setUserName(null);
|
user.setUserName(null);
|
||||||
user.setPassword(null);
|
user.setPassword(null);
|
||||||
|
user.setAvatar(null);
|
||||||
|
user.setDeptId(null);
|
||||||
if (userService.updateUserProfile(user) > 0) {
|
if (userService.updateUserProfile(user) > 0) {
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -83,12 +79,10 @@ public class SysProfileController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
|
*
|
||||||
|
* @param newPassword 旧密码
|
||||||
|
* @param oldPassword 新密码
|
||||||
*/
|
*/
|
||||||
@ApiOperation("重置密码")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "oldPassword", value = "旧密码", paramType = "query", dataTypeClass = String.class),
|
|
||||||
@ApiImplicitParam(name = "newPassword", value = "新密码", paramType = "query", dataTypeClass = String.class)
|
|
||||||
})
|
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updatePwd")
|
@PutMapping("/updatePwd")
|
||||||
public R<Void> updatePwd(String oldPassword, String newPassword) {
|
public R<Void> updatePwd(String oldPassword, String newPassword) {
|
||||||
@ -110,21 +104,19 @@ public class SysProfileController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 头像上传
|
* 头像上传
|
||||||
|
*
|
||||||
|
* @param avatarfile 用户头像
|
||||||
*/
|
*/
|
||||||
@ApiOperation("头像上传")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "avatarfile", value = "用户头像", paramType = "query", dataTypeClass = File.class, required = true)
|
|
||||||
})
|
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/avatar")
|
@PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) {
|
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
if (!file.isEmpty()) {
|
if (!avatarfile.isEmpty()) {
|
||||||
String extension = FileUtil.extName(file.getOriginalFilename());
|
String extension = FileUtil.extName(avatarfile.getOriginalFilename());
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
||||||
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
|
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
|
||||||
}
|
}
|
||||||
SysOss oss = iSysOssService.upload(file);
|
SysOssVo oss = iSysOssService.upload(avatarfile);
|
||||||
String avatar = oss.getUrl();
|
String avatar = oss.getUrl();
|
||||||
if (userService.updateUserAvatar(getUsername(), avatar)) {
|
if (userService.updateUserAvatar(getUsername(), avatar)) {
|
||||||
ajax.put("imgUrl", avatar);
|
ajax.put("imgUrl", avatar);
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.Anonymous;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import com.ruoyi.system.service.SysRegisterService;
|
import com.ruoyi.system.service.SysRegisterService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -20,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "注册验证控制器", tags = {"注册验证管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
public class SysRegisterController extends BaseController {
|
public class SysRegisterController extends BaseController {
|
||||||
@ -28,8 +25,10 @@ public class SysRegisterController extends BaseController {
|
|||||||
private final SysRegisterService registerService;
|
private final SysRegisterService registerService;
|
||||||
private final ISysConfigService configService;
|
private final ISysConfigService configService;
|
||||||
|
|
||||||
@Anonymous
|
/**
|
||||||
@ApiOperation("用户注册")
|
* 用户注册
|
||||||
|
*/
|
||||||
|
@SaIgnore
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||||
|
@ -5,8 +5,9 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
@ -15,16 +16,18 @@ import com.ruoyi.common.enums.BusinessType;
|
|||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import com.ruoyi.system.service.SysPermissionService;
|
import com.ruoyi.system.service.SysPermissionService;
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色信息
|
* 角色信息
|
||||||
@ -32,7 +35,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "角色信息控制器", tags = {"角色信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/role")
|
@RequestMapping("/system/role")
|
||||||
@ -40,16 +42,21 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
private final ISysUserService userService;
|
private final ISysUserService userService;
|
||||||
|
private final ISysDeptService deptService;
|
||||||
private final SysPermissionService permissionService;
|
private final SysPermissionService permissionService;
|
||||||
|
|
||||||
@ApiOperation("查询角色信息列表")
|
/**
|
||||||
|
* 获取角色信息列表
|
||||||
|
*/
|
||||||
@SaCheckPermission("system:role:list")
|
@SaCheckPermission("system:role:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) {
|
public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) {
|
||||||
return roleService.selectPageRoleList(role, pageQuery);
|
return roleService.selectPageRoleList(role, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出角色信息列表")
|
/**
|
||||||
|
* 导出角色信息列表
|
||||||
|
*/
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:role:export")
|
@SaCheckPermission("system:role:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -60,11 +67,12 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色编号获取详细信息
|
* 根据角色编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param roleId 角色ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据角色编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:role:query")
|
@SaCheckPermission("system:role:query")
|
||||||
@GetMapping(value = "/{roleId}")
|
@GetMapping(value = "/{roleId}")
|
||||||
public R<SysRole> getInfo(@ApiParam("角色ID") @PathVariable Long roleId) {
|
public R<SysRole> getInfo(@PathVariable Long roleId) {
|
||||||
roleService.checkRoleDataScope(roleId);
|
roleService.checkRoleDataScope(roleId);
|
||||||
return R.ok(roleService.selectRoleById(roleId));
|
return R.ok(roleService.selectRoleById(roleId));
|
||||||
}
|
}
|
||||||
@ -72,7 +80,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增角色
|
* 新增角色
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增角色")
|
|
||||||
@SaCheckPermission("system:role:add")
|
@SaCheckPermission("system:role:add")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -89,7 +96,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改保存角色
|
* 修改保存角色
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改保存角色")
|
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ -118,7 +124,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改保存数据权限
|
* 修改保存数据权限
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改保存数据权限")
|
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/dataScope")
|
@PutMapping("/dataScope")
|
||||||
@ -131,7 +136,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@ApiOperation("状态修改")
|
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
@ -143,19 +147,19 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除角色
|
* 删除角色
|
||||||
|
*
|
||||||
|
* @param roleIds 角色ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除角色")
|
|
||||||
@SaCheckPermission("system:role:remove")
|
@SaCheckPermission("system:role:remove")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{roleIds}")
|
@DeleteMapping("/{roleIds}")
|
||||||
public R<Void> remove(@ApiParam("角色ID串") @PathVariable Long[] roleIds) {
|
public R<Void> remove(@PathVariable Long[] roleIds) {
|
||||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色选择框列表
|
* 获取角色选择框列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取角色选择框列表")
|
|
||||||
@SaCheckPermission("system:role:query")
|
@SaCheckPermission("system:role:query")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysRole>> optionselect() {
|
public R<List<SysRole>> optionselect() {
|
||||||
@ -165,7 +169,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询已分配用户角色列表
|
* 查询已分配用户角色列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询已分配用户角色列表")
|
|
||||||
@SaCheckPermission("system:role:list")
|
@SaCheckPermission("system:role:list")
|
||||||
@GetMapping("/authUser/allocatedList")
|
@GetMapping("/authUser/allocatedList")
|
||||||
public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) {
|
||||||
@ -175,7 +178,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询未分配用户角色列表
|
* 查询未分配用户角色列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询未分配用户角色列表")
|
|
||||||
@SaCheckPermission("system:role:list")
|
@SaCheckPermission("system:role:list")
|
||||||
@GetMapping("/authUser/unallocatedList")
|
@GetMapping("/authUser/unallocatedList")
|
||||||
public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) {
|
||||||
@ -185,7 +187,6 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 取消授权用户
|
* 取消授权用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("取消授权用户")
|
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/cancel")
|
@PutMapping("/authUser/cancel")
|
||||||
@ -195,12 +196,10 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量取消授权用户
|
* 批量取消授权用户
|
||||||
|
*
|
||||||
|
* @param roleId 角色ID
|
||||||
|
* @param userIds 用户ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("批量取消授权用户")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
|
||||||
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
|
||||||
})
|
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/cancelAll")
|
@PutMapping("/authUser/cancelAll")
|
||||||
@ -210,12 +209,10 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量选择用户授权
|
* 批量选择用户授权
|
||||||
|
*
|
||||||
|
* @param roleId 角色ID
|
||||||
|
* @param userIds 用户ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("批量选择用户授权")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
|
||||||
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
|
||||||
})
|
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
@ -223,4 +220,18 @@ public class SysRoleController extends BaseController {
|
|||||||
roleService.checkRoleDataScope(roleId);
|
roleService.checkRoleDataScope(roleId);
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应角色部门树列表
|
||||||
|
*
|
||||||
|
* @param roleId 角色ID
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("system:role:list")
|
||||||
|
@GetMapping(value = "/deptTree/{roleId}")
|
||||||
|
public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||||
|
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
||||||
|
return R.ok(ajax);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
@ -17,16 +18,18 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.excel.ExcelResult;
|
import com.ruoyi.common.excel.ExcelResult;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
|
import com.ruoyi.common.utils.StreamUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.vo.SysUserExportVo;
|
import com.ruoyi.system.domain.vo.SysUserExportVo;
|
||||||
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
||||||
import com.ruoyi.system.listener.SysUserImportListener;
|
import com.ruoyi.system.listener.SysUserImportListener;
|
||||||
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@ -36,7 +39,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
@ -44,7 +46,6 @@ import java.util.stream.Collectors;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "用户信息控制器", tags = {"用户信息管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/user")
|
@RequestMapping("/system/user")
|
||||||
@ -53,18 +54,20 @@ public class SysUserController extends BaseController {
|
|||||||
private final ISysUserService userService;
|
private final ISysUserService userService;
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
private final ISysPostService postService;
|
private final ISysPostService postService;
|
||||||
|
private final ISysDeptService deptService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取用户列表")
|
|
||||||
@SaCheckPermission("system:user:list")
|
@SaCheckPermission("system:user:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) {
|
||||||
return userService.selectPageUserList(user, pageQuery);
|
return userService.selectPageUserList(user, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出用户列表")
|
/**
|
||||||
|
* 导出用户列表
|
||||||
|
*/
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:user:export")
|
@SaCheckPermission("system:user:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -82,19 +85,23 @@ public class SysUserController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
|
ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导入用户列表")
|
/**
|
||||||
@ApiImplicitParams({
|
* 导入数据
|
||||||
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
|
*
|
||||||
})
|
* @param file 导入文件
|
||||||
|
* @param updateSupport 是否更新已存在数据
|
||||||
|
*/
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
@SaCheckPermission("system:user:import")
|
@SaCheckPermission("system:user:import")
|
||||||
@PostMapping("/importData")
|
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
|
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
|
||||||
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
||||||
return R.ok(result.getAnalysis());
|
return R.ok(result.getAnalysis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("下载导入模板")
|
/**
|
||||||
|
* 获取导入模板
|
||||||
|
*/
|
||||||
@PostMapping("/importTemplate")
|
@PostMapping("/importTemplate")
|
||||||
public void importTemplate(HttpServletResponse response) {
|
public void importTemplate(HttpServletResponse response) {
|
||||||
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
||||||
@ -102,21 +109,22 @@ public class SysUserController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户编号获取详细信息
|
* 根据用户编号获取详细信息
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据用户编号获取详细信息")
|
|
||||||
@SaCheckPermission("system:user:query")
|
@SaCheckPermission("system:user:query")
|
||||||
@GetMapping(value = {"/", "/{userId}"})
|
@GetMapping(value = {"/", "/{userId}"})
|
||||||
public R<Map<String, Object>> getInfo(@ApiParam("用户ID") @PathVariable(value = "userId", required = false) Long userId) {
|
public R<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||||
userService.checkUserDataScope(userId);
|
userService.checkUserDataScope(userId);
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin()));
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts", postService.selectPostAll());
|
||||||
if (ObjectUtil.isNotNull(userId)) {
|
if (ObjectUtil.isNotNull(userId)) {
|
||||||
SysUser sysUser = userService.selectUserById(userId);
|
SysUser sysUser = userService.selectUserById(userId);
|
||||||
ajax.put("user", sysUser);
|
ajax.put("user", sysUser);
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
ajax.put("roleIds", StreamUtils.toList(sysUser.getRoles(), SysRole::getRoleId));
|
||||||
}
|
}
|
||||||
return R.ok(ajax);
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
@ -124,12 +132,11 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增用户
|
* 新增用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增用户")
|
|
||||||
@SaCheckPermission("system:user:add")
|
@SaCheckPermission("system:user:add")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysUser user) {
|
public R<Void> add(@Validated @RequestBody SysUser user) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
|
||||||
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
@ -145,14 +152,15 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改用户")
|
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysUser user) {
|
public R<Void> edit(@Validated @RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
userService.checkUserDataScope(user.getUserId());
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
|
||||||
|
return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
@ -164,12 +172,13 @@ public class SysUserController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除用户
|
* 删除用户
|
||||||
|
*
|
||||||
|
* @param userIds 角色ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除用户")
|
|
||||||
@SaCheckPermission("system:user:remove")
|
@SaCheckPermission("system:user:remove")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{userIds}")
|
@DeleteMapping("/{userIds}")
|
||||||
public R<Void> remove(@ApiParam("角色ID串") @PathVariable Long[] userIds) {
|
public R<Void> remove(@PathVariable Long[] userIds) {
|
||||||
if (ArrayUtil.contains(userIds, getUserId())) {
|
if (ArrayUtil.contains(userIds, getUserId())) {
|
||||||
return R.fail("当前用户不能删除");
|
return R.fail("当前用户不能删除");
|
||||||
}
|
}
|
||||||
@ -179,7 +188,6 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@ApiOperation("重置密码")
|
|
||||||
@SaCheckPermission("system:user:resetPwd")
|
@SaCheckPermission("system:user:resetPwd")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/resetPwd")
|
@PutMapping("/resetPwd")
|
||||||
@ -193,7 +201,6 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@ApiOperation("状态修改")
|
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
@ -205,27 +212,26 @@ public class SysUserController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户编号获取授权角色
|
* 根据用户编号获取授权角色
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据用户编号获取授权角色")
|
|
||||||
@SaCheckPermission("system:user:query")
|
@SaCheckPermission("system:user:query")
|
||||||
@GetMapping("/authRole/{userId}")
|
@GetMapping("/authRole/{userId}")
|
||||||
public R<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") Long userId) {
|
public R<Map<String, Object>> authRole(@PathVariable Long userId) {
|
||||||
SysUser user = userService.selectUserById(userId);
|
SysUser user = userService.selectUserById(userId);
|
||||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("user", user);
|
ajax.put("user", user);
|
||||||
ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin()));
|
||||||
return R.ok(ajax);
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
|
*
|
||||||
|
* @param userId 用户Id
|
||||||
|
* @param roleIds 角色ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("用户授权角色")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "userId", value = "用户Id", paramType = "query", dataTypeClass = String.class),
|
|
||||||
@ApiImplicitParam(name = "roleIds", value = "角色ID串", paramType = "query", dataTypeClass = String.class)
|
|
||||||
})
|
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authRole")
|
@PutMapping("/authRole")
|
||||||
@ -234,4 +240,14 @@ public class SysUserController extends BaseController {
|
|||||||
userService.insertUserAuth(userId, roleIds);
|
userService.insertUserAuth(userId, roleIds);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门树列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("system:user:list")
|
||||||
|
@GetMapping("/deptTree")
|
||||||
|
public R<List<Tree<Long>>> deptTree(SysDept dept) {
|
||||||
|
return R.ok(deptService.selectDeptTreeList(dept));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ xxl.job:
|
|||||||
--- # 数据源配置
|
--- # 数据源配置
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||||
dynamic:
|
dynamic:
|
||||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||||
@ -45,6 +45,7 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
|
type: ${spring.datasource.type}
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||||
@ -54,72 +55,46 @@ spring:
|
|||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
lazy: true
|
lazy: true
|
||||||
|
type: ${spring.datasource.type}
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
url:
|
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
# oracle:
|
# oracle:
|
||||||
|
# type: ${spring.datasource.type}
|
||||||
# driverClassName: oracle.jdbc.OracleDriver
|
# driverClassName: oracle.jdbc.OracleDriver
|
||||||
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
||||||
# username: ROOT
|
# username: ROOT
|
||||||
# password: root
|
# password: root
|
||||||
# druid:
|
# hikari:
|
||||||
# validationQuery: SELECT 1 FROM DUAL
|
# connectionTestQuery: SELECT 1 FROM DUAL
|
||||||
# postgres:
|
# postgres:
|
||||||
|
# type: ${spring.datasource.type}
|
||||||
# driverClassName: org.postgresql.Driver
|
# driverClassName: org.postgresql.Driver
|
||||||
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||||
# username: root
|
# username: root
|
||||||
# password: root
|
# password: root
|
||||||
# sqlserver:
|
# sqlserver:
|
||||||
|
# type: ${spring.datasource.type}
|
||||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;rewriteBatchedStatements=true
|
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
|
||||||
# username: SA
|
# username: SA
|
||||||
# password: root
|
# password: root
|
||||||
druid:
|
hikari:
|
||||||
# 初始连接数
|
|
||||||
initialSize: 5
|
|
||||||
# 最小连接池数量
|
|
||||||
minIdle: 10
|
|
||||||
# 最大连接池数量
|
# 最大连接池数量
|
||||||
maxActive: 20
|
maxPoolSize: 20
|
||||||
|
# 最小空闲线程数量
|
||||||
|
minIdle: 10
|
||||||
# 配置获取连接等待超时的时间
|
# 配置获取连接等待超时的时间
|
||||||
maxWait: 60000
|
connectionTimeout: 10000
|
||||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
# 校验超时时间
|
||||||
timeBetweenEvictionRunsMillis: 60000
|
validationTimeout: 5000
|
||||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
# 空闲连接存活最大时间,默认10分钟
|
||||||
minEvictableIdleTimeMillis: 300000
|
idleTimeout: 60000
|
||||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||||
maxEvictableIdleTimeMillis: 900000
|
maxLifetime: 900000
|
||||||
# 配置检测连接是否有效
|
# 连接测试query(配置检测连接是否有效)
|
||||||
validationQuery: SELECT 1
|
connectionTestQuery: SELECT 1
|
||||||
testWhileIdle: true
|
|
||||||
testOnBorrow: false
|
|
||||||
testOnReturn: false
|
|
||||||
# 注意这个值和druid原生不一致,默认启动了stat
|
|
||||||
filters: stat
|
|
||||||
|
|
||||||
--- # druid 配置
|
|
||||||
spring.datasource.druid:
|
|
||||||
webStatFilter:
|
|
||||||
enabled: true
|
|
||||||
statViewServlet:
|
|
||||||
enabled: true
|
|
||||||
# 设置白名单,不填则允许所有访问
|
|
||||||
allow:
|
|
||||||
url-pattern: /druid/*
|
|
||||||
# 控制台管理用户名和密码
|
|
||||||
login-username: ruoyi
|
|
||||||
login-password: 123456
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
enabled: true
|
|
||||||
# 慢SQL记录
|
|
||||||
log-slow-sql: true
|
|
||||||
slow-sql-millis: 1000
|
|
||||||
merge-sql: true
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
||||||
|
|
||||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||||
spring:
|
spring:
|
||||||
@ -138,6 +113,8 @@ spring:
|
|||||||
ssl: false
|
ssl: false
|
||||||
|
|
||||||
redisson:
|
redisson:
|
||||||
|
# redis key前缀
|
||||||
|
keyPrefix:
|
||||||
# 线程池数量
|
# 线程池数量
|
||||||
threads: 4
|
threads: 4
|
||||||
# Netty线程池数量
|
# Netty线程池数量
|
||||||
|
@ -5,7 +5,7 @@ spring.servlet.multipart.location: /ruoyi/server/temp
|
|||||||
spring.boot.admin.client:
|
spring.boot.admin.client:
|
||||||
# 增加客户端开关
|
# 增加客户端开关
|
||||||
enabled: true
|
enabled: true
|
||||||
url: http://172.30.0.90:9090/admin
|
url: http://localhost:9090/admin
|
||||||
instance:
|
instance:
|
||||||
service-host-type: IP
|
service-host-type: IP
|
||||||
username: ruoyi
|
username: ruoyi
|
||||||
@ -16,7 +16,7 @@ xxl.job:
|
|||||||
# 执行器开关
|
# 执行器开关
|
||||||
enabled: true
|
enabled: true
|
||||||
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
||||||
admin-addresses: http://172.30.0.92:9100/xxl-job-admin
|
admin-addresses: http://localhost:9100/xxl-job-admin
|
||||||
# 执行器通讯TOKEN:非空时启用
|
# 执行器通讯TOKEN:非空时启用
|
||||||
access-token: xxl-job
|
access-token: xxl-job
|
||||||
executor:
|
executor:
|
||||||
@ -36,7 +36,7 @@ xxl.job:
|
|||||||
--- # 数据源配置
|
--- # 数据源配置
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||||
dynamic:
|
dynamic:
|
||||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||||
@ -48,87 +48,62 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
|
type: ${spring.datasource.type}
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||||
url: jdbc:mysql://172.30.0.36:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: root
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
lazy: true
|
lazy: true
|
||||||
|
type: ${spring.datasource.type}
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
url:
|
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
# oracle:
|
# oracle:
|
||||||
|
# type: ${spring.datasource.type}
|
||||||
# driverClassName: oracle.jdbc.OracleDriver
|
# driverClassName: oracle.jdbc.OracleDriver
|
||||||
# url: jdbc:oracle:thin:@//172.30.0.36:1521/XE
|
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
||||||
# username: ROOT
|
# username: ROOT
|
||||||
# password: root
|
# password: root
|
||||||
# druid:
|
# hikari:
|
||||||
# validationQuery: SELECT 1 FROM DUAL
|
# connectionTestQuery: SELECT 1 FROM DUAL
|
||||||
# postgres:
|
# postgres:
|
||||||
|
# type: ${spring.datasource.type}
|
||||||
# driverClassName: org.postgresql.Driver
|
# driverClassName: org.postgresql.Driver
|
||||||
# url: jdbc:postgresql://172.30.0.36:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||||
# username: root
|
# username: root
|
||||||
# password: root
|
# password: root
|
||||||
# sqlserver:
|
# sqlserver:
|
||||||
|
# type: ${spring.datasource.type}
|
||||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||||
# url: jdbc:sqlserver://172.30.0.36:1433;DatabaseName=tempdb;SelectMethod=cursor;rewriteBatchedStatements=true
|
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
|
||||||
# username: SA
|
# username: SA
|
||||||
# password: root
|
# password: root
|
||||||
druid:
|
hikari:
|
||||||
# 初始连接数
|
|
||||||
initialSize: 5
|
|
||||||
# 最小连接池数量
|
|
||||||
minIdle: 10
|
|
||||||
# 最大连接池数量
|
# 最大连接池数量
|
||||||
maxActive: 20
|
maxPoolSize: 20
|
||||||
|
# 最小空闲线程数量
|
||||||
|
minIdle: 10
|
||||||
# 配置获取连接等待超时的时间
|
# 配置获取连接等待超时的时间
|
||||||
maxWait: 60000
|
connectionTimeout: 10000
|
||||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
# 校验超时时间
|
||||||
timeBetweenEvictionRunsMillis: 60000
|
validationTimeout: 5000
|
||||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
# 空闲连接存活最大时间,默认10分钟
|
||||||
minEvictableIdleTimeMillis: 300000
|
idleTimeout: 60000
|
||||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||||
maxEvictableIdleTimeMillis: 900000
|
maxLifetime: 900000
|
||||||
# 配置检测连接是否有效
|
# 连接测试query(配置检测连接是否有效)
|
||||||
validationQuery: SELECT 1
|
connectionTestQuery: SELECT 1
|
||||||
testWhileIdle: true
|
|
||||||
testOnBorrow: false
|
|
||||||
testOnReturn: false
|
|
||||||
# 注意这个值和druid原生不一致,默认启动了stat
|
|
||||||
filters: stat
|
|
||||||
|
|
||||||
--- # druid 配置
|
|
||||||
spring.datasource.druid:
|
|
||||||
webStatFilter:
|
|
||||||
enabled: true
|
|
||||||
statViewServlet:
|
|
||||||
enabled: true
|
|
||||||
# 设置白名单,不填则允许所有访问
|
|
||||||
allow:
|
|
||||||
url-pattern: /druid/*
|
|
||||||
# 控制台管理用户名和密码
|
|
||||||
login-username: ruoyi
|
|
||||||
login-password: 123456
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
enabled: true
|
|
||||||
# 慢SQL记录
|
|
||||||
log-slow-sql: true
|
|
||||||
slow-sql-millis: 1000
|
|
||||||
merge-sql: true
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
||||||
|
|
||||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||||
spring:
|
spring:
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
host: 172.30.0.48
|
host: localhost
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
@ -141,6 +116,8 @@ spring:
|
|||||||
ssl: false
|
ssl: false
|
||||||
|
|
||||||
redisson:
|
redisson:
|
||||||
|
# redis key前缀
|
||||||
|
keyPrefix:
|
||||||
# 线程池数量
|
# 线程池数量
|
||||||
threads: 16
|
threads: 16
|
||||||
# Netty线程池数量
|
# Netty线程池数量
|
||||||
|
@ -53,6 +53,14 @@ logging:
|
|||||||
org.springframework: warn
|
org.springframework: warn
|
||||||
config: classpath:logback.xml
|
config: classpath:logback.xml
|
||||||
|
|
||||||
|
# 用户配置
|
||||||
|
user:
|
||||||
|
password:
|
||||||
|
# 密码最大错误次数
|
||||||
|
maxRetryCount: 5
|
||||||
|
# 密码锁定时间(默认10分钟)
|
||||||
|
lockTime: 10
|
||||||
|
|
||||||
# Spring配置
|
# Spring配置
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
@ -75,10 +83,6 @@ spring:
|
|||||||
restart:
|
restart:
|
||||||
# 热部署开关
|
# 热部署开关
|
||||||
enabled: true
|
enabled: true
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
# 适配 boot 2.6 路由与 springfox 兼容
|
|
||||||
matching-strategy: ANT_PATH_MATCHER
|
|
||||||
jackson:
|
jackson:
|
||||||
# 日期格式化
|
# 日期格式化
|
||||||
date-format: yyyy-MM-dd HH:mm:ss
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
@ -104,15 +108,13 @@ sa-token:
|
|||||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||||
is-share: false
|
is-share: false
|
||||||
# 是否尝试从header里读取token
|
# 是否尝试从header里读取token
|
||||||
is-read-head: true
|
is-read-header: true
|
||||||
# 是否尝试从cookie里读取token
|
# 是否尝试从cookie里读取token
|
||||||
is-read-cookie: false
|
is-read-cookie: false
|
||||||
# token前缀
|
# token前缀
|
||||||
token-prefix: "Bearer"
|
token-prefix: "Bearer"
|
||||||
# jwt秘钥
|
# jwt秘钥
|
||||||
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
|
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
|
||||||
# 是否输出操作日志
|
|
||||||
is-log: true
|
|
||||||
|
|
||||||
# security配置
|
# security配置
|
||||||
security:
|
security:
|
||||||
@ -125,12 +127,8 @@ security:
|
|||||||
- /**/*.js
|
- /**/*.js
|
||||||
# swagger 文档配置
|
# swagger 文档配置
|
||||||
- /favicon.ico
|
- /favicon.ico
|
||||||
- /doc.html
|
|
||||||
- /swagger-resources/**
|
|
||||||
- /webjars/**
|
|
||||||
- /*/api-docs
|
- /*/api-docs
|
||||||
# druid 监控配置
|
- /*/api-docs/**
|
||||||
- /druid/**
|
|
||||||
# actuator 监控配置
|
# actuator 监控配置
|
||||||
- /actuator
|
- /actuator
|
||||||
- /actuator/**
|
- /actuator/**
|
||||||
@ -183,8 +181,7 @@ mybatis-plus:
|
|||||||
swagger:
|
swagger:
|
||||||
# 是否开启swagger
|
# 是否开启swagger
|
||||||
enabled: true
|
enabled: true
|
||||||
# 请求前缀
|
info:
|
||||||
pathMapping: /dev-api
|
|
||||||
# 标题
|
# 标题
|
||||||
title: '标题:${ruoyi.name}后台管理系统_接口文档'
|
title: '标题:${ruoyi.name}后台管理系统_接口文档'
|
||||||
# 描述
|
# 描述
|
||||||
@ -196,33 +193,23 @@ swagger:
|
|||||||
name: Lion Li
|
name: Lion Li
|
||||||
email: crazylionli@163.com
|
email: crazylionli@163.com
|
||||||
url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus
|
url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus
|
||||||
groups:
|
components:
|
||||||
- name: 1.演示案例
|
# 鉴权方式配置
|
||||||
basePackage: com.ruoyi.demo
|
security-schemes:
|
||||||
- name: 2.系统模块
|
apiKey:
|
||||||
basePackage: com.ruoyi.web
|
type: APIKEY
|
||||||
- name: 3.代码生成模块
|
in: HEADER
|
||||||
basePackage: com.ruoyi.generator
|
name: ${sa-token.token-name}
|
||||||
|
|
||||||
knife4j:
|
springdoc:
|
||||||
# 是否开启Knife4j增强模式
|
#这里定义了两个分组,可定义多个,也可以不定义
|
||||||
enable: true
|
group-configs:
|
||||||
# 是否开启生产环境保护策略
|
- group: 1.演示模块
|
||||||
production: @knife4j.production@
|
packages-to-scan: com.ruoyi.demo
|
||||||
basic:
|
- group: 2.系统模块
|
||||||
enable: true
|
packages-to-scan: com.ruoyi.web
|
||||||
username: ruoyi
|
- group: 3.代码生成模块
|
||||||
password: 123456
|
packages-to-scan: com.ruoyi.generator
|
||||||
# 前端Ui的个性化配置属性
|
|
||||||
setting:
|
|
||||||
# 默认语言
|
|
||||||
language: zh-CN
|
|
||||||
# 是否显示Footer
|
|
||||||
enableFooter: false
|
|
||||||
# 是否开启动态参数调试功能
|
|
||||||
enableDynamicParameter: true
|
|
||||||
# 是否在每个Debug调试栏后显示刷新变量按钮
|
|
||||||
enableReloadCacheParameter: true
|
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
xss:
|
xss:
|
||||||
@ -242,26 +229,11 @@ thread-pool:
|
|||||||
# 线程池维护线程所允许的空闲时间
|
# 线程池维护线程所允许的空闲时间
|
||||||
keepAliveSeconds: 300
|
keepAliveSeconds: 300
|
||||||
|
|
||||||
--- # redisson 缓存配置
|
|
||||||
redisson:
|
|
||||||
cacheGroup:
|
|
||||||
# 用例: @Cacheable(cacheNames="groupId", key="#XXX") 方可使用缓存组配置
|
|
||||||
- groupId: redissonCacheMap
|
|
||||||
# 组过期时间(脚本监控)
|
|
||||||
ttl: 60000
|
|
||||||
# 组最大空闲时间(脚本监控)
|
|
||||||
maxIdleTime: 60000
|
|
||||||
# 组最大长度
|
|
||||||
maxSize: 0
|
|
||||||
- groupId: testCache
|
|
||||||
ttl: 1000
|
|
||||||
maxIdleTime: 500
|
|
||||||
|
|
||||||
--- # 分布式锁 lock4j 全局配置
|
--- # 分布式锁 lock4j 全局配置
|
||||||
lock4j:
|
lock4j:
|
||||||
# 获取分布式锁超时时间,默认为 3000 毫秒
|
# 获取分布式锁超时时间,默认为 3000 毫秒
|
||||||
acquire-timeout: 3000
|
acquire-timeout: 3000
|
||||||
# 分布式锁的超时时间,默认为 30 毫秒
|
# 分布式锁的超时时间,默认为 30 秒
|
||||||
expire: 30000
|
expire: 30000
|
||||||
|
|
||||||
--- # Actuator 监控端点的配置项
|
--- # Actuator 监控端点的配置项
|
||||||
@ -269,9 +241,9 @@ management:
|
|||||||
endpoints:
|
endpoints:
|
||||||
web:
|
web:
|
||||||
exposure:
|
exposure:
|
||||||
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
|
include: '*'
|
||||||
# 生产环境不建议放开所有 根据项目需求放开即可
|
|
||||||
include: @endpoints.include@
|
|
||||||
endpoint:
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: ALWAYS
|
||||||
logfile:
|
logfile:
|
||||||
external-file: ./logs/sys-console.log
|
external-file: ./logs/sys-console.log
|
||||||
|
@ -5,7 +5,7 @@ user.jcaptcha.expire=验证码已失效
|
|||||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
user.not.exists=对不起, 您的账号:{0} 不存在.
|
||||||
user.password.not.match=用户不存在/密码错误
|
user.password.not.match=用户不存在/密码错误
|
||||||
user.password.retry.limit.count=密码输入错误{0}次
|
user.password.retry.limit.count=密码输入错误{0}次
|
||||||
user.password.retry.limit.exceed=密码错误次数过多,帐户锁定{0}分钟
|
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||||
user.password.delete=对不起,您的账号:{0} 已被删除
|
user.password.delete=对不起,您的账号:{0} 已被删除
|
||||||
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
||||||
role.blocked=角色已封禁,请联系管理员
|
role.blocked=角色已封禁,请联系管理员
|
||||||
@ -41,5 +41,5 @@ repeat.submit.message=不允许重复提交,请稍候再试
|
|||||||
rate.limiter.message=访问过于频繁,请稍候再试
|
rate.limiter.message=访问过于频繁,请稍候再试
|
||||||
sms.code.not.blank=短信验证码不能为空
|
sms.code.not.blank=短信验证码不能为空
|
||||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
||||||
sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟
|
sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{0}分钟
|
||||||
xcx.code.not.blank=小程序code不能为空
|
xcx.code.not.blank=小程序code不能为空
|
||||||
|
@ -5,7 +5,7 @@ user.jcaptcha.expire=Captcha invalid
|
|||||||
user.not.exists=Sorry, your account: {0} does not exist
|
user.not.exists=Sorry, your account: {0} does not exist
|
||||||
user.password.not.match=User does not exist/Password error
|
user.password.not.match=User does not exist/Password error
|
||||||
user.password.retry.limit.count=Password input error {0} times
|
user.password.retry.limit.count=Password input error {0} times
|
||||||
user.password.retry.limit.exceed=Too many password errors, account locked for {0} minutes
|
user.password.retry.limit.exceed=Password input error {0} times, account locked for {1} minutes
|
||||||
user.password.delete=Sorry, your account:{0} has been deleted
|
user.password.delete=Sorry, your account:{0} has been deleted
|
||||||
user.blocked=Sorry, your account: {0} has been disabled. Please contact the administrator
|
user.blocked=Sorry, your account: {0} has been disabled. Please contact the administrator
|
||||||
role.blocked=Role disabled,please contact administrators
|
role.blocked=Role disabled,please contact administrators
|
||||||
@ -41,5 +41,5 @@ repeat.submit.message=Repeat submit is not allowed, please try again later
|
|||||||
rate.limiter.message=Visit too frequently, please try again later
|
rate.limiter.message=Visit too frequently, please try again later
|
||||||
sms.code.not.blank=Sms code cannot be blank
|
sms.code.not.blank=Sms code cannot be blank
|
||||||
sms.code.retry.limit.count=Sms code input error {0} times
|
sms.code.retry.limit.count=Sms code input error {0} times
|
||||||
sms.code.retry.limit.exceed=Too many sms code errors, account locked for {0} minutes
|
sms.code.retry.limit.exceed=Sms code input error {0} times, account locked for {0} minutes
|
||||||
xcx.code.not.blank=Mini program code cannot be blank
|
xcx.code.not.blank=Mini program code cannot be blank
|
||||||
|
@ -5,7 +5,7 @@ user.jcaptcha.expire=验证码已失效
|
|||||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
user.not.exists=对不起, 您的账号:{0} 不存在.
|
||||||
user.password.not.match=用户不存在/密码错误
|
user.password.not.match=用户不存在/密码错误
|
||||||
user.password.retry.limit.count=密码输入错误{0}次
|
user.password.retry.limit.count=密码输入错误{0}次
|
||||||
user.password.retry.limit.exceed=密码错误次数过多,帐户锁定{0}分钟
|
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||||
user.password.delete=对不起,您的账号:{0} 已被删除
|
user.password.delete=对不起,您的账号:{0} 已被删除
|
||||||
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
||||||
role.blocked=角色已封禁,请联系管理员
|
role.blocked=角色已封禁,请联系管理员
|
||||||
@ -41,5 +41,5 @@ repeat.submit.message=不允许重复提交,请稍候再试
|
|||||||
rate.limiter.message=访问过于频繁,请稍候再试
|
rate.limiter.message=访问过于频繁,请稍候再试
|
||||||
sms.code.not.blank=短信验证码不能为空
|
sms.code.not.blank=短信验证码不能为空
|
||||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
||||||
sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟
|
sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{0}分钟
|
||||||
xcx.code.not.blank=小程序code不能为空
|
xcx.code.not.blank=小程序code不能为空
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<!-- 控制台输出 -->
|
<!-- 控制台输出 -->
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
|
<encoder>
|
||||||
<pattern>${console.log.pattern}</pattern>
|
<pattern>${console.log.pattern}</pattern>
|
||||||
<charset>utf-8</charset>
|
<charset>utf-8</charset>
|
||||||
</encoder>
|
</encoder>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<!-- 日志最大 1天 -->
|
<!-- 日志最大 1天 -->
|
||||||
<maxHistory>1</maxHistory>
|
<maxHistory>1</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
<charset>utf-8</charset>
|
<charset>utf-8</charset>
|
||||||
</encoder>
|
</encoder>
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<!-- 日志最大的历史 60天 -->
|
<!-- 日志最大的历史 60天 -->
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<!-- 日志最大的历史 60天 -->
|
<!-- 日志最大的历史 60天 -->
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
@ -78,7 +78,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- info异步输出 -->
|
<!-- info异步输出 -->
|
||||||
<appender name="async_info" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
|
<appender name="async_info" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
||||||
<discardingThreshold>0</discardingThreshold>
|
<discardingThreshold>0</discardingThreshold>
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||||
@ -88,7 +88,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- error异步输出 -->
|
<!-- error异步输出 -->
|
||||||
<appender name="async_error" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
|
<appender name="async_error" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
||||||
<discardingThreshold>0</discardingThreshold>
|
<discardingThreshold>0</discardingThreshold>
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||||
@ -97,12 +97,33 @@
|
|||||||
<appender-ref ref="file_error"/>
|
<appender-ref ref="file_error"/>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!-- 整合 skywalking 控制台输出 tid -->
|
||||||
|
<!-- <appender name="console" class="ch.qos.logback.core.ConsoleAppender">-->
|
||||||
|
<!-- <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
|
||||||
|
<!-- <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">-->
|
||||||
|
<!-- <pattern>[%tid] ${console.log.pattern}</pattern>-->
|
||||||
|
<!-- </layout>-->
|
||||||
|
<!-- <charset>utf-8</charset>-->
|
||||||
|
<!-- </encoder>-->
|
||||||
|
<!-- </appender>-->
|
||||||
|
|
||||||
|
<!-- 整合 skywalking 推送采集日志 -->
|
||||||
|
<!-- <appender name="sky_log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">-->
|
||||||
|
<!-- <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
|
||||||
|
<!-- <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">-->
|
||||||
|
<!-- <pattern>[%tid] ${console.log.pattern}</pattern>-->
|
||||||
|
<!-- </layout>-->
|
||||||
|
<!-- <charset>utf-8</charset>-->
|
||||||
|
<!-- </encoder>-->
|
||||||
|
<!-- </appender>-->
|
||||||
|
|
||||||
<!--系统操作日志-->
|
<!--系统操作日志-->
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="console" />
|
<appender-ref ref="console" />
|
||||||
<appender-ref ref="async_info" />
|
<appender-ref ref="async_info" />
|
||||||
<appender-ref ref="async_error" />
|
<appender-ref ref="async_error" />
|
||||||
<appender-ref ref="file_console" />
|
<appender-ref ref="file_console" />
|
||||||
|
<!-- <appender-ref ref="sky_log"/>-->
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -14,6 +14,8 @@ useprefix=true
|
|||||||
excludecategories=info,debug,result,commit,resultset
|
excludecategories=info,debug,result,commit,resultset
|
||||||
# 日期格式
|
# 日期格式
|
||||||
dateformat=yyyy-MM-dd HH:mm:ss
|
dateformat=yyyy-MM-dd HH:mm:ss
|
||||||
|
# SQL语句打印时间格式
|
||||||
|
databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss
|
||||||
# 实际驱动可多个
|
# 实际驱动可多个
|
||||||
#driverlist=org.h2.Driver
|
#driverlist=org.h2.Driver
|
||||||
# 是否开启慢SQL记录
|
# 是否开启慢SQL记录
|
||||||
@ -22,3 +24,5 @@ outagedetection=true
|
|||||||
outagedetectioninterval=2
|
outagedetectioninterval=2
|
||||||
# 是否过滤 Log
|
# 是否过滤 Log
|
||||||
filter=true
|
filter=true
|
||||||
|
# 过滤 Log 时所排除的 sql 关键字,以逗号分隔
|
||||||
|
exclude=SELECT 1
|
||||||
|
45
ruoyi-admin/src/test/java/com/ruoyi/test/AssertUnitTest.java
Normal file
45
ruoyi-admin/src/test/java/com/ruoyi/test/AssertUnitTest.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package com.ruoyi.test;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 断言单元测试案例
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@DisplayName("断言单元测试案例")
|
||||||
|
public class AssertUnitTest {
|
||||||
|
|
||||||
|
@DisplayName("测试 assertEquals 方法")
|
||||||
|
@Test
|
||||||
|
public void testAssertEquals() {
|
||||||
|
Assertions.assertEquals("666", new String("666"));
|
||||||
|
Assertions.assertNotEquals("666", new String("666"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("测试 assertSame 方法")
|
||||||
|
@Test
|
||||||
|
public void testAssertSame() {
|
||||||
|
Object obj = new Object();
|
||||||
|
Object obj1 = obj;
|
||||||
|
Assertions.assertSame(obj, obj1);
|
||||||
|
Assertions.assertNotSame(obj, obj1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("测试 assertTrue 方法")
|
||||||
|
@Test
|
||||||
|
public void testAssertTrue() {
|
||||||
|
Assertions.assertTrue(true);
|
||||||
|
Assertions.assertFalse(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("测试 assertNull 方法")
|
||||||
|
@Test
|
||||||
|
public void testAssertNull() {
|
||||||
|
Assertions.assertNull(null);
|
||||||
|
Assertions.assertNotNull(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
70
ruoyi-admin/src/test/java/com/ruoyi/test/DemoUnitTest.java
Normal file
70
ruoyi-admin/src/test/java/com/ruoyi/test/DemoUnitTest.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package com.ruoyi.test;
|
||||||
|
|
||||||
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单元测试案例
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
|
||||||
|
@DisplayName("单元测试案例")
|
||||||
|
public class DemoUnitTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuoYiConfig ruoYiConfig;
|
||||||
|
|
||||||
|
@DisplayName("测试 @SpringBootTest @Test @DisplayName 注解")
|
||||||
|
@Test
|
||||||
|
public void testTest() {
|
||||||
|
System.out.println(ruoYiConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Disabled
|
||||||
|
@DisplayName("测试 @Disabled 注解")
|
||||||
|
@Test
|
||||||
|
public void testDisabled() {
|
||||||
|
System.out.println(ruoYiConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Timeout(value = 2L, unit = TimeUnit.SECONDS)
|
||||||
|
@DisplayName("测试 @Timeout 注解")
|
||||||
|
@Test
|
||||||
|
public void testTimeout() throws InterruptedException {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
System.out.println(ruoYiConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DisplayName("测试 @RepeatedTest 注解")
|
||||||
|
@RepeatedTest(3)
|
||||||
|
public void testRepeatedTest() {
|
||||||
|
System.out.println(666);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void testBeforeAll() {
|
||||||
|
System.out.println("@BeforeAll ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void testBeforeEach() {
|
||||||
|
System.out.println("@BeforeEach ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void testAfterEach() {
|
||||||
|
System.out.println("@AfterEach ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void testAfterAll() {
|
||||||
|
System.out.println("@AfterAll ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
ruoyi-admin/src/test/java/com/ruoyi/test/ParamUnitTest.java
Normal file
72
ruoyi-admin/src/test/java/com/ruoyi/test/ParamUnitTest.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package com.ruoyi.test;
|
||||||
|
|
||||||
|
import com.ruoyi.common.enums.UserType;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.EnumSource;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import org.junit.jupiter.params.provider.NullSource;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带参数单元测试案例
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@DisplayName("带参数单元测试案例")
|
||||||
|
public class ParamUnitTest {
|
||||||
|
|
||||||
|
@DisplayName("测试 @ValueSource 注解")
|
||||||
|
@ParameterizedTest
|
||||||
|
@ValueSource(strings = {"t1", "t2", "t3"})
|
||||||
|
public void testValueSource(String str) {
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("测试 @NullSource 注解")
|
||||||
|
@ParameterizedTest
|
||||||
|
@NullSource
|
||||||
|
public void testNullSource(String str) {
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("测试 @EnumSource 注解")
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(UserType.class)
|
||||||
|
public void testEnumSource(UserType type) {
|
||||||
|
System.out.println(type.getUserType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("测试 @MethodSource 注解")
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("getParam")
|
||||||
|
public void testMethodSource(String str) {
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<String> getParam() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add("t1");
|
||||||
|
list.add("t2");
|
||||||
|
list.add("t3");
|
||||||
|
return list.stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void testBeforeEach() {
|
||||||
|
System.out.println("@BeforeEach ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void testAfterEach() {
|
||||||
|
System.out.println("@AfterEach ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
54
ruoyi-admin/src/test/java/com/ruoyi/test/TagUnitTest.java
Normal file
54
ruoyi-admin/src/test/java/com/ruoyi/test/TagUnitTest.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package com.ruoyi.test;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签单元测试案例
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@SpringBootTest
|
||||||
|
@DisplayName("标签单元测试案例")
|
||||||
|
public class TagUnitTest {
|
||||||
|
|
||||||
|
@Tag("dev")
|
||||||
|
@DisplayName("测试 @Tag dev")
|
||||||
|
@Test
|
||||||
|
public void testTagDev() {
|
||||||
|
System.out.println("dev");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Tag("prod")
|
||||||
|
@DisplayName("测试 @Tag prod")
|
||||||
|
@Test
|
||||||
|
public void testTagProd() {
|
||||||
|
System.out.println("prod");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Tag("local")
|
||||||
|
@DisplayName("测试 @Tag local")
|
||||||
|
@Test
|
||||||
|
public void testTagLocal() {
|
||||||
|
System.out.println("local");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Tag("exclude")
|
||||||
|
@DisplayName("测试 @Tag exclude")
|
||||||
|
@Test
|
||||||
|
public void testTagExclude() {
|
||||||
|
System.out.println("exclude");
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void testBeforeEach() {
|
||||||
|
System.out.println("@BeforeEach ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void testAfterEach() {
|
||||||
|
System.out.println("@AfterEach ==================");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.2.0</version>
|
<version>4.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -126,13 +126,13 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
<artifactId>springdoc-openapi-webmvc-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>springdoc-openapi-javadoc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 自动生成YML配置关联JSON文件 -->
|
<!-- 自动生成YML配置关联JSON文件 -->
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 匿名访问不鉴权注解
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface Anonymous {
|
|
||||||
}
|
|
@ -5,6 +5,8 @@ import java.lang.annotation.*;
|
|||||||
/**
|
/**
|
||||||
* 数据权限
|
* 数据权限
|
||||||
*
|
*
|
||||||
|
* 一个注解只能对应一个模板
|
||||||
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @version 3.5.0
|
* @version 3.5.0
|
||||||
*/
|
*/
|
||||||
@ -16,11 +18,11 @@ public @interface DataColumn {
|
|||||||
/**
|
/**
|
||||||
* 占位符关键字
|
* 占位符关键字
|
||||||
*/
|
*/
|
||||||
String key() default "deptName";
|
String[] key() default "deptName";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 占位符替换值
|
* 占位符替换值
|
||||||
*/
|
*/
|
||||||
String value() default "dept_id";
|
String[] value() default "dept_id";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.ruoyi.common.jackson.DictDataJsonSerializer;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据映射注解
|
||||||
|
*
|
||||||
|
* @author itino
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.FIELD, ElementType.METHOD})
|
||||||
|
@JacksonAnnotationsInside
|
||||||
|
@JsonSerialize(using = DictDataJsonSerializer.class)
|
||||||
|
public @interface DictDataMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置字典的type值 (如: sys_user_sex)
|
||||||
|
*/
|
||||||
|
String dictType() default "";
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.common.annotation;
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.enums.LimitType;
|
import com.ruoyi.common.enums.LimitType;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
@ -17,7 +17,7 @@ public @interface RateLimiter {
|
|||||||
/**
|
/**
|
||||||
* 限流key
|
* 限流key
|
||||||
*/
|
*/
|
||||||
String key() default Constants.RATE_LIMIT_KEY;
|
String key() default CacheConstants.RATE_LIMIT_KEY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 限流时间,单位秒
|
* 限流时间,单位秒
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存的key 常量
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public interface CacheConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录用户 redis key
|
||||||
|
*/
|
||||||
|
String LOGIN_TOKEN_KEY = "Authorization:login:token:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线用户 redis key
|
||||||
|
*/
|
||||||
|
String ONLINE_TOKEN_KEY = "online_tokens:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码 redis key
|
||||||
|
*/
|
||||||
|
String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数管理 cache key
|
||||||
|
*/
|
||||||
|
String SYS_CONFIG_KEY = "sys_config:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典管理 cache key
|
||||||
|
*/
|
||||||
|
String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 防重提交 redis key
|
||||||
|
*/
|
||||||
|
String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流 redis key
|
||||||
|
*/
|
||||||
|
String RATE_LIMIT_KEY = "rate_limit:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录账户密码错误次数 redis key
|
||||||
|
*/
|
||||||
|
String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存组名称常量
|
||||||
|
* <p>
|
||||||
|
* key 格式为 cacheNames#ttl#maxIdleTime#maxSize
|
||||||
|
* <p>
|
||||||
|
* ttl 过期时间 如果设置为0则不过期 默认为0
|
||||||
|
* maxIdleTime 最大空闲时间 根据LRU算法清理空闲数据 如果设置为0则不检测 默认为0
|
||||||
|
* maxSize 组最大长度 根据LRU算法清理溢出数据 如果设置为0则无限长 默认为0
|
||||||
|
* <p>
|
||||||
|
* 例子: test#60s、test#0#60s、test#0#1m#1000、test#1h#0#500
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface CacheNames {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 演示案例
|
||||||
|
*/
|
||||||
|
String DEMO_CACHE = "demo:cache#60s#10m#20";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置
|
||||||
|
*/
|
||||||
|
String SYS_CONFIG = "sys_config";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据字典
|
||||||
|
*/
|
||||||
|
String SYS_DICT = "sys_dict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OSS内容
|
||||||
|
*/
|
||||||
|
String SYS_OSS = "sys_oss#30d";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OSS配置
|
||||||
|
*/
|
||||||
|
String SYS_OSS_CONFIG = "sys_oss_config";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线用户
|
||||||
|
*/
|
||||||
|
String ONLINE_TOKEN = "online_tokens";
|
||||||
|
|
||||||
|
}
|
@ -17,6 +17,11 @@ public interface Constants {
|
|||||||
*/
|
*/
|
||||||
String GBK = "GBK";
|
String GBK = "GBK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* www主域
|
||||||
|
*/
|
||||||
|
String WWW = "www.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http请求
|
* http请求
|
||||||
*/
|
*/
|
||||||
@ -57,70 +62,15 @@ public interface Constants {
|
|||||||
*/
|
*/
|
||||||
String LOGIN_FAIL = "Error";
|
String LOGIN_FAIL = "Error";
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码 redis key
|
|
||||||
*/
|
|
||||||
String CAPTCHA_CODE_KEY = "captcha_codes:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户 redis key
|
|
||||||
*/
|
|
||||||
String LOGIN_TOKEN_KEY = "Authorization:login:token:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线用户 redis key
|
|
||||||
*/
|
|
||||||
String ONLINE_TOKEN_KEY = "online_tokens:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 防重提交 redis key
|
|
||||||
*/
|
|
||||||
String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流 redis key
|
|
||||||
*/
|
|
||||||
String RATE_LIMIT_KEY = "rate_limit:";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码有效期(分钟)
|
* 验证码有效期(分钟)
|
||||||
*/
|
*/
|
||||||
Integer CAPTCHA_EXPIRATION = 2;
|
Integer CAPTCHA_EXPIRATION = 2;
|
||||||
|
|
||||||
/**
|
|
||||||
* 登陆错误 redis key
|
|
||||||
*/
|
|
||||||
String LOGIN_ERROR = "login_error:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录错误次数
|
|
||||||
*/
|
|
||||||
Integer LOGIN_ERROR_NUMBER = 5;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录错误限制时间(分钟)
|
|
||||||
*/
|
|
||||||
Integer LOGIN_ERROR_LIMIT_TIME = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌
|
* 令牌
|
||||||
*/
|
*/
|
||||||
String TOKEN = "token";
|
String TOKEN = "token";
|
||||||
|
|
||||||
/**
|
|
||||||
* 令牌前缀
|
|
||||||
*/
|
|
||||||
String LOGIN_USER_KEY = "login_user_key";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数管理 cache key
|
|
||||||
*/
|
|
||||||
String SYS_CONFIG_KEY = "sys_config:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典管理 cache key
|
|
||||||
*/
|
|
||||||
String SYS_DICT_KEY = "sys_dict:";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回状态码
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface HttpStatus {
|
||||||
|
/**
|
||||||
|
* 操作成功
|
||||||
|
*/
|
||||||
|
int SUCCESS = 200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象创建成功
|
||||||
|
*/
|
||||||
|
int CREATED = 201;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求已经被接受
|
||||||
|
*/
|
||||||
|
int ACCEPTED = 202;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作已经执行成功,但是没有返回数据
|
||||||
|
*/
|
||||||
|
int NO_CONTENT = 204;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源已被移除
|
||||||
|
*/
|
||||||
|
int MOVED_PERM = 301;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重定向
|
||||||
|
*/
|
||||||
|
int SEE_OTHER = 303;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源没有被修改
|
||||||
|
*/
|
||||||
|
int NOT_MODIFIED = 304;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数列表错误(缺少,格式不匹配)
|
||||||
|
*/
|
||||||
|
int BAD_REQUEST = 400;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未授权
|
||||||
|
*/
|
||||||
|
int UNAUTHORIZED = 401;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问受限,授权过期
|
||||||
|
*/
|
||||||
|
int FORBIDDEN = 403;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源,服务未找到
|
||||||
|
*/
|
||||||
|
int NOT_FOUND = 404;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许的http方法
|
||||||
|
*/
|
||||||
|
int BAD_METHOD = 405;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源冲突,或者资源被锁
|
||||||
|
*/
|
||||||
|
int CONFLICT = 409;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不支持的数据,媒体类型
|
||||||
|
*/
|
||||||
|
int UNSUPPORTED_TYPE = 415;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统内部错误
|
||||||
|
*/
|
||||||
|
int ERROR = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口未实现
|
||||||
|
*/
|
||||||
|
int NOT_IMPLEMENTED = 501;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统警告消息
|
||||||
|
*/
|
||||||
|
int WARN = 601;
|
||||||
|
}
|
@ -2,7 +2,8 @@ package com.ruoyi.common.core.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -24,42 +25,38 @@ public class BaseEntity implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 搜索值
|
* 搜索值
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "搜索值")
|
@JsonIgnore
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建者")
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新者
|
* 更新者
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "更新者")
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "更新时间")
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求参数
|
* 请求参数
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "请求参数")
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Map<String, Object> params = new HashMap<>();
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询实体类
|
* 分页查询实体类
|
||||||
@ -24,25 +27,21 @@ public class PageQuery implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 分页大小
|
* 分页大小
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("分页大小")
|
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前页数
|
* 当前页数
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("当前页数")
|
|
||||||
private Integer pageNum;
|
private Integer pageNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序列
|
* 排序列
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("排序列")
|
|
||||||
private String orderByColumn;
|
private String orderByColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序的方向desc或者asc
|
* 排序的方向desc或者asc
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
|
||||||
private String isAsc;
|
private String isAsc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,30 +61,52 @@ public class PageQuery implements Serializable {
|
|||||||
pageNum = DEFAULT_PAGE_NUM;
|
pageNum = DEFAULT_PAGE_NUM;
|
||||||
}
|
}
|
||||||
Page<T> page = new Page<>(pageNum, pageSize);
|
Page<T> page = new Page<>(pageNum, pageSize);
|
||||||
OrderItem orderItem = buildOrderItem();
|
List<OrderItem> orderItems = buildOrderItem();
|
||||||
if (ObjectUtil.isNotNull(orderItem)) {
|
if (CollUtil.isNotEmpty(orderItems)) {
|
||||||
page.addOrder(orderItem);
|
page.addOrder(orderItems);
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderItem buildOrderItem() {
|
/**
|
||||||
// 兼容前端排序类型
|
* 构建排序
|
||||||
if ("ascending".equals(isAsc)) {
|
*
|
||||||
isAsc = "asc";
|
* 支持的用法如下:
|
||||||
} else if ("descending".equals(isAsc)) {
|
* {isAsc:"asc",orderByColumn:"id"} order by id asc
|
||||||
isAsc = "desc";
|
* {isAsc:"asc",orderByColumn:"id,createTime"} order by id asc,create_time asc
|
||||||
|
* {isAsc:"desc",orderByColumn:"id,createTime"} order by id desc,create_time desc
|
||||||
|
* {isAsc:"asc,desc",orderByColumn:"id,createTime"} order by id asc,create_time desc
|
||||||
|
*/
|
||||||
|
private List<OrderItem> buildOrderItem() {
|
||||||
|
if (StringUtils.isBlank(orderByColumn) || StringUtils.isBlank(isAsc)) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(orderByColumn)) {
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(orderByColumn);
|
String orderBy = SqlUtil.escapeOrderBySql(orderByColumn);
|
||||||
orderBy = StringUtils.toUnderScoreCase(orderBy);
|
orderBy = StringUtils.toUnderScoreCase(orderBy);
|
||||||
if ("asc".equals(isAsc)) {
|
|
||||||
return OrderItem.asc(orderBy);
|
// 兼容前端排序类型
|
||||||
} else if ("desc".equals(isAsc)) {
|
isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
|
||||||
return OrderItem.desc(orderBy);
|
|
||||||
|
String[] orderByArr = orderBy.split(",");
|
||||||
|
String[] isAscArr = isAsc.split(",");
|
||||||
|
if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
|
||||||
|
throw new ServiceException("排序参数有误");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<OrderItem> list = new ArrayList<>();
|
||||||
|
// 每个字段各自排序
|
||||||
|
for (int i = 0; i < orderByArr.length; i++) {
|
||||||
|
String orderByStr = orderByArr[i];
|
||||||
|
String isAscStr = isAscArr.length == 1 ? isAscArr[0] : isAscArr[i];
|
||||||
|
if ("asc".equals(isAscStr)) {
|
||||||
|
list.add(OrderItem.asc(orderByStr));
|
||||||
|
} else if ("desc".equals(isAscStr)) {
|
||||||
|
list.add(OrderItem.desc(orderByStr));
|
||||||
|
} else {
|
||||||
|
throw new ServiceException("排序参数有误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@ -14,7 +13,6 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ApiModel("请求响应对象")
|
|
||||||
public class R<T> implements Serializable {
|
public class R<T> implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -28,13 +26,10 @@ public class R<T> implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public static final int FAIL = 500;
|
public static final int FAIL = 500;
|
||||||
|
|
||||||
@ApiModelProperty("消息状态码")
|
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
@ApiModelProperty("消息内容")
|
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
@ApiModelProperty("数据对象")
|
|
||||||
private T data;
|
private T data;
|
||||||
|
|
||||||
public static <T> R<T> ok() {
|
public static <T> R<T> ok() {
|
||||||
@ -73,6 +68,27 @@ public class R<T> implements Serializable {
|
|||||||
return restResult(null, code, msg);
|
return restResult(null, code, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static <T> R<T> warn(String msg) {
|
||||||
|
return restResult(null, HttpStatus.WARN, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static <T> R<T> warn(String msg, T data) {
|
||||||
|
return restResult(data, HttpStatus.WARN, msg);
|
||||||
|
}
|
||||||
|
|
||||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
private static <T> R<T> restResult(T data, int code, String msg) {
|
||||||
R<T> r = new R<>();
|
R<T> r = new R<>();
|
||||||
r.setCode(code);
|
r.setCode(code);
|
||||||
@ -81,4 +97,11 @@ public class R<T> implements Serializable {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> Boolean isError(R<T> ret) {
|
||||||
|
return !isSuccess(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Boolean isSuccess(R<T> ret) {
|
||||||
|
return R.SUCCESS == ret.getCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -24,20 +23,17 @@ public class TreeEntity<T> extends BaseEntity {
|
|||||||
* 父菜单名称
|
* 父菜单名称
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "父菜单名称")
|
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父菜单ID
|
* 父菜单ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "父菜单ID")
|
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子部门
|
* 子部门
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "子部门")
|
|
||||||
private List<T> children = new ArrayList<>();
|
private List<T> children = new ArrayList<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.ruoyi.common.core.domain.TreeEntity;
|
import com.ruoyi.common.core.domain.TreeEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -23,21 +21,18 @@ import javax.validation.constraints.Size;
|
|||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("sys_dept")
|
@TableName("sys_dept")
|
||||||
@ApiModel("部门业务对象")
|
|
||||||
public class SysDept extends TreeEntity<SysDept> {
|
public class SysDept extends TreeEntity<SysDept> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门id")
|
|
||||||
@TableId(value = "dept_id")
|
@TableId(value = "dept_id")
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门名称")
|
|
||||||
@NotBlank(message = "部门名称不能为空")
|
@NotBlank(message = "部门名称不能为空")
|
||||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
@ -45,27 +40,23 @@ public class SysDept extends TreeEntity<SysDept> {
|
|||||||
/**
|
/**
|
||||||
* 显示顺序
|
* 显示顺序
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "显示顺序")
|
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotNull(message = "显示顺序不能为空")
|
||||||
private Integer orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 负责人
|
* 负责人
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "负责人")
|
|
||||||
private String leader;
|
private String leader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "联系电话")
|
|
||||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱
|
* 邮箱
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "邮箱")
|
|
||||||
@Email(message = "邮箱格式不正确")
|
@Email(message = "邮箱格式不正确")
|
||||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||||
private String email;
|
private String email;
|
||||||
@ -73,20 +64,17 @@ public class SysDept extends TreeEntity<SysDept> {
|
|||||||
/**
|
/**
|
||||||
* 部门状态:0正常,1停用
|
* 部门状态:0正常,1停用
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门状态:0正常,1停用")
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 2代表删除)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 祖级列表
|
* 祖级列表
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "祖级列表")
|
|
||||||
private String ancestors;
|
private String ancestors;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import com.ruoyi.common.annotation.ExcelDictFormat;
|
|||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -26,13 +24,11 @@ import javax.validation.constraints.Size;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("sys_dict_data")
|
@TableName("sys_dict_data")
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@ApiModel("字典数据业务对象")
|
|
||||||
public class SysDictData extends BaseEntity {
|
public class SysDictData extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典编码
|
* 字典编码
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典编码")
|
|
||||||
@ExcelProperty(value = "字典编码")
|
@ExcelProperty(value = "字典编码")
|
||||||
@TableId(value = "dict_code")
|
@TableId(value = "dict_code")
|
||||||
private Long dictCode;
|
private Long dictCode;
|
||||||
@ -40,14 +36,12 @@ public class SysDictData extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 字典排序
|
* 字典排序
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典排序")
|
|
||||||
@ExcelProperty(value = "字典排序")
|
@ExcelProperty(value = "字典排序")
|
||||||
private Integer dictSort;
|
private Integer dictSort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典标签
|
* 字典标签
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典标签")
|
|
||||||
@ExcelProperty(value = "字典标签")
|
@ExcelProperty(value = "字典标签")
|
||||||
@NotBlank(message = "字典标签不能为空")
|
@NotBlank(message = "字典标签不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||||
@ -56,7 +50,6 @@ public class SysDictData extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 字典键值
|
* 字典键值
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典键值")
|
|
||||||
@ExcelProperty(value = "字典键值")
|
@ExcelProperty(value = "字典键值")
|
||||||
@NotBlank(message = "字典键值不能为空")
|
@NotBlank(message = "字典键值不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||||
@ -65,7 +58,6 @@ public class SysDictData extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典类型")
|
|
||||||
@ExcelProperty(value = "字典类型")
|
@ExcelProperty(value = "字典类型")
|
||||||
@NotBlank(message = "字典类型不能为空")
|
@NotBlank(message = "字典类型不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||||
@ -74,20 +66,17 @@ public class SysDictData extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 样式属性(其他样式扩展)
|
* 样式属性(其他样式扩展)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "样式属性(其他样式扩展)")
|
|
||||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||||
private String cssClass;
|
private String cssClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格字典样式
|
* 表格字典样式
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "表格字典样式")
|
|
||||||
private String listClass;
|
private String listClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否默认(Y是 N否)
|
* 是否默认(Y是 N否)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "是否默认(Y是 N否)")
|
|
||||||
@ExcelProperty(value = "是否默认", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "是否默认", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(dictType = "sys_yes_no")
|
@ExcelDictFormat(dictType = "sys_yes_no")
|
||||||
private String isDefault;
|
private String isDefault;
|
||||||
@ -95,7 +84,6 @@ public class SysDictData extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 状态(0正常 1停用)
|
* 状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "状态(0正常 1停用)")
|
|
||||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(dictType = "sys_normal_disable")
|
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||||
private String status;
|
private String status;
|
||||||
@ -103,7 +91,6 @@ public class SysDictData extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
public boolean getDefault() {
|
public boolean getDefault() {
|
||||||
|
@ -7,11 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
@ -27,13 +24,11 @@ import javax.validation.constraints.Size;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("sys_dict_type")
|
@TableName("sys_dict_type")
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@ApiModel("字典类型业务对象")
|
|
||||||
public class SysDictType extends BaseEntity {
|
public class SysDictType extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典主键
|
* 字典主键
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典主键")
|
|
||||||
@ExcelProperty(value = "字典主键")
|
@ExcelProperty(value = "字典主键")
|
||||||
@TableId(value = "dict_id")
|
@TableId(value = "dict_id")
|
||||||
private Long dictId;
|
private Long dictId;
|
||||||
@ -41,7 +36,6 @@ public class SysDictType extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 字典名称
|
* 字典名称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典名称")
|
|
||||||
@ExcelProperty(value = "字典名称")
|
@ExcelProperty(value = "字典名称")
|
||||||
@NotBlank(message = "字典名称不能为空")
|
@NotBlank(message = "字典名称不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||||
@ -50,7 +44,6 @@ public class SysDictType extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典类型")
|
|
||||||
@ExcelProperty(value = "字典类型")
|
@ExcelProperty(value = "字典类型")
|
||||||
@NotBlank(message = "字典类型不能为空")
|
@NotBlank(message = "字典类型不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||||
@ -60,7 +53,6 @@ public class SysDictType extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 状态(0正常 1停用)
|
* 状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "状态(0正常 1停用)")
|
|
||||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(dictType = "sys_normal_disable")
|
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||||
private String status;
|
private String status;
|
||||||
@ -68,7 +60,6 @@ public class SysDictType extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.ruoyi.common.core.domain.TreeEntity;
|
import com.ruoyi.common.core.domain.TreeEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -22,20 +20,17 @@ import javax.validation.constraints.Size;
|
|||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("sys_menu")
|
@TableName("sys_menu")
|
||||||
@ApiModel("菜单权限业务对象")
|
|
||||||
public class SysMenu extends TreeEntity<SysMenu> {
|
public class SysMenu extends TreeEntity<SysMenu> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单ID
|
* 菜单ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单ID")
|
|
||||||
@TableId(value = "menu_id")
|
@TableId(value = "menu_id")
|
||||||
private Long menuId;
|
private Long menuId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单名称
|
* 菜单名称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单名称")
|
|
||||||
@NotBlank(message = "菜单名称不能为空")
|
@NotBlank(message = "菜单名称不能为空")
|
||||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||||
private String menuName;
|
private String menuName;
|
||||||
@ -43,65 +38,55 @@ public class SysMenu extends TreeEntity<SysMenu> {
|
|||||||
/**
|
/**
|
||||||
* 显示顺序
|
* 显示顺序
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "显示顺序")
|
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotNull(message = "显示顺序不能为空")
|
||||||
private Integer orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由地址
|
* 路由地址
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "路由地址")
|
|
||||||
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件路径
|
* 组件路径
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "组件路径")
|
|
||||||
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
||||||
private String component;
|
private String component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由参数
|
* 路由参数
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "路由参数")
|
|
||||||
private String queryParam;
|
private String queryParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为外链(0是 1否)
|
* 是否为外链(0是 1否)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "是否为外链(0是 1否)")
|
|
||||||
private String isFrame;
|
private String isFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否缓存(0缓存 1不缓存)
|
* 是否缓存(0缓存 1不缓存)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "是否缓存(0缓存 1不缓存)")
|
|
||||||
private String isCache;
|
private String isCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型(M目录 C菜单 F按钮)
|
* 类型(M目录 C菜单 F按钮)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "类型(M目录 C菜单 F按钮)")
|
|
||||||
@NotBlank(message = "菜单类型不能为空")
|
@NotBlank(message = "菜单类型不能为空")
|
||||||
private String menuType;
|
private String menuType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示状态(0显示 1隐藏)
|
* 显示状态(0显示 1隐藏)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "显示状态(0显示 1隐藏)")
|
|
||||||
private String visible;
|
private String visible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单状态(0显示 1隐藏)
|
* 菜单状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单状态(0显示 1隐藏)")
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限字符串
|
* 权限字符串
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "权限字符串")
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||||
private String perms;
|
private String perms;
|
||||||
@ -109,13 +94,11 @@ public class SysMenu extends TreeEntity<SysMenu> {
|
|||||||
/**
|
/**
|
||||||
* 菜单图标
|
* 菜单图标
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单图标")
|
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import com.ruoyi.common.annotation.ExcelDictFormat;
|
|||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -18,6 +17,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色表 sys_role
|
* 角色表 sys_role
|
||||||
@ -35,7 +35,6 @@ public class SysRole extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色ID")
|
|
||||||
@ExcelProperty(value = "角色序号")
|
@ExcelProperty(value = "角色序号")
|
||||||
@TableId(value = "role_id")
|
@TableId(value = "role_id")
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
@ -43,7 +42,6 @@ public class SysRole extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 角色名称
|
* 角色名称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色名称")
|
|
||||||
@ExcelProperty(value = "角色名称")
|
@ExcelProperty(value = "角色名称")
|
||||||
@NotBlank(message = "角色名称不能为空")
|
@NotBlank(message = "角色名称不能为空")
|
||||||
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
||||||
@ -52,7 +50,6 @@ public class SysRole extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色权限")
|
|
||||||
@ExcelProperty(value = "角色权限")
|
@ExcelProperty(value = "角色权限")
|
||||||
@NotBlank(message = "权限字符不能为空")
|
@NotBlank(message = "权限字符不能为空")
|
||||||
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
||||||
@ -61,7 +58,6 @@ public class SysRole extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 角色排序
|
* 角色排序
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色排序")
|
|
||||||
@ExcelProperty(value = "角色排序")
|
@ExcelProperty(value = "角色排序")
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotNull(message = "显示顺序不能为空")
|
||||||
private Integer roleSort;
|
private Integer roleSort;
|
||||||
@ -69,7 +65,6 @@ public class SysRole extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)")
|
|
||||||
@ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
@ExcelDictFormat(readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
||||||
private String dataScope;
|
private String dataScope;
|
||||||
@ -77,62 +72,59 @@ public class SysRole extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)")
|
|
||||||
private Boolean menuCheckStrictly;
|
private Boolean menuCheckStrictly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )")
|
|
||||||
private Boolean deptCheckStrictly;
|
private Boolean deptCheckStrictly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色状态(0正常 1停用)
|
* 角色状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色状态(0正常 1停用)")
|
|
||||||
@ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class)
|
@ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class)
|
||||||
@ExcelDictFormat(dictType = "sys_common_status")
|
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 2代表删除)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户是否存在此角色标识 默认不存在
|
* 用户是否存在此角色标识 默认不存在
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户是否存在此角色标识 默认不存在")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private boolean flag = false;
|
private boolean flag = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单组
|
* 菜单组
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单组")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long[] menuIds;
|
private Long[] menuIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门组(数据权限)
|
* 部门组(数据权限)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门组(数据权限)")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long[] deptIds;
|
private Long[] deptIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色菜单权限
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Set<String> permissions;
|
||||||
|
|
||||||
public SysRole(Long roleId) {
|
public SysRole(Long roleId) {
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否管理员")
|
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
return UserConstants.ADMIN_ID.equals(this.roleId);
|
return UserConstants.ADMIN_ID.equals(this.roleId);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package com.ruoyi.common.core.domain.entity;
|
package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.ruoyi.common.annotation.Sensitive;
|
import com.ruoyi.common.annotation.Sensitive;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
import com.ruoyi.common.enums.SensitiveStrategy;
|
||||||
import com.ruoyi.common.xss.Xss;
|
import com.ruoyi.common.xss.Xss;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -30,26 +26,22 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("sys_user")
|
@TableName("sys_user")
|
||||||
@ApiModel("用户信息业务对象")
|
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户ID")
|
|
||||||
@TableId(value = "user_id")
|
@TableId(value = "user_id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门ID")
|
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账号
|
* 用户账号
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户账号")
|
|
||||||
@Xss(message = "用户账号不能包含脚本字符")
|
@Xss(message = "用户账号不能包含脚本字符")
|
||||||
@NotBlank(message = "用户账号不能为空")
|
@NotBlank(message = "用户账号不能为空")
|
||||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||||
@ -58,7 +50,6 @@ public class SysUser extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 用户昵称
|
* 用户昵称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户昵称")
|
|
||||||
@Xss(message = "用户昵称不能包含脚本字符")
|
@Xss(message = "用户昵称不能包含脚本字符")
|
||||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
@ -66,14 +57,12 @@ public class SysUser extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 用户类型(sys_user系统用户)
|
* 用户类型(sys_user系统用户)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户类型")
|
|
||||||
private String userType;
|
private String userType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户邮箱
|
* 用户邮箱
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.EMAIL)
|
@Sensitive(strategy = SensitiveStrategy.EMAIL)
|
||||||
@ApiModelProperty(value = "用户邮箱")
|
|
||||||
@Email(message = "邮箱格式不正确")
|
@Email(message = "邮箱格式不正确")
|
||||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||||
private String email;
|
private String email;
|
||||||
@ -82,25 +71,21 @@ public class SysUser extends BaseEntity {
|
|||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.PHONE)
|
@Sensitive(strategy = SensitiveStrategy.PHONE)
|
||||||
@ApiModelProperty(value = "手机号码")
|
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户性别
|
* 用户性别
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户性别")
|
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户头像
|
* 用户头像
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户头像")
|
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码
|
* 密码
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "密码")
|
|
||||||
@TableField(
|
@TableField(
|
||||||
insertStrategy = FieldStrategy.NOT_EMPTY,
|
insertStrategy = FieldStrategy.NOT_EMPTY,
|
||||||
updateStrategy = FieldStrategy.NOT_EMPTY,
|
updateStrategy = FieldStrategy.NOT_EMPTY,
|
||||||
@ -111,66 +96,56 @@ public class SysUser extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 帐号状态(0正常 1停用)
|
* 帐号状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "帐号状态(0正常 1停用)")
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 2代表删除)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后登录IP
|
* 最后登录IP
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "最后登录IP")
|
|
||||||
private String loginIp;
|
private String loginIp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后登录时间
|
* 最后登录时间
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "最后登录时间")
|
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "备注")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门对象
|
* 部门对象
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门对象")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private SysDept dept;
|
private SysDept dept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色对象
|
* 角色对象
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色对象")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<SysRole> roles;
|
private List<SysRole> roles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色组
|
* 角色组
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色组")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long[] roleIds;
|
private Long[] roleIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位组
|
* 岗位组
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "岗位组")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long[] postIds;
|
private Long[] postIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限 当前角色ID
|
* 数据权限 当前角色ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色ID")
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
@ -178,7 +153,6 @@ public class SysUser extends BaseEntity {
|
|||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否管理员")
|
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
return UserConstants.ADMIN_ID.equals(this.userId);
|
return UserConstants.ADMIN_ID.equals(this.userId);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
@ -15,7 +13,6 @@ import javax.validation.constraints.NotBlank;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel("用户登录对象")
|
|
||||||
public class LoginBody {
|
public class LoginBody {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +20,6 @@ public class LoginBody {
|
|||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.username.not.blank}")
|
@NotBlank(message = "{user.username.not.blank}")
|
||||||
@Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "{user.username.length.valid}")
|
@Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "{user.username.length.valid}")
|
||||||
@ApiModelProperty(value = "用户名")
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,19 +27,16 @@ public class LoginBody {
|
|||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.password.not.blank}")
|
@NotBlank(message = "{user.password.not.blank}")
|
||||||
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
||||||
@ApiModelProperty(value = "用户密码")
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码
|
* 验证码
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "验证码")
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 唯一标识
|
* 唯一标识
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "唯一标识")
|
|
||||||
private String uuid;
|
private String uuid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,12 @@ public class LoginUser implements Serializable {
|
|||||||
* 获取登录id
|
* 获取登录id
|
||||||
*/
|
*/
|
||||||
public String getLoginId() {
|
public String getLoginId() {
|
||||||
|
if (userType == null) {
|
||||||
|
throw new IllegalArgumentException("用户类型不能为空");
|
||||||
|
}
|
||||||
|
if (userId == null) {
|
||||||
|
throw new IllegalArgumentException("用户ID不能为空");
|
||||||
|
}
|
||||||
return userType + LoginHelper.JOIN_CODE + userId;
|
return userType + LoginHelper.JOIN_CODE + userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -12,10 +10,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel("用户注册对象")
|
|
||||||
public class RegisterBody extends LoginBody {
|
public class RegisterBody extends LoginBody {
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户类型")
|
|
||||||
private String userType;
|
private String userType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
@ -13,21 +11,18 @@ import javax.validation.constraints.NotBlank;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel("短信登录对象")
|
|
||||||
public class SmsLoginBody {
|
public class SmsLoginBody {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
@NotBlank(message = "{user.phonenumber.not.blank}")
|
||||||
@ApiModelProperty(value = "用户手机号")
|
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户密码
|
* 用户密码
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "{sms.code.not.blank}")
|
@NotBlank(message = "{sms.code.not.blank}")
|
||||||
@ApiModelProperty(value = "短信验证码")
|
|
||||||
private String smsCode;
|
private String smsCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
|
|||||||
return BeanCopyUtils.copy(obj, voClass);
|
return BeanCopyUtils.copy(obj, voClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<V> selectVoById(Collection<? extends Serializable> idList) {
|
default List<V> selectVoBatchIds(Collection<? extends Serializable> idList) {
|
||||||
return selectVoBatchIds(idList, this.currentVoClass());
|
return selectVoBatchIds(idList, this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,8 @@ package com.ruoyi.common.core.page;
|
|||||||
|
|
||||||
import cn.hutool.http.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,32 +16,27 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ApiModel("分页响应对象")
|
|
||||||
public class TableDataInfo<T> implements Serializable {
|
public class TableDataInfo<T> implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 总记录数
|
* 总记录数
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("总记录数")
|
|
||||||
private long total;
|
private long total;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表数据
|
* 列表数据
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("列表数据")
|
|
||||||
private List<T> rows;
|
private List<T> rows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息状态码
|
* 消息状态码
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("消息状态码")
|
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息内容
|
* 消息内容
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("消息内容")
|
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ import com.alibaba.excel.event.AnalysisEventListener;
|
|||||||
import com.alibaba.excel.exception.ExcelAnalysisException;
|
import com.alibaba.excel.exception.ExcelAnalysisException;
|
||||||
import com.alibaba.excel.exception.ExcelDataConvertException;
|
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||||
import com.ruoyi.common.utils.JsonUtils;
|
import com.ruoyi.common.utils.JsonUtils;
|
||||||
|
import com.ruoyi.common.utils.StreamUtils;
|
||||||
import com.ruoyi.common.utils.ValidatorUtils;
|
import com.ruoyi.common.utils.ValidatorUtils;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -14,7 +15,6 @@ import javax.validation.ConstraintViolation;
|
|||||||
import javax.validation.ConstraintViolationException;
|
import javax.validation.ConstraintViolationException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel 导入监听
|
* Excel 导入监听
|
||||||
@ -69,9 +69,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
|
|||||||
if (exception instanceof ConstraintViolationException) {
|
if (exception instanceof ConstraintViolationException) {
|
||||||
ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
|
ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
|
||||||
Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
|
Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
|
||||||
String constraintViolationsMsg = constraintViolations.stream()
|
String constraintViolationsMsg = StreamUtils.join(constraintViolations, ConstraintViolation::getMessage, ", ");
|
||||||
.map(ConstraintViolation::getMessage)
|
|
||||||
.collect(Collectors.joining(", "));
|
|
||||||
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
|
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.error(errMsg);
|
log.error(errMsg);
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户错误最大次数异常类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class UserPasswordRetryLimitExceedException extends UserException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime) {
|
||||||
|
super("user.password.retry.limit.exceed", retryLimitCount, lockTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.common.filter;
|
package com.ruoyi.common.filter;
|
||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
|
||||||
import javax.servlet.ReadListener;
|
import javax.servlet.ReadListener;
|
||||||
import javax.servlet.ServletInputStream;
|
import javax.servlet.ServletInputStream;
|
||||||
@ -11,7 +12,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建可重复读取inputStream的request
|
* 构建可重复读取inputStream的request
|
||||||
@ -23,10 +23,10 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
|
|||||||
|
|
||||||
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
|
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
|
||||||
super(request);
|
super(request);
|
||||||
request.setCharacterEncoding("UTF-8");
|
request.setCharacterEncoding(Constants.UTF8);
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding(Constants.UTF8);
|
||||||
|
|
||||||
body = IoUtil.readUtf8(request.getInputStream()).getBytes(StandardCharsets.UTF_8);
|
body = IoUtil.readBytes(request.getInputStream(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.common.filter;
|
package com.ruoyi.common.filter;
|
||||||
|
|
||||||
|
import com.ruoyi.common.enums.HttpMethod;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
@ -48,7 +49,7 @@ public class XssFilter implements Filter {
|
|||||||
String url = request.getServletPath();
|
String url = request.getServletPath();
|
||||||
String method = request.getMethod();
|
String method = request.getMethod();
|
||||||
// GET DELETE 不过滤
|
// GET DELETE 不过滤
|
||||||
if (method == null || method.matches("GET") || method.matches("DELETE")) {
|
if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return StringUtils.matches(url, excludes);
|
return StringUtils.matches(url, excludes);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.common.filter;
|
package com.ruoyi.common.filter;
|
||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@ -50,7 +51,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 为空,直接返回
|
// 为空,直接返回
|
||||||
String json = IoUtil.read(super.getInputStream(), StandardCharsets.UTF_8);
|
String json = StrUtil.str(IoUtil.readBytes(super.getInputStream(), false), StandardCharsets.UTF_8);
|
||||||
if (StringUtils.isEmpty(json)) {
|
if (StringUtils.isEmpty(json)) {
|
||||||
return super.getInputStream();
|
return super.getInputStream();
|
||||||
}
|
}
|
||||||
@ -88,8 +89,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否是Json请求
|
* 是否是Json请求
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
*/
|
*/
|
||||||
public boolean isJsonRequest() {
|
public boolean isJsonRequest() {
|
||||||
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.common.helper;
|
|||||||
|
|
||||||
import cn.dev33.satoken.context.SaHolder;
|
import cn.dev33.satoken.context.SaHolder;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
@ -80,18 +81,12 @@ public class LoginHelper {
|
|||||||
LoginUser loginUser = getLoginUser();
|
LoginUser loginUser = getLoginUser();
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
if (ObjectUtil.isNull(loginUser)) {
|
||||||
String loginId = StpUtil.getLoginIdAsString();
|
String loginId = StpUtil.getLoginIdAsString();
|
||||||
String userId = null;
|
|
||||||
for (UserType value : UserType.values()) {
|
|
||||||
if (StringUtils.contains(loginId, value.getUserType())) {
|
|
||||||
String[] strs = StringUtils.split(loginId, JOIN_CODE);
|
String[] strs = StringUtils.split(loginId, JOIN_CODE);
|
||||||
// 用户id在总是在最后
|
if (!ArrayUtil.containsAny(strs, UserType.values())) {
|
||||||
userId = strs[strs.length - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isBlank(userId)) {
|
|
||||||
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
||||||
}
|
}
|
||||||
return Long.parseLong(userId);
|
// 用户id在总是在最后
|
||||||
|
return Long.parseLong(strs[strs.length - 1]);
|
||||||
}
|
}
|
||||||
return loginUser.getUserId();
|
return loginUser.getUserId();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.ruoyi.common.jackson;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.BeanProperty;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
||||||
|
import com.ruoyi.common.annotation.DictDataMapper;
|
||||||
|
import com.ruoyi.common.core.service.DictService;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据json序列化工具
|
||||||
|
*
|
||||||
|
* @author itino
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class DictDataJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
|
||||||
|
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
|
try {
|
||||||
|
DictService dictService = SpringUtils.getBean(DictService.class);
|
||||||
|
if (ObjectUtil.isNotNull(dictService)) {
|
||||||
|
String label = dictService.getDictLabel(dictType, value);
|
||||||
|
gen.writeString(StringUtils.isNotBlank(label) ? label : value);
|
||||||
|
} else {
|
||||||
|
gen.writeString(value);
|
||||||
|
}
|
||||||
|
} catch (BeansException e) {
|
||||||
|
log.error("字典数据未查到, 采用默认处理 => {}", e.getMessage());
|
||||||
|
gen.writeString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
|
||||||
|
DictDataMapper anno = property.getAnnotation(DictDataMapper.class);
|
||||||
|
if (Objects.nonNull(anno) && StrUtil.isNotBlank(anno.dictType())) {
|
||||||
|
this.dictType = anno.dictType();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return prov.findValueSerializer(property.getType(), property);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.common.jackson;
|
package com.ruoyi.common.jackson;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.BeanProperty;
|
import com.fasterxml.jackson.databind.BeanProperty;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
@ -10,6 +11,8 @@ import com.ruoyi.common.annotation.Sensitive;
|
|||||||
import com.ruoyi.common.core.service.SensitiveService;
|
import com.ruoyi.common.core.service.SensitiveService;
|
||||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
import com.ruoyi.common.enums.SensitiveStrategy;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -19,19 +22,24 @@ import java.util.Objects;
|
|||||||
*
|
*
|
||||||
* @author Yjoioooo
|
* @author Yjoioooo
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
|
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
|
||||||
|
|
||||||
private SensitiveStrategy strategy;
|
private SensitiveStrategy strategy;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
|
try {
|
||||||
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
||||||
if (sensitiveService.isSensitive()) {
|
if (ObjectUtil.isNotNull(sensitiveService) && sensitiveService.isSensitive()) {
|
||||||
gen.writeString(strategy.desensitizer().apply(value));
|
gen.writeString(strategy.desensitizer().apply(value));
|
||||||
} else {
|
} else {
|
||||||
gen.writeString(value);
|
gen.writeString(value);
|
||||||
}
|
}
|
||||||
|
} catch (BeansException e) {
|
||||||
|
log.error("脱敏实现不存在, 采用默认处理 => {}", e.getMessage());
|
||||||
|
gen.writeString(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,6 @@ import org.springframework.cglib.core.Converter;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bean深拷贝工具(基于 cglib 性能优异)
|
* bean深拷贝工具(基于 cglib 性能优异)
|
||||||
@ -79,11 +78,11 @@ public class BeanCopyUtils {
|
|||||||
if (CollUtil.isEmpty(sourceList)) {
|
if (CollUtil.isEmpty(sourceList)) {
|
||||||
return CollUtil.newArrayList();
|
return CollUtil.newArrayList();
|
||||||
}
|
}
|
||||||
return sourceList.stream().map(source -> {
|
return StreamUtils.toList(sourceList, source -> {
|
||||||
V target = ReflectUtil.newInstanceIfPossible(desc);
|
V target = ReflectUtil.newInstanceIfPossible(desc);
|
||||||
copy(source, target);
|
copy(source, target);
|
||||||
return target;
|
return target;
|
||||||
}).collect(Collectors.toList());
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -78,6 +79,9 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructType(Dict.class));
|
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructType(Dict.class));
|
||||||
|
} catch (MismatchedInputException e) {
|
||||||
|
// 类型不匹配说明不是json
|
||||||
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.ruoyi.common.utils;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import cn.hutool.http.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@ -10,11 +11,18 @@ import org.springframework.web.context.request.RequestAttributes;
|
|||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端工具类
|
* 客户端工具类
|
||||||
@ -66,6 +74,31 @@ public class ServletUtils extends ServletUtil {
|
|||||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得所有请求参数
|
||||||
|
*
|
||||||
|
* @param request 请求对象{@link ServletRequest}
|
||||||
|
* @return Map
|
||||||
|
*/
|
||||||
|
public static Map<String, String[]> getParams(ServletRequest request) {
|
||||||
|
final Map<String, String[]> map = request.getParameterMap();
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得所有请求参数
|
||||||
|
*
|
||||||
|
* @param request 请求对象{@link ServletRequest}
|
||||||
|
* @return Map
|
||||||
|
*/
|
||||||
|
public static Map<String, String> getParamMap(ServletRequest request) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
||||||
|
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
@ -117,7 +150,7 @@ public class ServletUtils extends ServletUtil {
|
|||||||
public static boolean isAjaxRequest(HttpServletRequest request) {
|
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||||
|
|
||||||
String accept = request.getHeader("accept");
|
String accept = request.getHeader("accept");
|
||||||
if (accept != null && accept.contains("application/json")) {
|
if (accept != null && accept.contains(MediaType.APPLICATION_JSON_VALUE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,4 +172,32 @@ public class ServletUtils extends ServletUtil {
|
|||||||
return getClientIP(getRequest());
|
return getClientIP(getRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容编码
|
||||||
|
*
|
||||||
|
* @param str 内容
|
||||||
|
* @return 编码后的内容
|
||||||
|
*/
|
||||||
|
public static String urlEncode(String str) {
|
||||||
|
try {
|
||||||
|
return URLEncoder.encode(str, Constants.UTF8);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容解码
|
||||||
|
*
|
||||||
|
* @param str 内容
|
||||||
|
* @return 解码后的内容
|
||||||
|
*/
|
||||||
|
public static String urlDecode(String str) {
|
||||||
|
try {
|
||||||
|
return URLDecoder.decode(str, Constants.UTF8);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,251 @@
|
|||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stream 流工具类
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class StreamUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection过滤
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param function 过滤方法
|
||||||
|
* @return 过滤后的list
|
||||||
|
*/
|
||||||
|
public static <E> List<E> filter(Collection<E> collection, Predicate<E> function) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return collection.stream().filter(function).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection拼接
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param function 拼接方法
|
||||||
|
* @return 拼接后的list
|
||||||
|
*/
|
||||||
|
public static <E> String join(Collection<E> collection, Function<E, String> function) {
|
||||||
|
return join(collection, function, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection拼接
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param function 拼接方法
|
||||||
|
* @param delimiter 拼接符
|
||||||
|
* @return 拼接后的list
|
||||||
|
*/
|
||||||
|
public static <E> String join(Collection<E> collection, Function<E, String> function, CharSequence delimiter) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
return collection.stream().map(function).filter(Objects::nonNull).collect(Collectors.joining(delimiter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection排序
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param comparing 排序方法
|
||||||
|
* @return 排序后的list
|
||||||
|
*/
|
||||||
|
public static <E> List<E> sorted(Collection<E> collection, Comparator<E> comparing) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return collection.stream().sorted(comparing).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection转化为类型不变的map<br>
|
||||||
|
* <B>{@code Collection<V> ----> Map<K,V>}</B>
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param key V类型转化为K类型的lambda方法
|
||||||
|
* @param <V> collection中的泛型
|
||||||
|
* @param <K> map中的key类型
|
||||||
|
* @return 转化后的map
|
||||||
|
*/
|
||||||
|
public static <V, K> Map<K, V> toIdentityMap(Collection<V> collection, Function<V, K> key) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return MapUtil.newHashMap();
|
||||||
|
}
|
||||||
|
return collection.stream().collect(Collectors.toMap(key, Function.identity(), (l, r) -> l));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将Collection转化为map(value类型与collection的泛型不同)<br>
|
||||||
|
* <B>{@code Collection<E> -----> Map<K,V> }</B>
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param key E类型转化为K类型的lambda方法
|
||||||
|
* @param value E类型转化为V类型的lambda方法
|
||||||
|
* @param <E> collection中的泛型
|
||||||
|
* @param <K> map中的key类型
|
||||||
|
* @param <V> map中的value类型
|
||||||
|
* @return 转化后的map
|
||||||
|
*/
|
||||||
|
public static <E, K, V> Map<K, V> toMap(Collection<E> collection, Function<E, K> key, Function<E, V> value) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return MapUtil.newHashMap();
|
||||||
|
}
|
||||||
|
return collection.stream().collect(Collectors.toMap(key, value, (l, r) -> l));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection按照规则(比如有相同的班级id)分类成map<br>
|
||||||
|
* <B>{@code Collection<E> -------> Map<K,List<E>> } </B>
|
||||||
|
*
|
||||||
|
* @param collection 需要分类的集合
|
||||||
|
* @param key 分类的规则
|
||||||
|
* @param <E> collection中的泛型
|
||||||
|
* @param <K> map中的key类型
|
||||||
|
* @return 分类后的map
|
||||||
|
*/
|
||||||
|
public static <E, K> Map<K, List<E>> groupByKey(Collection<E> collection, Function<E, K> key) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return MapUtil.newHashMap();
|
||||||
|
}
|
||||||
|
return collection
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(key, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection按照两个规则(比如有相同的年级id,班级id)分类成双层map<br>
|
||||||
|
* <B>{@code Collection<E> ---> Map<T,Map<U,List<E>>> } </B>
|
||||||
|
*
|
||||||
|
* @param collection 需要分类的集合
|
||||||
|
* @param key1 第一个分类的规则
|
||||||
|
* @param key2 第二个分类的规则
|
||||||
|
* @param <E> 集合元素类型
|
||||||
|
* @param <K> 第一个map中的key类型
|
||||||
|
* @param <U> 第二个map中的key类型
|
||||||
|
* @return 分类后的map
|
||||||
|
*/
|
||||||
|
public static <E, K, U> Map<K, Map<U, List<E>>> groupBy2Key(Collection<E> collection, Function<E, K> key1, Function<E, U> key2) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return MapUtil.newHashMap();
|
||||||
|
}
|
||||||
|
return collection
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.groupingBy(key2, LinkedHashMap::new, Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection按照两个规则(比如有相同的年级id,班级id)分类成双层map<br>
|
||||||
|
* <B>{@code Collection<E> ---> Map<T,Map<U,E>> } </B>
|
||||||
|
*
|
||||||
|
* @param collection 需要分类的集合
|
||||||
|
* @param key1 第一个分类的规则
|
||||||
|
* @param key2 第二个分类的规则
|
||||||
|
* @param <T> 第一个map中的key类型
|
||||||
|
* @param <U> 第二个map中的key类型
|
||||||
|
* @param <E> collection中的泛型
|
||||||
|
* @return 分类后的map
|
||||||
|
*/
|
||||||
|
public static <E, T, U> Map<T, Map<U, E>> group2Map(Collection<E> collection, Function<E, T> key1, Function<E, U> key2) {
|
||||||
|
if (CollUtil.isEmpty(collection) || key1 == null || key2 == null) {
|
||||||
|
return MapUtil.newHashMap();
|
||||||
|
}
|
||||||
|
return collection
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.toMap(key2, Function.identity(), (l, r) -> l)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection转化为List集合,但是两者的泛型不同<br>
|
||||||
|
* <B>{@code Collection<E> ------> List<T> } </B>
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param function collection中的泛型转化为list泛型的lambda表达式
|
||||||
|
* @param <E> collection中的泛型
|
||||||
|
* @param <T> List中的泛型
|
||||||
|
* @return 转化后的list
|
||||||
|
*/
|
||||||
|
public static <E, T> List<T> toList(Collection<E> collection, Function<E, T> function) {
|
||||||
|
if (CollUtil.isEmpty(collection)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return collection
|
||||||
|
.stream()
|
||||||
|
.map(function)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将collection转化为Set集合,但是两者的泛型不同<br>
|
||||||
|
* <B>{@code Collection<E> ------> Set<T> } </B>
|
||||||
|
*
|
||||||
|
* @param collection 需要转化的集合
|
||||||
|
* @param function collection中的泛型转化为set泛型的lambda表达式
|
||||||
|
* @param <E> collection中的泛型
|
||||||
|
* @param <T> Set中的泛型
|
||||||
|
* @return 转化后的Set
|
||||||
|
*/
|
||||||
|
public static <E, T> Set<T> toSet(Collection<E> collection, Function<E, T> function) {
|
||||||
|
if (CollUtil.isEmpty(collection) || function == null) {
|
||||||
|
return CollUtil.newHashSet();
|
||||||
|
}
|
||||||
|
return collection
|
||||||
|
.stream()
|
||||||
|
.map(function)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并两个相同key类型的map
|
||||||
|
*
|
||||||
|
* @param map1 第一个需要合并的 map
|
||||||
|
* @param map2 第二个需要合并的 map
|
||||||
|
* @param merge 合并的lambda,将key value1 value2合并成最终的类型,注意value可能为空的情况
|
||||||
|
* @param <K> map中的key类型
|
||||||
|
* @param <X> 第一个 map的value类型
|
||||||
|
* @param <Y> 第二个 map的value类型
|
||||||
|
* @param <V> 最终map的value类型
|
||||||
|
* @return 合并后的map
|
||||||
|
*/
|
||||||
|
public static <K, X, Y, V> Map<K, V> merge(Map<K, X> map1, Map<K, Y> map2, BiFunction<X, Y, V> merge) {
|
||||||
|
if (MapUtil.isEmpty(map1) && MapUtil.isEmpty(map2)) {
|
||||||
|
return MapUtil.newHashMap();
|
||||||
|
} else if (MapUtil.isEmpty(map1)) {
|
||||||
|
map1 = MapUtil.newHashMap();
|
||||||
|
} else if (MapUtil.isEmpty(map2)) {
|
||||||
|
map2 = MapUtil.newHashMap();
|
||||||
|
}
|
||||||
|
Set<K> key = new HashSet<>();
|
||||||
|
key.addAll(map1.keySet());
|
||||||
|
key.addAll(map2.keySet());
|
||||||
|
Map<K, V> map = new HashMap<>();
|
||||||
|
for (K t : key) {
|
||||||
|
X x = map1.get(t);
|
||||||
|
Y y = map2.get(t);
|
||||||
|
V z = merge.apply(x, y);
|
||||||
|
if (z != null) {
|
||||||
|
map.put(t, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -194,7 +194,6 @@ public class ExcelUtil {
|
|||||||
*/
|
*/
|
||||||
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
|
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
|
||||||
String filename = encodingFilename(sheetName);
|
String filename = encodingFilename(sheetName);
|
||||||
response.reset();
|
|
||||||
FileUtils.setAttachmentResponseHeader(response, filename);
|
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package com.ruoyi.common.utils.redis;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.redisson.api.RMap;
|
||||||
|
import org.springframework.cache.Cache;
|
||||||
|
import org.springframework.cache.CacheManager;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存操作工具类 {@link }
|
||||||
|
*
|
||||||
|
* @author Michelle.Chung
|
||||||
|
* @date 2022/8/13
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
@SuppressWarnings(value = {"unchecked"})
|
||||||
|
public class CacheUtils {
|
||||||
|
|
||||||
|
private static final CacheManager CACHE_MANAGER = SpringUtils.getBean(CacheManager.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存组内所有的KEY
|
||||||
|
*
|
||||||
|
* @param cacheNames 缓存组名称
|
||||||
|
*/
|
||||||
|
public static Set<Object> keys(String cacheNames) {
|
||||||
|
RMap<Object, Object> rmap = (RMap<Object, Object>) CACHE_MANAGER.getCache(cacheNames).getNativeCache();
|
||||||
|
return rmap.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存值
|
||||||
|
*
|
||||||
|
* @param cacheNames 缓存组名称
|
||||||
|
* @param key 缓存key
|
||||||
|
*/
|
||||||
|
public static <T> T get(String cacheNames, Object key) {
|
||||||
|
Cache.ValueWrapper wrapper = CACHE_MANAGER.getCache(cacheNames).get(key);
|
||||||
|
return wrapper != null ? (T) wrapper.get() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存缓存值
|
||||||
|
*
|
||||||
|
* @param cacheNames 缓存组名称
|
||||||
|
* @param key 缓存key
|
||||||
|
* @param value 缓存值
|
||||||
|
*/
|
||||||
|
public static void put(String cacheNames, Object key, Object value) {
|
||||||
|
CACHE_MANAGER.getCache(cacheNames).put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除缓存值
|
||||||
|
*
|
||||||
|
* @param cacheNames 缓存组名称
|
||||||
|
* @param key 缓存key
|
||||||
|
*/
|
||||||
|
public static void evict(String cacheNames, Object key) {
|
||||||
|
CACHE_MANAGER.getCache(cacheNames).evict(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空缓存值
|
||||||
|
*
|
||||||
|
* @param cacheNames 缓存组名称
|
||||||
|
*/
|
||||||
|
public static void clear(String cacheNames) {
|
||||||
|
CACHE_MANAGER.getCache(cacheNames).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,6 @@ import lombok.AccessLevel;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.redisson.api.*;
|
import org.redisson.api.*;
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -30,6 +29,43 @@ public class QueueUtils {
|
|||||||
return CLIENT;
|
return CLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加普通队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
* @param data 数据
|
||||||
|
*/
|
||||||
|
public static <T> boolean addQueueObject(String queueName, T data) {
|
||||||
|
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
||||||
|
return queue.offer(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用获取一个队列数据 没有数据返回 null(不支持延迟队列)
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
|
public static <T> T getQueueObject(String queueName) {
|
||||||
|
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
||||||
|
return queue.poll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用删除队列数据(不支持延迟队列)
|
||||||
|
*/
|
||||||
|
public static <T> boolean removeQueueObject(String queueName, T data) {
|
||||||
|
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
||||||
|
return queue.remove(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用销毁队列 所有阻塞监听 报错(不支持延迟队列)
|
||||||
|
*/
|
||||||
|
public static <T> boolean destroyQueue(String queueName) {
|
||||||
|
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
||||||
|
return queue.delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加延迟队列数据 默认毫秒
|
* 添加延迟队列数据 默认毫秒
|
||||||
*
|
*
|
||||||
@ -84,32 +120,6 @@ public class QueueUtils {
|
|||||||
delayedQueue.destroy();
|
delayedQueue.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 尝试设置 优先队列比较器 用于排序优先级
|
|
||||||
*
|
|
||||||
* @param queueName 队列名
|
|
||||||
* @param comparator 比较器
|
|
||||||
*/
|
|
||||||
public static <T> boolean trySetPriorityQueueComparator(String queueName, Comparator<T> comparator) {
|
|
||||||
RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName);
|
|
||||||
return priorityBlockingQueue.trySetComparator(comparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 尝试设置 优先队列比较器 用于排序优先级
|
|
||||||
*
|
|
||||||
* @param queueName 队列名
|
|
||||||
* @param comparator 比较器
|
|
||||||
* @param destroy 已存在是否销毁
|
|
||||||
*/
|
|
||||||
public static <T> boolean trySetPriorityQueueComparator(String queueName, Comparator<T> comparator, boolean destroy) {
|
|
||||||
RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName);
|
|
||||||
if (priorityBlockingQueue.isExists() && destroy) {
|
|
||||||
destroyPriorityQueueObject(queueName);
|
|
||||||
}
|
|
||||||
return priorityBlockingQueue.trySetComparator(comparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加优先队列数据
|
* 添加优先队列数据
|
||||||
*
|
*
|
||||||
@ -121,32 +131,6 @@ public class QueueUtils {
|
|||||||
return priorityBlockingQueue.offer(data);
|
return priorityBlockingQueue.offer(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取一个优先队列数据 没有数据返回 null
|
|
||||||
*
|
|
||||||
* @param queueName 队列名
|
|
||||||
*/
|
|
||||||
public static <T> T getPriorityQueueObject(String queueName) {
|
|
||||||
RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName);
|
|
||||||
return priorityBlockingQueue.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除优先队列数据
|
|
||||||
*/
|
|
||||||
public static <T> boolean removePriorityQueueObject(String queueName, T data) {
|
|
||||||
RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName);
|
|
||||||
return priorityBlockingQueue.remove(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 销毁优先队列
|
|
||||||
*/
|
|
||||||
public static boolean destroyPriorityQueueObject(String queueName) {
|
|
||||||
RPriorityBlockingQueue<?> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName);
|
|
||||||
return priorityBlockingQueue.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 尝试设置 有界队列 容量 用于限制数量
|
* 尝试设置 有界队列 容量 用于限制数量
|
||||||
*
|
*
|
||||||
@ -168,7 +152,7 @@ public class QueueUtils {
|
|||||||
public static <T> boolean trySetBoundedQueueCapacity(String queueName, int capacity, boolean destroy) {
|
public static <T> boolean trySetBoundedQueueCapacity(String queueName, int capacity, boolean destroy) {
|
||||||
RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName);
|
RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName);
|
||||||
if (boundedBlockingQueue.isExists() && destroy) {
|
if (boundedBlockingQueue.isExists() && destroy) {
|
||||||
destroyBoundedQueueObject(queueName);
|
destroyQueue(queueName);
|
||||||
}
|
}
|
||||||
return boundedBlockingQueue.trySetCapacity(capacity);
|
return boundedBlockingQueue.trySetCapacity(capacity);
|
||||||
}
|
}
|
||||||
@ -185,32 +169,6 @@ public class QueueUtils {
|
|||||||
return boundedBlockingQueue.offer(data);
|
return boundedBlockingQueue.offer(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取一个有界队列数据 没有数据返回 null
|
|
||||||
*
|
|
||||||
* @param queueName 队列名
|
|
||||||
*/
|
|
||||||
public static <T> T getBoundedQueueObject(String queueName) {
|
|
||||||
RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName);
|
|
||||||
return boundedBlockingQueue.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除有界队列数据
|
|
||||||
*/
|
|
||||||
public static <T> boolean removeBoundedQueueObject(String queueName, T data) {
|
|
||||||
RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName);
|
|
||||||
return boundedBlockingQueue.remove(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 销毁有界队列
|
|
||||||
*/
|
|
||||||
public static boolean destroyBoundedQueueObject(String queueName) {
|
|
||||||
RBoundedBlockingQueue<?> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName);
|
|
||||||
return boundedBlockingQueue.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 等)
|
* 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 等)
|
||||||
*/
|
*/
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.ruoyi.common.utils.redis;
|
package com.ruoyi.common.utils.redis;
|
||||||
|
|
||||||
import cn.hutool.core.collection.IterUtil;
|
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.redisson.api.*;
|
import org.redisson.api.*;
|
||||||
|
import org.redisson.config.Config;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -12,6 +12,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis 工具类
|
* redis 工具类
|
||||||
@ -25,6 +27,14 @@ public class RedisUtils {
|
|||||||
|
|
||||||
private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class);
|
private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class);
|
||||||
|
|
||||||
|
public static NameMapper getNameMapper() {
|
||||||
|
Config config = CLIENT.getConfig();
|
||||||
|
if (config.isClusterConfig()) {
|
||||||
|
return config.useClusterServers().getNameMapper();
|
||||||
|
}
|
||||||
|
return config.useSingleServer().getNameMapper();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 限流
|
* 限流
|
||||||
*
|
*
|
||||||
@ -100,14 +110,13 @@ public class RedisUtils {
|
|||||||
* @since Redis 6.X 以上使用 setAndKeepTTL 兼容 5.X 方案
|
* @since Redis 6.X 以上使用 setAndKeepTTL 兼容 5.X 方案
|
||||||
*/
|
*/
|
||||||
public static <T> void setCacheObject(final String key, final T value, final boolean isSaveTtl) {
|
public static <T> void setCacheObject(final String key, final T value, final boolean isSaveTtl) {
|
||||||
RBucket<Object> bucket = CLIENT.getBucket(key);
|
RBucket<T> bucket = CLIENT.getBucket(key);
|
||||||
if (isSaveTtl) {
|
if (isSaveTtl) {
|
||||||
try {
|
try {
|
||||||
bucket.setAndKeepTTL(value);
|
bucket.setAndKeepTTL(value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
long timeToLive = bucket.remainTimeToLive();
|
long timeToLive = bucket.remainTimeToLive();
|
||||||
bucket.set(value);
|
setCacheObject(key, value, Duration.ofMillis(timeToLive));
|
||||||
bucket.expire(Duration.ofMillis(timeToLive));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bucket.set(value);
|
bucket.set(value);
|
||||||
@ -122,9 +131,11 @@ public class RedisUtils {
|
|||||||
* @param duration 时间
|
* @param duration 时间
|
||||||
*/
|
*/
|
||||||
public static <T> void setCacheObject(final String key, final T value, final Duration duration) {
|
public static <T> void setCacheObject(final String key, final T value, final Duration duration) {
|
||||||
RBucket<T> result = CLIENT.getBucket(key);
|
RBatch batch = CLIENT.createBatch();
|
||||||
result.set(value);
|
RBucketAsync<T> bucket = batch.getBucket(key);
|
||||||
result.expire(duration);
|
bucket.setAsync(value);
|
||||||
|
bucket.expireAsync(duration);
|
||||||
|
batch.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -316,6 +327,17 @@ public class RedisUtils {
|
|||||||
return rMap.getAll(rMap.keySet());
|
return rMap.getAll(rMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得缓存Map的key列表
|
||||||
|
*
|
||||||
|
* @param key 缓存的键值
|
||||||
|
* @return key列表
|
||||||
|
*/
|
||||||
|
public static <T> Set<String> getCacheMapKeySet(final String key) {
|
||||||
|
RMap<String, T> rMap = CLIENT.getMap(key);
|
||||||
|
return rMap.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 往Hash中存入数据
|
* 往Hash中存入数据
|
||||||
*
|
*
|
||||||
@ -415,8 +437,17 @@ public class RedisUtils {
|
|||||||
* @return 对象列表
|
* @return 对象列表
|
||||||
*/
|
*/
|
||||||
public static Collection<String> keys(final String pattern) {
|
public static Collection<String> keys(final String pattern) {
|
||||||
Iterable<String> iterable = CLIENT.getKeys().getKeysByPattern(pattern);
|
Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(getNameMapper().map(pattern));
|
||||||
return IterUtil.toList(iterable);
|
return stream.map(key -> getNameMapper().unmap(key)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除缓存的基本对象列表
|
||||||
|
*
|
||||||
|
* @param pattern 字符串前缀
|
||||||
|
*/
|
||||||
|
public static void deleteKeys(final String pattern) {
|
||||||
|
CLIENT.getKeys().deleteByPattern(getNameMapper().map(pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -426,6 +457,6 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean hasKey(String key) {
|
public static Boolean hasKey(String key) {
|
||||||
RKeys rKeys = CLIENT.getKeys();
|
RKeys rKeys = CLIENT.getKeys();
|
||||||
return rKeys.countExists(key) > 0;
|
return rKeys.countExists(getNameMapper().map(key)) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.2.0</version>
|
<version>4.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.tencentcloudapi</groupId>-->
|
<!-- <groupId>com.tencentcloudapi</groupId>-->
|
||||||
<!-- <artifactId>tencentcloud-sdk-java</artifactId>-->
|
<!-- <artifactId>tencentcloud-sdk-java-sms</artifactId>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -2,9 +2,6 @@ package com.ruoyi.demo.controller;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.email.MailUtils;
|
import com.ruoyi.common.utils.email.MailUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -20,27 +17,34 @@ import java.io.File;
|
|||||||
* @author Michelle.Chung
|
* @author Michelle.Chung
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "邮件发送案例", tags = {"邮件发送案例"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/mail")
|
@RequestMapping("/demo/mail")
|
||||||
public class MailController {
|
public class MailController {
|
||||||
|
|
||||||
@ApiOperation("发送邮件")
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
*
|
||||||
|
* @param to 接收人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param text 内容
|
||||||
|
*/
|
||||||
@GetMapping("/sendSimpleMessage")
|
@GetMapping("/sendSimpleMessage")
|
||||||
public R<Void> sendSimpleMessage(@ApiParam("接收人") String to,
|
public R<Void> sendSimpleMessage(String to, String subject, String text) {
|
||||||
@ApiParam("标题") String subject,
|
|
||||||
@ApiParam("内容") String text) {
|
|
||||||
MailUtils.sendText(to, subject, text);
|
MailUtils.sendText(to, subject, text);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("发送邮件(带附件)")
|
/**
|
||||||
|
* 发送邮件(带附件)
|
||||||
|
*
|
||||||
|
* @param to 接收人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param text 内容
|
||||||
|
* @param filePath 附件路径
|
||||||
|
*/
|
||||||
@GetMapping("/sendMessageWithAttachment")
|
@GetMapping("/sendMessageWithAttachment")
|
||||||
public R<Void> sendMessageWithAttachment(@ApiParam("接收人") String to,
|
public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) {
|
||||||
@ApiParam("标题") String subject,
|
|
||||||
@ApiParam("内容") String text,
|
|
||||||
@ApiParam("附件路径") String filePath) {
|
|
||||||
MailUtils.sendText(to, subject, text, new File(filePath));
|
MailUtils.sendText(to, subject, text, new File(filePath));
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ruoyi.demo.controller;
|
package com.ruoyi.demo.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.constant.CacheNames;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.CachePut;
|
import org.springframework.cache.annotation.CachePut;
|
||||||
@ -20,8 +19,7 @@ import java.time.Duration;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
// 类级别 缓存统一配置
|
// 类级别 缓存统一配置
|
||||||
//@CacheConfig(cacheNames = "redissonCacheMap")
|
//@CacheConfig(cacheNames = CacheNames.DEMO_CACHE)
|
||||||
@Api(value = "spring-cache 演示案例", tags = {"spring-cache 演示案例"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/cache")
|
@RequestMapping("/demo/cache")
|
||||||
@ -39,10 +37,9 @@ public class RedisCacheController {
|
|||||||
* 重点说明: 缓存注解严谨与其他筛选数据功能一起使用
|
* 重点说明: 缓存注解严谨与其他筛选数据功能一起使用
|
||||||
* 例如: 数据权限注解 会造成 缓存击穿 与 数据不一致问题
|
* 例如: 数据权限注解 会造成 缓存击穿 与 数据不一致问题
|
||||||
* <p>
|
* <p>
|
||||||
* cacheNames 为配置文件内 groupId
|
* cacheNames 命名规则 查看 {@link CacheNames} 注释 支持多参数
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试 @Cacheable")
|
@Cacheable(cacheNames = "demo:cache#60s#10m#20", key = "#key", condition = "#key != null")
|
||||||
@Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
|
|
||||||
@GetMapping("/test1")
|
@GetMapping("/test1")
|
||||||
public R<String> test1(String key, String value) {
|
public R<String> test1(String key, String value) {
|
||||||
return R.ok("操作成功", value);
|
return R.ok("操作成功", value);
|
||||||
@ -52,12 +49,11 @@ public class RedisCacheController {
|
|||||||
* 测试 @CachePut
|
* 测试 @CachePut
|
||||||
* <p>
|
* <p>
|
||||||
* 加了@CachePut注解的方法,会把方法的返回值put到缓存里面缓存起来,供其它地方使用
|
* 加了@CachePut注解的方法,会把方法的返回值put到缓存里面缓存起来,供其它地方使用
|
||||||
* 它「通常用在新增方法上」
|
* 它「通常用在新增或者实时更新方法上」
|
||||||
* <p>
|
* <p>
|
||||||
* cacheNames 为 配置文件内 groupId
|
* cacheNames 命名规则 查看 {@link CacheNames} 注释 支持多参数
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试 @CachePut")
|
@CachePut(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null")
|
||||||
@CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
|
|
||||||
@GetMapping("/test2")
|
@GetMapping("/test2")
|
||||||
public R<String> test2(String key, String value) {
|
public R<String> test2(String key, String value) {
|
||||||
return R.ok("操作成功", value);
|
return R.ok("操作成功", value);
|
||||||
@ -67,12 +63,11 @@ public class RedisCacheController {
|
|||||||
* 测试 @CacheEvict
|
* 测试 @CacheEvict
|
||||||
* <p>
|
* <p>
|
||||||
* 使用了CacheEvict注解的方法,会清空指定缓存
|
* 使用了CacheEvict注解的方法,会清空指定缓存
|
||||||
* 「一般用在更新或者删除的方法上」
|
* 「一般用在删除的方法上」
|
||||||
* <p>
|
* <p>
|
||||||
* cacheNames 为 配置文件内 groupId
|
* cacheNames 命名规则 查看 {@link CacheNames} 注释 支持多参数
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试 @CacheEvict")
|
@CacheEvict(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null")
|
||||||
@CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
|
|
||||||
@GetMapping("/test3")
|
@GetMapping("/test3")
|
||||||
public R<String> test3(String key, String value) {
|
public R<String> test3(String key, String value) {
|
||||||
return R.ok("操作成功", value);
|
return R.ok("操作成功", value);
|
||||||
@ -83,7 +78,6 @@ public class RedisCacheController {
|
|||||||
* 手动设置过期时间10秒
|
* 手动设置过期时间10秒
|
||||||
* 11秒后获取 判断是否相等
|
* 11秒后获取 判断是否相等
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试设置过期时间")
|
|
||||||
@GetMapping("/test6")
|
@GetMapping("/test6")
|
||||||
public R<Boolean> test6(String key, String value) {
|
public R<Boolean> test6(String key, String value) {
|
||||||
RedisUtils.setCacheObject(key, value);
|
RedisUtils.setCacheObject(key, value);
|
||||||
|
@ -5,8 +5,6 @@ import com.baomidou.lock.LockTemplate;
|
|||||||
import com.baomidou.lock.annotation.Lock4j;
|
import com.baomidou.lock.annotation.Lock4j;
|
||||||
import com.baomidou.lock.executor.RedissonLockExecutor;
|
import com.baomidou.lock.executor.RedissonLockExecutor;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -21,7 +19,6 @@ import java.time.LocalTime;
|
|||||||
*
|
*
|
||||||
* @author shenxinquan
|
* @author shenxinquan
|
||||||
*/
|
*/
|
||||||
@Api(value = "测试分布式锁的样例", tags = {"测试分布式锁的样例"})
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/redisLock")
|
@RequestMapping("/demo/redisLock")
|
||||||
@ -33,7 +30,6 @@ public class RedisLockController {
|
|||||||
/**
|
/**
|
||||||
* 测试lock4j 注解
|
* 测试lock4j 注解
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试lock4j 注解")
|
|
||||||
@Lock4j(keys = {"#key"})
|
@Lock4j(keys = {"#key"})
|
||||||
@GetMapping("/testLock4j")
|
@GetMapping("/testLock4j")
|
||||||
public R<String> testLock4j(String key, String value) {
|
public R<String> testLock4j(String key, String value) {
|
||||||
@ -50,7 +46,6 @@ public class RedisLockController {
|
|||||||
/**
|
/**
|
||||||
* 测试lock4j 工具
|
* 测试lock4j 工具
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试lock4j 工具")
|
|
||||||
@GetMapping("/testLock4jLockTemplate")
|
@GetMapping("/testLock4jLockTemplate")
|
||||||
public R<String> testLock4jLockTemplate(String key, String value) {
|
public R<String> testLock4jLockTemplate(String key, String value) {
|
||||||
final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class);
|
final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class);
|
||||||
|
@ -2,9 +2,6 @@ package com.ruoyi.demo.controller;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -15,24 +12,32 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "Redis发布订阅 演示案例", tags = {"Redis发布订阅"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/redis/pubsub")
|
@RequestMapping("/demo/redis/pubsub")
|
||||||
public class RedisPubSubController {
|
public class RedisPubSubController {
|
||||||
|
|
||||||
@ApiOperation("发布消息")
|
/**
|
||||||
|
* 发布消息
|
||||||
|
*
|
||||||
|
* @param key 通道Key
|
||||||
|
* @param value 发送内容
|
||||||
|
*/
|
||||||
@GetMapping("/pub")
|
@GetMapping("/pub")
|
||||||
public R<Void> pub(@ApiParam("通道Key") String key, @ApiParam("发送内容") String value) {
|
public R<Void> pub(String key, String value) {
|
||||||
RedisUtils.publish(key, value, consumer -> {
|
RedisUtils.publish(key, value, consumer -> {
|
||||||
System.out.println("发布通道 => " + key + ", 发送值 => " + value);
|
System.out.println("发布通道 => " + key + ", 发送值 => " + value);
|
||||||
});
|
});
|
||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("订阅消息")
|
/**
|
||||||
|
* 订阅消息
|
||||||
|
*
|
||||||
|
* @param key 通道Key
|
||||||
|
*/
|
||||||
@GetMapping("/sub")
|
@GetMapping("/sub")
|
||||||
public R<Void> sub(@ApiParam("通道Key") String key) {
|
public R<Void> sub(String key) {
|
||||||
RedisUtils.subscribe(key, String.class, msg -> {
|
RedisUtils.subscribe(key, String.class, msg -> {
|
||||||
System.out.println("订阅通道 => " + key + ", 接收值 => " + msg);
|
System.out.println("订阅通道 => " + key + ", 接收值 => " + msg);
|
||||||
});
|
});
|
||||||
|
@ -3,8 +3,6 @@ package com.ruoyi.demo.controller;
|
|||||||
import com.ruoyi.common.annotation.RateLimiter;
|
import com.ruoyi.common.annotation.RateLimiter;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.enums.LimitType;
|
import com.ruoyi.common.enums.LimitType;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -16,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "测试分布式限流样例", tags = {"测试分布式限流样例"})
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/rateLimiter")
|
@RequestMapping("/demo/rateLimiter")
|
||||||
@ -26,7 +23,6 @@ public class RedisRateLimiterController {
|
|||||||
* 测试全局限流
|
* 测试全局限流
|
||||||
* 全局影响
|
* 全局影响
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试全局限流")
|
|
||||||
@RateLimiter(count = 2, time = 10)
|
@RateLimiter(count = 2, time = 10)
|
||||||
@GetMapping("/test")
|
@GetMapping("/test")
|
||||||
public R<String> test(String value) {
|
public R<String> test(String value) {
|
||||||
@ -37,7 +33,6 @@ public class RedisRateLimiterController {
|
|||||||
* 测试请求IP限流
|
* 测试请求IP限流
|
||||||
* 同一IP请求受影响
|
* 同一IP请求受影响
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试请求IP限流")
|
|
||||||
@RateLimiter(count = 2, time = 10, limitType = LimitType.IP)
|
@RateLimiter(count = 2, time = 10, limitType = LimitType.IP)
|
||||||
@GetMapping("/testip")
|
@GetMapping("/testip")
|
||||||
public R<String> testip(String value) {
|
public R<String> testip(String value) {
|
||||||
@ -48,7 +43,6 @@ public class RedisRateLimiterController {
|
|||||||
* 测试集群实例限流
|
* 测试集群实例限流
|
||||||
* 启动两个后端服务互不影响
|
* 启动两个后端服务互不影响
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试集群实例限流")
|
|
||||||
@RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER)
|
@RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER)
|
||||||
@GetMapping("/testcluster")
|
@GetMapping("/testcluster")
|
||||||
public R<String> testcluster(String value) {
|
public R<String> testcluster(String value) {
|
||||||
|
@ -4,9 +4,6 @@ import com.ruoyi.common.core.domain.R;
|
|||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.sms.config.properties.SmsProperties;
|
import com.ruoyi.sms.config.properties.SmsProperties;
|
||||||
import com.ruoyi.sms.core.SmsTemplate;
|
import com.ruoyi.sms.core.SmsTemplate;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -24,7 +21,6 @@ import java.util.Map;
|
|||||||
* @version 4.2.0
|
* @version 4.2.0
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "短信演示案例", tags = {"短信演示案例"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/sms")
|
@RequestMapping("/demo/sms")
|
||||||
@ -34,10 +30,14 @@ public class SmsController {
|
|||||||
// private final SmsTemplate smsTemplate; // 可以使用spring注入
|
// private final SmsTemplate smsTemplate; // 可以使用spring注入
|
||||||
// private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具
|
// private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具
|
||||||
|
|
||||||
@ApiOperation("发送短信Aliyun")
|
/**
|
||||||
|
* 发送短信Aliyun
|
||||||
|
*
|
||||||
|
* @param phones 电话号
|
||||||
|
* @param templateId 模板ID
|
||||||
|
*/
|
||||||
@GetMapping("/sendAliyun")
|
@GetMapping("/sendAliyun")
|
||||||
public R<Object> sendAliyun(@ApiParam("电话号") String phones,
|
public R<Object> sendAliyun(String phones, String templateId) {
|
||||||
@ApiParam("模板ID") String templateId) {
|
|
||||||
if (!smsProperties.getEnabled()) {
|
if (!smsProperties.getEnabled()) {
|
||||||
return R.fail("当前系统没有开启短信功能!");
|
return R.fail("当前系统没有开启短信功能!");
|
||||||
}
|
}
|
||||||
@ -51,10 +51,14 @@ public class SmsController {
|
|||||||
return R.ok(send);
|
return R.ok(send);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("发送短信Tencent")
|
/**
|
||||||
|
* 发送短信Tencent
|
||||||
|
*
|
||||||
|
* @param phones 电话号
|
||||||
|
* @param templateId 模板ID
|
||||||
|
*/
|
||||||
@GetMapping("/sendTencent")
|
@GetMapping("/sendTencent")
|
||||||
public R<Object> sendTencent(@ApiParam("电话号") String phones,
|
public R<Object> sendTencent(String phones, String templateId) {
|
||||||
@ApiParam("模板ID") String templateId) {
|
|
||||||
if (!smsProperties.getEnabled()) {
|
if (!smsProperties.getEnabled()) {
|
||||||
return R.fail("当前系统没有开启短信功能!");
|
return R.fail("当前系统没有开启短信功能!");
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
package com.ruoyi.demo.controller;
|
package com.ruoyi.demo.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import io.swagger.annotations.Api;
|
import org.springframework.http.MediaType;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swagger3 用法示例
|
* swagger3 用法示例
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "演示swagger3控制器", tags = {"演示swagger3接口"})
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/swagger/demo")
|
@RequestMapping("/swagger/demo")
|
||||||
public class Swagger3DemoController {
|
public class Swagger3DemoController {
|
||||||
@ -26,12 +20,10 @@ public class Swagger3DemoController {
|
|||||||
/**
|
/**
|
||||||
* 上传请求
|
* 上传请求
|
||||||
* 必须使用 @RequestPart 注解标注为文件
|
* 必须使用 @RequestPart 注解标注为文件
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "通用上传请求")
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataTypeClass = File.class, required = true)
|
|
||||||
})
|
|
||||||
@PostMapping(value = "/upload")
|
|
||||||
public R<String> upload(@RequestPart("file") MultipartFile file) {
|
public R<String> upload(@RequestPart("file") MultipartFile file) {
|
||||||
return R.ok("操作成功", file.getOriginalFilename());
|
return R.ok("操作成功", file.getOriginalFilename());
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.demo.domain.TestDemo;
|
import com.ruoyi.demo.domain.TestDemo;
|
||||||
import com.ruoyi.demo.mapper.TestDemoMapper;
|
import com.ruoyi.demo.mapper.TestDemoMapper;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -22,7 +20,6 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @date 2021-05-30
|
* @date 2021-05-30
|
||||||
*/
|
*/
|
||||||
@Api(value = "测试批量方法", tags = {"测试批量方法"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/batch")
|
@RequestMapping("/demo/batch")
|
||||||
@ -38,7 +35,6 @@ public class TestBatchController extends BaseController {
|
|||||||
* <p>
|
* <p>
|
||||||
* 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度
|
* 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "新增批量方法")
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
// @DS("slave")
|
// @DS("slave")
|
||||||
public R<Void> add() {
|
public R<Void> add() {
|
||||||
@ -50,7 +46,7 @@ public class TestBatchController extends BaseController {
|
|||||||
testDemo.setValue("测试新增");
|
testDemo.setValue("测试新增");
|
||||||
list.add(testDemo);
|
list.add(testDemo);
|
||||||
}
|
}
|
||||||
return toAjax(testDemoMapper.insertBatch(list) ? 1 : 0);
|
return toAjax(testDemoMapper.insertBatch(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +54,6 @@ public class TestBatchController extends BaseController {
|
|||||||
* <p>
|
* <p>
|
||||||
* 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度
|
* 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "新增或更新批量方法")
|
|
||||||
@PostMapping("/addOrUpdate")
|
@PostMapping("/addOrUpdate")
|
||||||
// @DS("slave")
|
// @DS("slave")
|
||||||
public R<Void> addOrUpdate() {
|
public R<Void> addOrUpdate() {
|
||||||
@ -68,7 +63,8 @@ public class TestBatchController extends BaseController {
|
|||||||
testDemo.setOrderNum(-1);
|
testDemo.setOrderNum(-1);
|
||||||
testDemo.setTestKey("批量新增");
|
testDemo.setTestKey("批量新增");
|
||||||
testDemo.setValue("测试新增");
|
testDemo.setValue("测试新增");
|
||||||
list.add(testDemo); }
|
list.add(testDemo);
|
||||||
|
}
|
||||||
testDemoMapper.insertBatch(list);
|
testDemoMapper.insertBatch(list);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TestDemo testDemo = list.get(i);
|
TestDemo testDemo = list.get(i);
|
||||||
@ -78,13 +74,12 @@ public class TestBatchController extends BaseController {
|
|||||||
testDemo.setId(null);
|
testDemo.setId(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toAjax(testDemoMapper.insertOrUpdateBatch(list) ? 1 : 0);
|
return toAjax(testDemoMapper.insertOrUpdateBatch(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除批量方法
|
* 删除批量方法
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "删除批量方法")
|
|
||||||
@DeleteMapping()
|
@DeleteMapping()
|
||||||
// @DS("slave")
|
// @DS("slave")
|
||||||
public R<Void> remove() {
|
public R<Void> remove() {
|
||||||
|
@ -5,8 +5,8 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.validate.AddGroup;
|
import com.ruoyi.common.core.validate.AddGroup;
|
||||||
import com.ruoyi.common.core.validate.EditGroup;
|
import com.ruoyi.common.core.validate.EditGroup;
|
||||||
@ -20,8 +20,8 @@ import com.ruoyi.demo.domain.bo.TestDemoBo;
|
|||||||
import com.ruoyi.demo.domain.bo.TestDemoImportVo;
|
import com.ruoyi.demo.domain.bo.TestDemoImportVo;
|
||||||
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
||||||
import com.ruoyi.demo.service.ITestDemoService;
|
import com.ruoyi.demo.service.ITestDemoService;
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@ -29,7 +29,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -41,7 +40,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "测试单表控制器", tags = {"测试单表管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/demo")
|
@RequestMapping("/demo/demo")
|
||||||
@ -52,7 +50,6 @@ public class TestDemoController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询测试单表列表
|
* 查询测试单表列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询测试单表列表")
|
|
||||||
@SaCheckPermission("demo:demo:list")
|
@SaCheckPermission("demo:demo:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) {
|
public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) {
|
||||||
@ -62,20 +59,20 @@ public class TestDemoController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 自定义分页查询
|
* 自定义分页查询
|
||||||
*/
|
*/
|
||||||
@ApiOperation("自定义分页查询")
|
|
||||||
@SaCheckPermission("demo:demo:list")
|
@SaCheckPermission("demo:demo:list")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) {
|
public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) {
|
||||||
return iTestDemoService.customPageList(bo, pageQuery);
|
return iTestDemoService.customPageList(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导入测试-校验")
|
/**
|
||||||
@ApiImplicitParams({
|
* 导入数据
|
||||||
@ApiImplicitParam(name = "file", value = "导入文件", paramType = "query", dataTypeClass = File.class, required = true),
|
*
|
||||||
})
|
* @param file 导入文件
|
||||||
|
*/
|
||||||
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
|
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
|
||||||
@SaCheckPermission("demo:demo:import")
|
@SaCheckPermission("demo:demo:import")
|
||||||
@PostMapping("/importData")
|
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
||||||
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
|
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
|
||||||
List<TestDemoImportVo> volist = excelResult.getList();
|
List<TestDemoImportVo> volist = excelResult.getList();
|
||||||
@ -87,7 +84,6 @@ public class TestDemoController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 导出测试单表列表
|
* 导出测试单表列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("导出测试单表列表")
|
|
||||||
@SaCheckPermission("demo:demo:export")
|
@SaCheckPermission("demo:demo:export")
|
||||||
@Log(title = "测试单表", businessType = BusinessType.EXPORT)
|
@Log(title = "测试单表", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ -102,12 +98,12 @@ public class TestDemoController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取测试单表详细信息
|
* 获取测试单表详细信息
|
||||||
|
*
|
||||||
|
* @param id 测试ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取测试单表详细信息")
|
|
||||||
@SaCheckPermission("demo:demo:query")
|
@SaCheckPermission("demo:demo:query")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<TestDemoVo> getInfo(@ApiParam("测试ID")
|
public R<TestDemoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@NotNull(message = "主键不能为空")
|
|
||||||
@PathVariable("id") Long id) {
|
@PathVariable("id") Long id) {
|
||||||
return R.ok(iTestDemoService.queryById(id));
|
return R.ok(iTestDemoService.queryById(id));
|
||||||
}
|
}
|
||||||
@ -115,7 +111,6 @@ public class TestDemoController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增测试单表
|
* 新增测试单表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增测试单表")
|
|
||||||
@SaCheckPermission("demo:demo:add")
|
@SaCheckPermission("demo:demo:add")
|
||||||
@Log(title = "测试单表", businessType = BusinessType.INSERT)
|
@Log(title = "测试单表", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "{repeat.submit.message}")
|
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "{repeat.submit.message}")
|
||||||
@ -124,31 +119,30 @@ public class TestDemoController extends BaseController {
|
|||||||
// 使用校验工具对标 @Validated(AddGroup.class) 注解
|
// 使用校验工具对标 @Validated(AddGroup.class) 注解
|
||||||
// 用于在非 Controller 的地方校验对象
|
// 用于在非 Controller 的地方校验对象
|
||||||
ValidatorUtils.validate(bo, AddGroup.class);
|
ValidatorUtils.validate(bo, AddGroup.class);
|
||||||
return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0);
|
return toAjax(iTestDemoService.insertByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改测试单表
|
* 修改测试单表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改测试单表")
|
|
||||||
@SaCheckPermission("demo:demo:edit")
|
@SaCheckPermission("demo:demo:edit")
|
||||||
@Log(title = "测试单表", businessType = BusinessType.UPDATE)
|
@Log(title = "测试单表", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) {
|
||||||
return toAjax(iTestDemoService.updateByBo(bo) ? 1 : 0);
|
return toAjax(iTestDemoService.updateByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除测试单表
|
* 删除测试单表
|
||||||
|
*
|
||||||
|
* @param ids 测试ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除测试单表")
|
|
||||||
@SaCheckPermission("demo:demo:remove")
|
@SaCheckPermission("demo:demo:remove")
|
||||||
@Log(title = "测试单表", businessType = BusinessType.DELETE)
|
@Log(title = "测试单表", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public R<Void> remove(@ApiParam("测试ID串")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@NotEmpty(message = "主键不能为空")
|
|
||||||
@PathVariable Long[] ids) {
|
@PathVariable Long[] ids) {
|
||||||
return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ package com.ruoyi.demo.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -21,7 +19,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "测试Excel功能", tags = {"测试Excel功能"})
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/excel")
|
@RequestMapping("/demo/excel")
|
||||||
public class TestExcelController {
|
public class TestExcelController {
|
||||||
@ -29,35 +26,33 @@ public class TestExcelController {
|
|||||||
/**
|
/**
|
||||||
* 单列表多数据
|
* 单列表多数据
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "单列表多数据")
|
|
||||||
@GetMapping("/exportTemplateOne")
|
@GetMapping("/exportTemplateOne")
|
||||||
public void exportTemplateOne(HttpServletResponse response) {
|
public void exportTemplateOne(HttpServletResponse response) {
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("title","单列表多数据");
|
map.put("title", "单列表多数据");
|
||||||
map.put("test1","数据测试1");
|
map.put("test1", "数据测试1");
|
||||||
map.put("test2","数据测试2");
|
map.put("test2", "数据测试2");
|
||||||
map.put("test3","数据测试3");
|
map.put("test3", "数据测试3");
|
||||||
map.put("test4","数据测试4");
|
map.put("test4", "数据测试4");
|
||||||
map.put("testTest","666");
|
map.put("testTest", "666");
|
||||||
List<TestObj> list = new ArrayList<>();
|
List<TestObj> list = new ArrayList<>();
|
||||||
list.add(new TestObj("单列表测试1", "列表测试1", "列表测试2", "列表测试3", "列表测试4"));
|
list.add(new TestObj("单列表测试1", "列表测试1", "列表测试2", "列表测试3", "列表测试4"));
|
||||||
list.add(new TestObj("单列表测试2", "列表测试5", "列表测试6", "列表测试7", "列表测试8"));
|
list.add(new TestObj("单列表测试2", "列表测试5", "列表测试6", "列表测试7", "列表测试8"));
|
||||||
list.add(new TestObj("单列表测试3", "列表测试9", "列表测试10", "列表测试11", "列表测试12"));
|
list.add(new TestObj("单列表测试3", "列表测试9", "列表测试10", "列表测试11", "列表测试12"));
|
||||||
ExcelUtil.exportTemplate(CollUtil.newArrayList(map,list),"单列表.xlsx", "excel/单列表.xlsx", response);
|
ExcelUtil.exportTemplate(CollUtil.newArrayList(map, list), "单列表.xlsx", "excel/单列表.xlsx", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多列表多数据
|
* 多列表多数据
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "多列表多数据")
|
|
||||||
@GetMapping("/exportTemplateMuliti")
|
@GetMapping("/exportTemplateMuliti")
|
||||||
public void exportTemplateMuliti(HttpServletResponse response) {
|
public void exportTemplateMuliti(HttpServletResponse response) {
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("title1","标题1");
|
map.put("title1", "标题1");
|
||||||
map.put("title2","标题2");
|
map.put("title2", "标题2");
|
||||||
map.put("title3","标题3");
|
map.put("title3", "标题3");
|
||||||
map.put("title4","标题4");
|
map.put("title4", "标题4");
|
||||||
map.put("author","Lion Li");
|
map.put("author", "Lion Li");
|
||||||
List<TestObj1> list1 = new ArrayList<>();
|
List<TestObj1> list1 = new ArrayList<>();
|
||||||
list1.add(new TestObj1("list1测试1", "list1测试2", "list1测试3"));
|
list1.add(new TestObj1("list1测试1", "list1测试2", "list1测试3"));
|
||||||
list1.add(new TestObj1("list1测试4", "list1测试5", "list1测试6"));
|
list1.add(new TestObj1("list1测试4", "list1测试5", "list1测试6"));
|
||||||
@ -72,12 +67,12 @@ public class TestExcelController {
|
|||||||
list4.add(new TestObj1("list4测试4", "list4测试5", "list4测试6"));
|
list4.add(new TestObj1("list4测试4", "list4测试5", "list4测试6"));
|
||||||
list4.add(new TestObj1("list4测试7", "list4测试8", "list4测试9"));
|
list4.add(new TestObj1("list4测试7", "list4测试8", "list4测试9"));
|
||||||
list4.add(new TestObj1("list4测试10", "list4测试11", "list4测试12"));
|
list4.add(new TestObj1("list4测试10", "list4测试11", "list4测试12"));
|
||||||
Map<String,Object> multiListMap = new HashMap<>();
|
Map<String, Object> multiListMap = new HashMap<>();
|
||||||
multiListMap.put("map",map);
|
multiListMap.put("map", map);
|
||||||
multiListMap.put("data1",list1);
|
multiListMap.put("data1", list1);
|
||||||
multiListMap.put("data2",list2);
|
multiListMap.put("data2", list2);
|
||||||
multiListMap.put("data3",list3);
|
multiListMap.put("data3", list3);
|
||||||
multiListMap.put("data4",list4);
|
multiListMap.put("data4", list4);
|
||||||
ExcelUtil.exportTemplateMultiList(multiListMap, "多列表.xlsx", "excel/多列表.xlsx", response);
|
ExcelUtil.exportTemplateMultiList(multiListMap, "多列表.xlsx", "excel/多列表.xlsx", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ package com.ruoyi.demo.controller;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Range;
|
import org.hibernate.validator.constraints.Range;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -22,7 +19,6 @@ import javax.validation.constraints.NotNull;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "测试国际化控制器", tags = {"测试国际化管理"})
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/i18n")
|
@RequestMapping("/demo/i18n")
|
||||||
public class TestI18nController {
|
public class TestI18nController {
|
||||||
@ -32,10 +28,11 @@ public class TestI18nController {
|
|||||||
* code为 messages.properties 中的 key
|
* code为 messages.properties 中的 key
|
||||||
* <p>
|
* <p>
|
||||||
* 测试使用 user.register.success
|
* 测试使用 user.register.success
|
||||||
|
*
|
||||||
|
* @param code 国际化code
|
||||||
*/
|
*/
|
||||||
@ApiOperation("通过code获取国际化内容")
|
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public R<Void> get(@ApiParam("国际化code") String code) {
|
public R<Void> get(String code) {
|
||||||
return R.ok(MessageUtils.message(code));
|
return R.ok(MessageUtils.message(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +42,6 @@ public class TestI18nController {
|
|||||||
* <p>
|
* <p>
|
||||||
* 测试使用 not.null
|
* 测试使用 not.null
|
||||||
*/
|
*/
|
||||||
@ApiOperation("Validator 校验国际化")
|
|
||||||
@GetMapping("/test1")
|
@GetMapping("/test1")
|
||||||
public R<Void> test1(@NotBlank(message = "{not.null}") String str) {
|
public R<Void> test1(@NotBlank(message = "{not.null}") String str) {
|
||||||
return R.ok(str);
|
return R.ok(str);
|
||||||
@ -57,7 +53,6 @@ public class TestI18nController {
|
|||||||
* <p>
|
* <p>
|
||||||
* 测试使用 not.null
|
* 测试使用 not.null
|
||||||
*/
|
*/
|
||||||
@ApiOperation("Bean 校验国际化")
|
|
||||||
@GetMapping("/test2")
|
@GetMapping("/test2")
|
||||||
public R<TestI18nBo> test2(@Validated TestI18nBo bo) {
|
public R<TestI18nBo> test2(@Validated TestI18nBo bo) {
|
||||||
return R.ok(bo);
|
return R.ok(bo);
|
||||||
|
@ -4,8 +4,6 @@ import com.ruoyi.common.annotation.Sensitive;
|
|||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
import com.ruoyi.common.enums.SensitiveStrategy;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -21,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @version 3.6.0
|
* @version 3.6.0
|
||||||
* @see com.ruoyi.common.core.service.SensitiveService
|
* @see com.ruoyi.common.core.service.SensitiveService
|
||||||
*/
|
*/
|
||||||
@Api(value = "测试数据脱敏控制器", tags = {"测试数据脱敏管理"})
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/sensitive")
|
@RequestMapping("/demo/sensitive")
|
||||||
public class TestSensitiveController extends BaseController {
|
public class TestSensitiveController extends BaseController {
|
||||||
@ -29,7 +26,6 @@ public class TestSensitiveController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 测试数据脱敏
|
* 测试数据脱敏
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询测试单表列表")
|
|
||||||
@GetMapping("/test")
|
@GetMapping("/test")
|
||||||
public R<TestSensitive> test() {
|
public R<TestSensitive> test() {
|
||||||
TestSensitive testSensitive = new TestSensitive();
|
TestSensitive testSensitive = new TestSensitive();
|
||||||
|
@ -13,9 +13,6 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
|||||||
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
||||||
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
||||||
import com.ruoyi.demo.service.ITestTreeService;
|
import com.ruoyi.demo.service.ITestTreeService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -33,7 +30,6 @@ import java.util.List;
|
|||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "测试树表控制器", tags = {"测试树表管理"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/tree")
|
@RequestMapping("/demo/tree")
|
||||||
@ -44,7 +40,6 @@ public class TestTreeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询测试树表列表
|
* 查询测试树表列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询测试树表列表")
|
|
||||||
@SaCheckPermission("demo:tree:list")
|
@SaCheckPermission("demo:tree:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<TestTreeVo>> list(@Validated(QueryGroup.class) TestTreeBo bo) {
|
public R<List<TestTreeVo>> list(@Validated(QueryGroup.class) TestTreeBo bo) {
|
||||||
@ -55,7 +50,6 @@ public class TestTreeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 导出测试树表列表
|
* 导出测试树表列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("导出测试树表列表")
|
|
||||||
@SaCheckPermission("demo:tree:export")
|
@SaCheckPermission("demo:tree:export")
|
||||||
@Log(title = "测试树表", businessType = BusinessType.EXPORT)
|
@Log(title = "测试树表", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@ -66,12 +60,12 @@ public class TestTreeController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取测试树表详细信息
|
* 获取测试树表详细信息
|
||||||
|
*
|
||||||
|
* @param id 测试树ID
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取测试树表详细信息")
|
|
||||||
@SaCheckPermission("demo:tree:query")
|
@SaCheckPermission("demo:tree:query")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<TestTreeVo> getInfo(@ApiParam("测试树ID")
|
public R<TestTreeVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@NotNull(message = "主键不能为空")
|
|
||||||
@PathVariable("id") Long id) {
|
@PathVariable("id") Long id) {
|
||||||
return R.ok(iTestTreeService.queryById(id));
|
return R.ok(iTestTreeService.queryById(id));
|
||||||
}
|
}
|
||||||
@ -79,37 +73,35 @@ public class TestTreeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增测试树表
|
* 新增测试树表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增测试树表")
|
|
||||||
@SaCheckPermission("demo:tree:add")
|
@SaCheckPermission("demo:tree:add")
|
||||||
@Log(title = "测试树表", businessType = BusinessType.INSERT)
|
@Log(title = "测试树表", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) {
|
||||||
return toAjax(iTestTreeService.insertByBo(bo) ? 1 : 0);
|
return toAjax(iTestTreeService.insertByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改测试树表
|
* 修改测试树表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改测试树表")
|
|
||||||
@SaCheckPermission("demo:tree:edit")
|
@SaCheckPermission("demo:tree:edit")
|
||||||
@Log(title = "测试树表", businessType = BusinessType.UPDATE)
|
@Log(title = "测试树表", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) {
|
||||||
return toAjax(iTestTreeService.updateByBo(bo) ? 1 : 0);
|
return toAjax(iTestTreeService.updateByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除测试树表
|
* 删除测试树表
|
||||||
|
*
|
||||||
|
* @param ids 测试树ID串
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除测试树表")
|
|
||||||
@SaCheckPermission("demo:tree:remove")
|
@SaCheckPermission("demo:tree:remove")
|
||||||
@Log(title = "测试树表", businessType = BusinessType.DELETE)
|
@Log(title = "测试树表", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public R<Void> remove(@ApiParam("测试树ID串")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@NotEmpty(message = "主键不能为空")
|
|
||||||
@PathVariable Long[] ids) {
|
@PathVariable Long[] ids) {
|
||||||
return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@ package com.ruoyi.demo.controller.queue;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.redis.QueueUtils;
|
import com.ruoyi.common.utils.redis.QueueUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -23,19 +20,22 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @version 3.6.0
|
* @version 3.6.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(value = "有界队列 演示案例", tags = {"有界队列"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/queue/bounded")
|
@RequestMapping("/demo/queue/bounded")
|
||||||
public class BoundedQueueController {
|
public class BoundedQueueController {
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("添加队列数据")
|
/**
|
||||||
|
* 添加队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
* @param capacity 容量
|
||||||
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public R<Void> add(@ApiParam("队列名") String queueName,
|
public R<Void> add(String queueName, int capacity) {
|
||||||
@ApiParam("容量") int capacity) {
|
|
||||||
// 用完了一定要销毁 否则会一直存在
|
// 用完了一定要销毁 否则会一直存在
|
||||||
boolean b = QueueUtils.destroyBoundedQueueObject(queueName);
|
boolean b = QueueUtils.destroyQueue(queueName);
|
||||||
log.info("通道: {} , 删除: {}", queueName, b);
|
log.info("通道: {} , 删除: {}", queueName, b);
|
||||||
// 初始化设置一次即可
|
// 初始化设置一次即可
|
||||||
if (QueueUtils.trySetBoundedQueueCapacity(queueName, capacity)) {
|
if (QueueUtils.trySetBoundedQueueCapacity(queueName, capacity)) {
|
||||||
@ -56,11 +56,15 @@ public class BoundedQueueController {
|
|||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除队列数据")
|
/**
|
||||||
|
* 删除队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
@GetMapping("/remove")
|
@GetMapping("/remove")
|
||||||
public R<Void> remove(@ApiParam("队列名") String queueName) {
|
public R<Void> remove(String queueName) {
|
||||||
String data = "data-" + 5;
|
String data = "data-" + 5;
|
||||||
if (QueueUtils.removeBoundedQueueObject(queueName, data)) {
|
if (QueueUtils.removeQueueObject(queueName, data)) {
|
||||||
log.info("通道: {} , 删除数据: {}", queueName, data);
|
log.info("通道: {} , 删除数据: {}", queueName, data);
|
||||||
} else {
|
} else {
|
||||||
return R.fail("操作失败");
|
return R.fail("操作失败");
|
||||||
@ -68,12 +72,16 @@ public class BoundedQueueController {
|
|||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取队列数据")
|
/**
|
||||||
|
* 获取队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
public R<Void> get(@ApiParam("队列名") String queueName) {
|
public R<Void> get(String queueName) {
|
||||||
String data;
|
String data;
|
||||||
do {
|
do {
|
||||||
data = QueueUtils.getBoundedQueueObject(queueName);
|
data = QueueUtils.getQueueObject(queueName);
|
||||||
log.info("通道: {} , 获取数据: {}", queueName, data);
|
log.info("通道: {} , 获取数据: {}", queueName, data);
|
||||||
} while (data != null);
|
} while (data != null);
|
||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
|
@ -2,9 +2,6 @@ package com.ruoyi.demo.controller.queue;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.redis.QueueUtils;
|
import com.ruoyi.common.utils.redis.QueueUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -26,15 +23,18 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @version 3.6.0
|
* @version 3.6.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(value = "延迟队列 演示案例", tags = {"延迟队列"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/queue/delayed")
|
@RequestMapping("/demo/queue/delayed")
|
||||||
public class DelayedQueueController {
|
public class DelayedQueueController {
|
||||||
|
|
||||||
@ApiOperation("订阅队列")
|
/**
|
||||||
|
* 订阅队列
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
@GetMapping("/subscribe")
|
@GetMapping("/subscribe")
|
||||||
public R<Void> subscribe(@ApiParam("队列名") String queueName) {
|
public R<Void> subscribe(String queueName) {
|
||||||
log.info("通道: {} 监听中......", queueName);
|
log.info("通道: {} 监听中......", queueName);
|
||||||
// 项目初始化设置一次即可
|
// 项目初始化设置一次即可
|
||||||
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
||||||
@ -44,21 +44,29 @@ public class DelayedQueueController {
|
|||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("添加队列数据")
|
/**
|
||||||
|
* 添加队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
* @param orderNum 订单号
|
||||||
|
* @param time 延迟时间(秒)
|
||||||
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public R<Void> add(@ApiParam("队列名") String queueName,
|
public R<Void> add(String queueName, String orderNum, Long time) {
|
||||||
@ApiParam("订单号") String orderNum,
|
|
||||||
@ApiParam("延迟时间(秒)") Long time) {
|
|
||||||
QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS);
|
QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS);
|
||||||
// 观察发送时间
|
// 观察发送时间
|
||||||
log.info("通道: {} , 发送数据: {}", queueName, orderNum);
|
log.info("通道: {} , 发送数据: {}", queueName, orderNum);
|
||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除队列数据")
|
/**
|
||||||
|
* 删除队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
* @param orderNum 订单号
|
||||||
|
*/
|
||||||
@GetMapping("/remove")
|
@GetMapping("/remove")
|
||||||
public R<Void> remove(@ApiParam("队列名") String queueName,
|
public R<Void> remove(String queueName, String orderNum) {
|
||||||
@ApiParam("订单号") String orderNum) {
|
|
||||||
if (QueueUtils.removeDelayedQueueObject(queueName, orderNum)) {
|
if (QueueUtils.removeDelayedQueueObject(queueName, orderNum)) {
|
||||||
log.info("通道: {} , 删除数据: {}", queueName, orderNum);
|
log.info("通道: {} , 删除数据: {}", queueName, orderNum);
|
||||||
} else {
|
} else {
|
||||||
@ -67,9 +75,13 @@ public class DelayedQueueController {
|
|||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("销毁队列")
|
/**
|
||||||
|
* 销毁队列
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
@GetMapping("/destroy")
|
@GetMapping("/destroy")
|
||||||
public R<Void> destroy(@ApiParam("队列名") String queueName) {
|
public R<Void> destroy(String queueName) {
|
||||||
// 用完了一定要销毁 否则会一直存在
|
// 用完了一定要销毁 否则会一直存在
|
||||||
QueueUtils.destroyDelayedQueue(queueName);
|
QueueUtils.destroyDelayedQueue(queueName);
|
||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.demo.controller.queue;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实体类 注意不允许使用内部类 否则会找不到类
|
* 实体类 注意不允许使用内部类 否则会找不到类
|
||||||
@ -11,7 +12,12 @@ import lombok.NoArgsConstructor;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class PriorityDemo {
|
public class PriorityDemo implements Comparable<PriorityDemo> {
|
||||||
private String name;
|
private String name;
|
||||||
private Integer orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull PriorityDemo other) {
|
||||||
|
return Integer.compare(getOrderNum(), other.getOrderNum());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package com.ruoyi.demo.controller.queue;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 比较器 注意不允许使用 内部类或匿名类或lambda表达式 会找不到类
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
* @version 3.6.0
|
|
||||||
*/
|
|
||||||
public class PriorityDemoComparator implements Comparator<PriorityDemo> {
|
|
||||||
@Override
|
|
||||||
public int compare(PriorityDemo pd1, PriorityDemo pd2) {
|
|
||||||
return Integer.compare(pd1.getOrderNum(), pd2.getOrderNum());
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,9 +3,6 @@ package com.ruoyi.demo.controller.queue;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.utils.redis.QueueUtils;
|
import com.ruoyi.common.utils.redis.QueueUtils;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -24,26 +21,22 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @version 3.6.0
|
* @version 3.6.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(value = "优先队列 演示案例", tags = {"优先队列"})
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/queue/priority")
|
@RequestMapping("/demo/queue/priority")
|
||||||
public class PriorityQueueController {
|
public class PriorityQueueController {
|
||||||
|
|
||||||
@ApiOperation("添加队列数据")
|
/**
|
||||||
|
* 添加队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public R<Void> add(@ApiParam("队列名") String queueName) {
|
public R<Void> add(String queueName) {
|
||||||
// 用完了一定要销毁 否则会一直存在
|
// 用完了一定要销毁 否则会一直存在
|
||||||
boolean b = QueueUtils.destroyPriorityQueueObject(queueName);
|
boolean b = QueueUtils.destroyQueue(queueName);
|
||||||
log.info("通道: {} , 删除: {}", queueName, b);
|
log.info("通道: {} , 删除: {}", queueName, b);
|
||||||
// 初始化设置一次即可 此处注意 不允许用内部类或匿名类
|
|
||||||
boolean flag = QueueUtils.trySetPriorityQueueComparator(queueName, new PriorityDemoComparator());
|
|
||||||
if (flag) {
|
|
||||||
log.info("通道: {} , 设置比较器成功", queueName);
|
|
||||||
} else {
|
|
||||||
log.info("通道: {} , 设置比较器失败", queueName);
|
|
||||||
return R.fail("操作失败");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
int randomNum = RandomUtil.randomInt(10);
|
int randomNum = RandomUtil.randomInt(10);
|
||||||
PriorityDemo data = new PriorityDemo();
|
PriorityDemo data = new PriorityDemo();
|
||||||
@ -58,15 +51,19 @@ public class PriorityQueueController {
|
|||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除队列数据")
|
/**
|
||||||
|
* 删除队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
* @param name 对象名
|
||||||
|
* @param orderNum 排序号
|
||||||
|
*/
|
||||||
@GetMapping("/remove")
|
@GetMapping("/remove")
|
||||||
public R<Void> remove(@ApiParam("队列名") String queueName,
|
public R<Void> remove(String queueName, String name, Integer orderNum) {
|
||||||
@ApiParam("对象名") String name,
|
|
||||||
@ApiParam("排序号") Integer orderNum) {
|
|
||||||
PriorityDemo data = new PriorityDemo();
|
PriorityDemo data = new PriorityDemo();
|
||||||
data.setName(name);
|
data.setName(name);
|
||||||
data.setOrderNum(orderNum);
|
data.setOrderNum(orderNum);
|
||||||
if (QueueUtils.removePriorityQueueObject(queueName, data)) {
|
if (QueueUtils.removeQueueObject(queueName, data)) {
|
||||||
log.info("通道: {} , 删除数据: {}", queueName, data);
|
log.info("通道: {} , 删除数据: {}", queueName, data);
|
||||||
} else {
|
} else {
|
||||||
return R.fail("操作失败");
|
return R.fail("操作失败");
|
||||||
@ -74,12 +71,16 @@ public class PriorityQueueController {
|
|||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取队列数据")
|
/**
|
||||||
|
* 获取队列数据
|
||||||
|
*
|
||||||
|
* @param queueName 队列名
|
||||||
|
*/
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
public R<Void> get(@ApiParam("队列名") String queueName) {
|
public R<Void> get(String queueName) {
|
||||||
PriorityDemo data;
|
PriorityDemo data;
|
||||||
do {
|
do {
|
||||||
data = QueueUtils.getPriorityQueueObject(queueName);
|
data = QueueUtils.getQueueObject(queueName);
|
||||||
log.info("通道: {} , 获取数据: {}", queueName, data);
|
log.info("通道: {} , 获取数据: {}", queueName, data);
|
||||||
} while (data != null);
|
} while (data != null);
|
||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user