mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
d98acffe4e | |||
4d92ef22c3 | |||
255b5f2f07 | |||
c6fe27b040 | |||
3e2ddb3b25 | |||
ebc6617a8e | |||
65eb873f9a | |||
36fd16562e | |||
f99e24bf82 | |||
9aa8438ced | |||
a2c8b0d13e | |||
2c6e1f0db7 | |||
afbe1c98e6 | |||
c0e4e27dcc | |||
85762f7c92 | |||
c6963e1a96 | |||
ed7e8d0e5c | |||
b47a38d9d8 | |||
c2efaa5c3c |
@ -1,13 +0,0 @@
|
|||||||
### 使用版本(未按照模板填写直接删除)
|
|
||||||
|
|
||||||
|
|
||||||
### 问题描述
|
|
||||||
|
|
||||||
|
|
||||||
### 希望结果
|
|
||||||
|
|
||||||
|
|
||||||
### 重现步骤
|
|
||||||
|
|
||||||
|
|
||||||
### 报错信息(截图为主 请勿发混乱格式)
|
|
@ -1,7 +0,0 @@
|
|||||||
### 更改目的 解决了什么问题(请提交到dev分支)
|
|
||||||
|
|
||||||
|
|
||||||
### 描述 做了哪些改动
|
|
||||||
|
|
||||||
|
|
||||||
### 测试 都做了哪些测试(未经过测试不采纳)
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -25,9 +25,6 @@ target/
|
|||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
### JRebel ###
|
|
||||||
rebel.xml
|
|
||||||
|
|
||||||
### NetBeans ###
|
### NetBeans ###
|
||||||
nbproject/private/
|
nbproject/private/
|
||||||
build/*
|
build/*
|
||||||
|
20
README.md
20
README.md
@ -4,8 +4,8 @@
|
|||||||
[](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)
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
|
|
||||||
@ -14,20 +14,18 @@
|
|||||||
> 系统演示: [传送门](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/系统演示?sort_id=4836388)
|
> 系统演示: [传送门](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/系统演示?sort_id=4836388)
|
||||||
|
|
||||||
| 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 |
|
| 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 |
|
||||||
|----------|---------------------|---------------------------------------------------------------------------------------------------|----------------------------|
|
|---|---|---|---|
|
||||||
| 当前框架 | RuoYi-Vue-Plus | [RuoYi-Vue-Plus文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) | 重写RuoYi-Vue全方位升级(不兼容原框架) |
|
| 当前框架 | RuoYi-Vue-Plus | [RuoYi-Vue-Plus文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) | 重写RuoYi-Vue全方位升级(不兼容原框架) |
|
||||||
| 微服务分支 | RuoYi-Cloud-Plus | [微服务分支地址](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus) | 重写RuoYi-Cloud全方位升级(不兼容原框架) |
|
| satoken分支 | RuoYi-Vue-Plus-satoken | [satoken分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 高可读性 扩展性(推荐使用) |
|
||||||
| 单体分支 | RuoYi-Vue-Plus-fast | [fast分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) | 单体应用结构 |
|
| 单体分支 | RuoYi-Vue-Plus-fast | [fast分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) | 单体应用结构 |
|
||||||
| Vue3分支 | RuoYi-Vue-Plus-UI | [UI地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus-UI) | 由于组件还未完善 仅供学习 |
|
| Vue3分支 | RuoYi-Vue-Plus-UI | [UI地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus-UI) | 由于组件还未完善 仅供学习 |
|
||||||
| 原框架 | RuoYi-Vue | [RuoYi-Vue官网](http://ruoyi.vip/) | 定期同步需要的功能 |
|
| 原框架 | RuoYi-Vue | [RuoYi-Vue官网](http://ruoyi.vip/) | 定期同步需要的功能 |
|
||||||
| 前端开发框架 | Vue、Element UI | [Element UI官网](https://element.eleme.cn/#/zh-CN) | |
|
| 前端开发框架 | Vue、Element UI | [Element UI官网](https://element.eleme.cn/#/zh-CN) | |
|
||||||
| 后端开发框架 | SpringBoot | [SpringBoot官网](https://spring.io/projects/spring-boot/#learn) | |
|
| 后端开发框架 | SpringBoot | [SpringBoot官网](https://spring.io/projects/spring-boot/#learn) | |
|
||||||
| 容器框架 | Undertow | [Undertow官网](https://undertow.io/) | 基于 XNIO 的高性能容器 |
|
| 容器框架 | Undertow | [Undertow官网](https://undertow.io/) | 基于 XNIO 的高性能容器 |
|
||||||
|
| 权限认证框架 | Spring Security、Jwt | [SpringSecurity官网](https://spring.io/projects/spring-security#learn) | 支持多终端认证系统 |
|
||||||
| 权限认证框架 | Sa-Token、Jwt | [Sa-Token官网](https://sa-token.dev33.cn/) | 强解耦、强扩展 |
|
| 权限认证框架 | Sa-Token、Jwt | [Sa-Token官网](https://sa-token.dev33.cn/) | 强解耦、强扩展 |
|
||||||
| 关系数据库 | MySQL | [MySQL官网](https://dev.mysql.com/) | 适配 8.X 最低 5.7 |
|
| 关系数据库 | MySQL | [MySQL官网](https://dev.mysql.com/) | 适配 8.X 最低 5.7 |
|
||||||
| 关系数据库 | Oracle | [Oracle官网](https://www.oracle.com/cn/database/) | 适配 11g 12c |
|
|
||||||
| 关系数据库 | PostgreSQL | [PostgreSQL官网](https://www.postgresql.org/) | 适配 13 14 |
|
|
||||||
| 关系数据库 | SQLServer | [SQLServer官网](https://docs.microsoft.com/zh-cn/sql/sql-server) | 适配 2017 2019 |
|
|
||||||
| 缓存数据库 | Redis | [Redis官网](https://redis.io/) | 适配 6.X 最低 4.X |
|
| 缓存数据库 | Redis | [Redis官网](https://redis.io/) | 适配 6.X 最低 4.X |
|
||||||
| 数据库框架 | Mybatis-Plus | [Mybatis-Plus文档](https://baomidou.com/guide/) | 快速 CRUD 增加开发效率 |
|
| 数据库框架 | Mybatis-Plus | [Mybatis-Plus文档](https://baomidou.com/guide/) | 快速 CRUD 增加开发效率 |
|
||||||
| 数据库框架 | p6spy | [p6spy官网](https://p6spy.readthedocs.io/) | 更强劲的 SQL 分析 |
|
| 数据库框架 | p6spy | [p6spy官网](https://p6spy.readthedocs.io/) | 更强劲的 SQL 分析 |
|
||||||
@ -35,14 +33,12 @@
|
|||||||
| 序列化框架 | Jackson | [Jackson官网](https://github.com/FasterXML/jackson) | 统一使用 jackson 高效可靠 |
|
| 序列化框架 | Jackson | [Jackson官网](https://github.com/FasterXML/jackson) | 统一使用 jackson 高效可靠 |
|
||||||
| Redis客户端 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 支持单机、集群配置 |
|
| Redis客户端 | 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) | 全局、请求IP、集群ID 多种限流 |
|
| 分布式限流 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 全局、请求IP、集群ID 多种限流 |
|
||||||
| 分布式队列 | 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) | 支持跟踪链路日志记录、性能分析、链路排查 |
|
| 分布式日志 | TLog | [TLog文档](https://yomahub.com/tlog/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) | 云存储 |
|
||||||
| 短信模块 | 阿里、腾讯 | [短信使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5578491&doc_id=1469725) | 短信发送 |
|
|
||||||
| 监控框架 | 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) | 性能优异 扩展性强 |
|
||||||
@ -78,8 +74,8 @@
|
|||||||
|
|
||||||
* 同步升级 RuoYi-Vue
|
* 同步升级 RuoYi-Vue
|
||||||
* GitHub 地址 [RuoYi-Vue-Plus-github](https://github.com/JavaLionLi/RuoYi-Vue-Plus)
|
* GitHub 地址 [RuoYi-Vue-Plus-github](https://github.com/JavaLionLi/RuoYi-Vue-Plus)
|
||||||
* 单模块 分支 [RuoYi-Vue-Plus-fast](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/)
|
* 单模块 fast 分支 [RuoYi-Vue-Plus-fast](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/)
|
||||||
* 微服务 分支 [RuoYi-Cloud-Plus](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus)
|
* satoken 分支 [RuoYi-Vue-Plus-satoken](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/)
|
||||||
* 用户扩展项目 [扩展项目列表](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4478302&doc_id=1469725)
|
* 用户扩展项目 [扩展项目列表](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4478302&doc_id=1469725)
|
||||||
|
|
||||||
## 加群与捐献
|
## 加群与捐献
|
||||||
@ -88,7 +84,7 @@
|
|||||||
|
|
||||||
## 捐献作者
|
## 捐献作者
|
||||||
作者为兼职做开源,平时还需要工作,如果帮到了您可以请作者吃个盒饭
|
作者为兼职做开源,平时还需要工作,如果帮到了您可以请作者吃个盒饭
|
||||||
<img src="https://images.gitee.com/uploads/images/2022/0218/213734_b1b8197f_1766278.jpeg" width="300px" height="450px" />
|
<img src="https://images.gitee.com/uploads/images/2021/0525/101654_451e4523_1766278.jpeg" width="300px" height="450px" />
|
||||||
<img src="https://images.gitee.com/uploads/images/2021/0525/101713_3d18b119_1766278.jpeg" width="300px" height="450px" />
|
<img src="https://images.gitee.com/uploads/images/2021/0525/101713_3d18b119_1766278.jpeg" width="300px" height="450px" />
|
||||||
|
|
||||||
## 业务功能
|
## 业务功能
|
||||||
|
176
pom.xml
176
pom.xml
@ -6,46 +6,45 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<version>4.2.0</version>
|
<version>3.5.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>3.5.0</ruoyi-vue-plus.version>
|
||||||
<spring-boot.version>2.6.9</spring-boot.version>
|
<spring-boot.version>2.5.8</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.0</maven-jar-plugin.version>
|
||||||
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
|
<druid.version>1.2.8</druid.version>
|
||||||
<druid.version>1.2.11</druid.version>
|
|
||||||
<knife4j.version>3.0.3</knife4j.version>
|
<knife4j.version>3.0.3</knife4j.version>
|
||||||
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
||||||
<poi.version>5.2.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<easyexcel.version>3.1.1</easyexcel.version>
|
<easyexcel.version>2.2.11</easyexcel.version>
|
||||||
|
<cglib.version>3.3.0</cglib.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<satoken.version>1.30.0</satoken.version>
|
<mybatis-plus.version>3.4.3.4</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.7.18</hutool.version>
|
||||||
<okhttp.version>4.9.3</okhttp.version>
|
<okhttp.version>4.9.2</okhttp.version>
|
||||||
<spring-boot-admin.version>2.6.7</spring-boot-admin.version>
|
<spring-boot-admin.version>2.5.5</spring-boot-admin.version>
|
||||||
<redisson.version>3.17.4</redisson.version>
|
<redisson.version>3.16.7</redisson.version>
|
||||||
<lock4j.version>2.2.1</lock4j.version>
|
<lock4j.version>2.2.1</lock4j.version>
|
||||||
<dynamic-ds.version>3.5.1</dynamic-ds.version>
|
<dynamic-ds.version>3.5.0</dynamic-ds.version>
|
||||||
<tlog.version>1.4.3</tlog.version>
|
<tlog.version>1.3.6</tlog.version>
|
||||||
<xxl-job.version>2.3.1</xxl-job.version>
|
<xxl-job.version>2.3.0</xxl-job.version>
|
||||||
|
|
||||||
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
<!-- jdk11 缺失依赖 jaxb-->
|
||||||
<guava.version>30.0-jre</guava.version>
|
<jaxb.version>3.0.1</jaxb.version>
|
||||||
|
|
||||||
<!-- OSS 配置 -->
|
<!-- OSS 配置 -->
|
||||||
<aws-java-sdk-s3.version>1.12.248</aws-java-sdk-s3.version>
|
<qiniu.version>7.9.0</qiniu.version>
|
||||||
<!-- SMS 配置 -->
|
<aliyun.oss.version>3.13.1</aliyun.oss.version>
|
||||||
<aliyun.sms.version>2.0.9</aliyun.sms.version>
|
<qcloud.cos.version>5.6.58</qcloud.cos.version>
|
||||||
<tencent.sms.version>3.1.537</tencent.sms.version>
|
<minio.version>8.3.4</minio.version>
|
||||||
|
|
||||||
<!-- docker 配置 -->
|
<!-- docker 配置 -->
|
||||||
<docker.registry.url>localhost</docker.registry.url>
|
<docker.registry.url>localhost</docker.registry.url>
|
||||||
@ -68,15 +67,6 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- hutool 的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-bom</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 阿里数据库连接池 -->
|
<!-- 阿里数据库连接池 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
@ -102,21 +92,22 @@
|
|||||||
<version>${swagger-annotations.version}</version>
|
<version>${swagger-annotations.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- excel工具 -->
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi</artifactId>
|
|
||||||
<version>${poi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
<version>${easyexcel.version}</version>
|
<version>${easyexcel.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml-schemas</artifactId>
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
@ -124,6 +115,12 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cglib</groupId>
|
||||||
|
<artifactId>cglib</artifactId>
|
||||||
|
<version>${cglib.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- velocity代码生成使用模板 -->
|
<!-- velocity代码生成使用模板 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
@ -131,17 +128,11 @@
|
|||||||
<version>${velocity.version}</version>
|
<version>${velocity.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
|
<!-- jdk11 缺失依赖 jaxb-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>${satoken.version}</version>
|
<version>${jaxb.version}</version>
|
||||||
</dependency>
|
|
||||||
<!-- Sa-Token 整合 jwt -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-jwt</artifactId>
|
|
||||||
<version>${satoken.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- dynamic-datasource 多数据源-->
|
<!-- dynamic-datasource 多数据源-->
|
||||||
@ -168,30 +159,42 @@
|
|||||||
<version>${p6spy.version}</version>
|
<version>${p6spy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-core</artifactId>
|
||||||
|
<version>${hutool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-http</artifactId>
|
||||||
|
<version>${hutool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-captcha</artifactId>
|
||||||
|
<version>${hutool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-extra</artifactId>
|
||||||
|
<version>${hutool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-jwt</artifactId>
|
||||||
|
<version>${hutool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>${okhttp.version}</version>
|
<version>${okhttp.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.amazonaws</groupId>
|
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
|
||||||
<version>${aws-java-sdk-s3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>dysmsapi20170525</artifactId>
|
|
||||||
<version>${aliyun.sms.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tencentcloudapi</groupId>
|
|
||||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
|
||||||
<version>${tencent.sms.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.codecentric</groupId>
|
<groupId>de.codecentric</groupId>
|
||||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||||
@ -226,20 +229,6 @@
|
|||||||
<groupId>com.yomahub</groupId>
|
<groupId>com.yomahub</groupId>
|
||||||
<artifactId>tlog-web-spring-boot-starter</artifactId>
|
<artifactId>tlog-web-spring-boot-starter</artifactId>
|
||||||
<version>${tlog.version}</version>
|
<version>${tlog.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>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -248,13 +237,6 @@
|
|||||||
<version>${tlog.version}</version>
|
<version>${tlog.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>${guava.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 定时任务 -->
|
<!-- 定时任务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -297,13 +279,6 @@
|
|||||||
<version>${ruoyi-vue-plus.version}</version>
|
<version>${ruoyi-vue-plus.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SMS短信模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-sms</artifactId>
|
|
||||||
<version>${ruoyi-vue-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- demo模块 -->
|
<!-- demo模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -324,7 +299,6 @@
|
|||||||
<module>ruoyi-demo</module>
|
<module>ruoyi-demo</module>
|
||||||
<module>ruoyi-extend</module>
|
<module>ruoyi-extend</module>
|
||||||
<module>ruoyi-oss</module>
|
<module>ruoyi-oss</module>
|
||||||
<module>ruoyi-sms</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
@ -333,7 +307,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.9.0</version>
|
<version>3.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
@ -343,18 +317,8 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
<!--打包该目录下的 application.yml -->
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<!-- 关闭过滤 -->
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<!-- 引入所有 匹配文件进行过滤 -->
|
|
||||||
<includes>
|
|
||||||
<include>application*</include>
|
|
||||||
<include>bootstrap*</include>
|
|
||||||
<include>banner*</include>
|
|
||||||
</includes>
|
|
||||||
<!-- 启用过滤 即该资源中的变量将会被过滤器中的值替换 -->
|
<!-- 启用过滤 即该资源中的变量将会被过滤器中的值替换 -->
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
|
@ -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>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
@ -29,21 +29,6 @@
|
|||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Oracle -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.oracle.database.jdbc</groupId>
|
|
||||||
<artifactId>ojdbc8</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- PostgreSql -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.postgresql</groupId>
|
|
||||||
<artifactId>postgresql</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- SqlServer -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.microsoft.sqlserver</groupId>
|
|
||||||
<artifactId>mssql-jdbc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -101,7 +86,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<warName>${project.artifactId}</warName>
|
<warName>${project.artifactId}</warName>
|
||||||
|
@ -4,89 +4,50 @@ 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 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.AjaxResult;
|
||||||
import com.ruoyi.common.enums.CaptchaType;
|
import com.ruoyi.common.enums.CaptchaType;
|
||||||
|
import com.ruoyi.common.utils.RedisUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.framework.config.properties.CaptchaProperties;
|
import com.ruoyi.framework.config.properties.CaptchaProperties;
|
||||||
import com.ruoyi.sms.config.properties.SmsProperties;
|
|
||||||
import com.ruoyi.sms.core.SmsTemplate;
|
|
||||||
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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
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;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码操作处理
|
* 验证码操作处理
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
|
||||||
@Slf4j
|
|
||||||
@Validated
|
|
||||||
@Api(value = "验证码操作处理", tags = {"验证码管理"})
|
@Api(value = "验证码操作处理", tags = {"验证码管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
public class CaptchaController {
|
public class CaptchaController {
|
||||||
|
|
||||||
private final CaptchaProperties captchaProperties;
|
private final CaptchaProperties captchaProperties;
|
||||||
private final SmsProperties smsProperties;
|
|
||||||
private final ISysConfigService configService;
|
private final ISysConfigService configService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信验证码
|
|
||||||
*/
|
|
||||||
@ApiOperation("短信验证码")
|
|
||||||
@GetMapping("/captchaSms")
|
|
||||||
public R<Void> smsCaptcha(@ApiParam("用户手机号")
|
|
||||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
|
||||||
String phonenumber) {
|
|
||||||
if (smsProperties.getEnabled()) {
|
|
||||||
R.fail("当前系统没有开启短信功能!");
|
|
||||||
}
|
|
||||||
String key = Constants.CAPTCHA_CODE_KEY + phonenumber;
|
|
||||||
String code = RandomUtil.randomNumbers(4);
|
|
||||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
|
||||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
|
||||||
String templateId = "";
|
|
||||||
Map<String, String> map = new HashMap<>(1);
|
|
||||||
map.put("code", code);
|
|
||||||
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
|
||||||
SmsResult result = smsTemplate.send(phonenumber, templateId, map);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
log.error("验证码短信发送异常 => {}", result);
|
|
||||||
return R.fail(result.getMessage());
|
|
||||||
}
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@ApiOperation("生成验证码")
|
@ApiOperation("生成验证码")
|
||||||
@GetMapping("/captchaImage")
|
@GetMapping("/captchaImage")
|
||||||
public R<Map<String, Object>> getCode() {
|
public AjaxResult<Map<String, Object>> getCode() {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||||
ajax.put("captchaOnOff", captchaOnOff);
|
ajax.put("captchaOnOff", captchaOnOff);
|
||||||
if (!captchaOnOff) {
|
if (!captchaOnOff) {
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtil.simpleUUID();
|
String uuid = IdUtil.simpleUUID();
|
||||||
@ -100,10 +61,10 @@ public class CaptchaController {
|
|||||||
captcha.setGenerator(codeGenerator);
|
captcha.setGenerator(codeGenerator);
|
||||||
captcha.createCode();
|
captcha.createCode();
|
||||||
String code = isMath ? getCodeResult(captcha.getCode()) : captcha.getCode();
|
String code = isMath ? getCodeResult(captcha.getCode()) : captcha.getCode();
|
||||||
RedisUtils.setCacheObject(verifyKey, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
RedisUtils.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid", uuid);
|
||||||
ajax.put("img", captcha.getImageBase64());
|
ajax.put("img", captcha.getImageBase64());
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCodeResult(String capStr) {
|
private String getCodeResult(String capStr) {
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||||
import org.springframework.data.redis.core.RedisCallback;
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -21,7 +22,7 @@ import java.util.*;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "缓存监控", tags = {"缓存监控管理"})
|
@Api(value = "缓存监控", tags = {"缓存监控管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/cache")
|
@RequestMapping("/monitor/cache")
|
||||||
public class CacheController {
|
public class CacheController {
|
||||||
@ -29,9 +30,9 @@ public class CacheController {
|
|||||||
private final RedisTemplate<String, String> redisTemplate;
|
private final RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
@ApiOperation("获取缓存监控详细信息")
|
@ApiOperation("获取缓存监控详细信息")
|
||||||
@SaCheckPermission("monitor:cache:list")
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public R<Map<String, Object>> getInfo() throws Exception {
|
public AjaxResult<Map<String, Object>> getInfo() throws Exception {
|
||||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info);
|
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info);
|
||||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize);
|
Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize);
|
||||||
@ -51,6 +52,6 @@ public class CacheController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
result.put("commandStats", pieList);
|
result.put("commandStats", pieList);
|
||||||
return R.ok(result);
|
return AjaxResult.success(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -13,6 +12,8 @@ import com.ruoyi.system.service.ISysLogininforService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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,7 +27,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "系统访问记录", tags = {"系统访问记录管理"})
|
@Api(value = "系统访问记录", tags = {"系统访问记录管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/logininfor")
|
@RequestMapping("/monitor/logininfor")
|
||||||
public class SysLogininforController extends BaseController {
|
public class SysLogininforController extends BaseController {
|
||||||
@ -34,7 +35,7 @@ public class SysLogininforController extends BaseController {
|
|||||||
private final ISysLogininforService logininforService;
|
private final ISysLogininforService logininforService;
|
||||||
|
|
||||||
@ApiOperation("查询系统访问记录列表")
|
@ApiOperation("查询系统访问记录列表")
|
||||||
@SaCheckPermission("monitor:logininfor:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -42,7 +43,7 @@ public class SysLogininforController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出系统访问记录列表")
|
@ApiOperation("导出系统访问记录列表")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("monitor:logininfor:export")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysLogininfor logininfor, HttpServletResponse response) {
|
public void export(SysLogininfor logininfor, HttpServletResponse response) {
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
@ -50,19 +51,19 @@ public class SysLogininforController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除系统访问记录")
|
@ApiOperation("删除系统访问记录")
|
||||||
@SaCheckPermission("monitor:logininfor:remove")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{infoIds}")
|
@DeleteMapping("/{infoIds}")
|
||||||
public R<Void> remove(@PathVariable Long[] infoIds) {
|
public AjaxResult<Void> remove(@PathVariable Long[] infoIds) {
|
||||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("清空系统访问记录")
|
@ApiOperation("清空系统访问记录")
|
||||||
@SaCheckPermission("monitor:logininfor:remove")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public R<Void> clean() {
|
public AjaxResult<Void> clean() {
|
||||||
logininforService.cleanLogininfor();
|
logininforService.cleanLogininfor();
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -13,6 +12,8 @@ import com.ruoyi.system.service.ISysOperLogService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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,7 +27,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "操作日志记录", tags = {"操作日志记录管理"})
|
@Api(value = "操作日志记录", tags = {"操作日志记录管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/operlog")
|
@RequestMapping("/monitor/operlog")
|
||||||
public class SysOperlogController extends BaseController {
|
public class SysOperlogController extends BaseController {
|
||||||
@ -34,7 +35,7 @@ public class SysOperlogController extends BaseController {
|
|||||||
private final ISysOperLogService operLogService;
|
private final ISysOperLogService operLogService;
|
||||||
|
|
||||||
@ApiOperation("查询操作日志记录列表")
|
@ApiOperation("查询操作日志记录列表")
|
||||||
@SaCheckPermission("monitor:operlog:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -42,7 +43,7 @@ public class SysOperlogController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出操作日志记录列表")
|
@ApiOperation("导出操作日志记录列表")
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("monitor:operlog:export")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysOperLog operLog, HttpServletResponse response) {
|
public void export(SysOperLog operLog, HttpServletResponse response) {
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
@ -51,18 +52,18 @@ public class SysOperlogController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("删除操作日志记录")
|
@ApiOperation("删除操作日志记录")
|
||||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
@SaCheckPermission("monitor:operlog:remove")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
@DeleteMapping("/{operIds}")
|
@DeleteMapping("/{operIds}")
|
||||||
public R<Void> remove(@PathVariable Long[] operIds) {
|
public AjaxResult<Void> remove(@PathVariable Long[] operIds) {
|
||||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("清空操作日志记录")
|
@ApiOperation("清空操作日志记录")
|
||||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||||
@SaCheckPermission("monitor:operlog:remove")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public R<Void> clean() {
|
public AjaxResult<Void> clean() {
|
||||||
operLogService.cleanOperLog();
|
operLogService.cleanOperLog();
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,27 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
import cn.dev33.satoken.exception.NotLoginException;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
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.Constants;
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.dto.UserOnlineDTO;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
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.RedisUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.system.domain.SysUserOnline;
|
import com.ruoyi.system.domain.SysUserOnline;
|
||||||
|
import com.ruoyi.system.service.ISysUserOnlineService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户监控
|
* 在线用户监控
|
||||||
@ -30,43 +29,39 @@ import java.util.stream.Collectors;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "在线用户监控", tags = {"在线用户监控管理"})
|
@Api(value = "在线用户监控", tags = {"在线用户监控管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/online")
|
@RequestMapping("/monitor/online")
|
||||||
public class SysUserOnlineController extends BaseController {
|
public class SysUserOnlineController extends BaseController {
|
||||||
|
|
||||||
|
private final ISysUserOnlineService userOnlineService;
|
||||||
|
|
||||||
@ApiOperation("在线用户列表")
|
@ApiOperation("在线用户列表")
|
||||||
@SaCheckPermission("monitor:online:list")
|
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
||||||
// 获取所有未过期的 token
|
Collection<String> keys = RedisUtils.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
||||||
List<String> keys = StpUtil.searchTokenValue("", -1, 0);
|
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||||
List<UserOnlineDTO> userOnlineDTOList = new ArrayList<>();
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
String token = key.replace(Constants.LOGIN_TOKEN_KEY, "");
|
LoginUser user = RedisUtils.getCacheObject(key);
|
||||||
// 如果已经过期则踢下线
|
|
||||||
if (StpUtil.stpLogic.getTokenActivityTimeoutByToken(token) < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
userOnlineDTOList.add(RedisUtils.getCacheObject(Constants.ONLINE_TOKEN_KEY + token));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||||
userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline ->
|
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||||
StringUtils.equals(ipaddr, userOnline.getIpaddr()) &&
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||||
StringUtils.equals(userName, userOnline.getUserName())
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
|
||||||
userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline ->
|
|
||||||
StringUtils.equals(ipaddr, userOnline.getIpaddr()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else if (StringUtils.isNotEmpty(userName)) {
|
|
||||||
userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline ->
|
|
||||||
StringUtils.equals(userName, userOnline.getUserName())
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
Collections.reverse(userOnlineDTOList);
|
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||||
userOnlineDTOList.removeAll(Collections.singleton(null));
|
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||||
List<SysUserOnline> userOnlineList = BeanUtil.copyToList(userOnlineDTOList, SysUserOnline.class);
|
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||||
|
}
|
||||||
|
} else if (StringUtils.isNotEmpty(userName)) {
|
||||||
|
if (StringUtils.equals(userName, user.getUsername())) {
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.reverse(userOnlineList);
|
||||||
|
userOnlineList.removeAll(Collections.singleton(null));
|
||||||
return TableDataInfo.build(userOnlineList);
|
return TableDataInfo.build(userOnlineList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,14 +69,11 @@ public class SysUserOnlineController extends BaseController {
|
|||||||
* 强退用户
|
* 强退用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("强退用户")
|
@ApiOperation("强退用户")
|
||||||
@SaCheckPermission("monitor:online:forceLogout")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> forceLogout(@PathVariable String tokenId) {
|
||||||
try {
|
RedisUtils.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
StpUtil.kickoutByTokenValue(tokenId);
|
return AjaxResult.success();
|
||||||
} catch (NotLoginException e) {
|
|
||||||
}
|
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -15,6 +14,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "参数配置控制器", tags = {"参数配置管理"})
|
@Api(value = "参数配置控制器", tags = {"参数配置管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/config")
|
@RequestMapping("/system/config")
|
||||||
public class SysConfigController extends BaseController {
|
public class SysConfigController extends BaseController {
|
||||||
@ -39,7 +40,7 @@ public class SysConfigController extends BaseController {
|
|||||||
* 获取参数配置列表
|
* 获取参数配置列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取参数配置列表")
|
@ApiOperation("获取参数配置列表")
|
||||||
@SaCheckPermission("system:config:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -47,7 +48,7 @@ public class SysConfigController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出参数配置列表")
|
@ApiOperation("导出参数配置列表")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:config:export")
|
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysConfig config, HttpServletResponse response) {
|
public void export(SysConfig config, HttpServletResponse response) {
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
@ -58,10 +59,10 @@ public class SysConfigController extends BaseController {
|
|||||||
* 根据参数编号获取详细信息
|
* 根据参数编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据参数编号获取详细信息")
|
@ApiOperation("根据参数编号获取详细信息")
|
||||||
@SaCheckPermission("system:config:query")
|
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public R<SysConfig> getInfo(@ApiParam("参数ID") @PathVariable Long configId) {
|
public AjaxResult<SysConfig> getInfo(@ApiParam("参数ID") @PathVariable Long configId) {
|
||||||
return R.ok(configService.selectConfigById(configId));
|
return AjaxResult.success(configService.selectConfigById(configId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,20 +70,20 @@ public class SysConfigController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("根据参数键名查询参数值")
|
@ApiOperation("根据参数键名查询参数值")
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
public R<Void> getConfigKey(@ApiParam("参数Key") @PathVariable String configKey) {
|
public AjaxResult<Void> getConfigKey(@ApiParam("参数Key") @PathVariable String configKey) {
|
||||||
return R.ok(configService.selectConfigByKey(configKey));
|
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增参数配置")
|
@ApiOperation("新增参数配置")
|
||||||
@SaCheckPermission("system:config:add")
|
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysConfig config) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysConfig config) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
return toAjax(configService.insertConfig(config));
|
return toAjax(configService.insertConfig(config));
|
||||||
}
|
}
|
||||||
@ -91,48 +92,37 @@ public class SysConfigController extends BaseController {
|
|||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改参数配置")
|
@ApiOperation("修改参数配置")
|
||||||
@SaCheckPermission("system:config:edit")
|
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysConfig config) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysConfig config) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
return toAjax(configService.updateConfig(config));
|
return toAjax(configService.updateConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据参数键名修改参数配置
|
|
||||||
*/
|
|
||||||
@ApiOperation("根据参数键名修改参数配置")
|
|
||||||
@SaCheckPermission("system:config:edit")
|
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping("/updateByKey")
|
|
||||||
public R<Void> updateByKey(@RequestBody SysConfig config) {
|
|
||||||
return toAjax(configService.updateConfig(config));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除参数配置
|
* 删除参数配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除参数配置")
|
@ApiOperation("删除参数配置")
|
||||||
@SaCheckPermission("system:config:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("参数ID串") @PathVariable Long[] configIds) {
|
||||||
configService.deleteConfigByIds(configIds);
|
configService.deleteConfigByIds(configIds);
|
||||||
return R.ok();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新参数缓存
|
* 刷新参数缓存
|
||||||
*/
|
*/
|
||||||
@ApiOperation("刷新参数缓存")
|
@ApiOperation("刷新参数缓存")
|
||||||
@SaCheckPermission("system:config:remove")
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
public R<Void> refreshCache() {
|
public AjaxResult<Void> refreshCache() {
|
||||||
configService.resetConfigCache();
|
configService.resetConfigCache();
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
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;
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
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;
|
||||||
@ -15,6 +14,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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 +30,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "部门控制器", tags = {"部门管理"})
|
@Api(value = "部门控制器", tags = {"部门管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
public class SysDeptController extends BaseController {
|
public class SysDeptController extends BaseController {
|
||||||
@ -40,35 +41,35 @@ public class SysDeptController extends BaseController {
|
|||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取部门列表")
|
@ApiOperation("获取部门列表")
|
||||||
@SaCheckPermission("system:dept:list")
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<SysDept>> list(SysDept dept) {
|
public AjaxResult<List<SysDept>> list(SysDept dept) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return R.ok(depts);
|
return AjaxResult.success(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门列表(排除节点)
|
* 查询部门列表(排除节点)
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询部门列表(排除节点)")
|
@ApiOperation("查询部门列表(排除节点)")
|
||||||
@SaCheckPermission("system:dept:list")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<List<SysDept>> excludeChild(@ApiParam("部门ID") @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 + ""));
|
||||||
return R.ok(depts);
|
return AjaxResult.success(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门编号获取详细信息
|
* 根据部门编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据部门编号获取详细信息")
|
@ApiOperation("根据部门编号获取详细信息")
|
||||||
@SaCheckPermission("system:dept:query")
|
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public R<SysDept> getInfo(@ApiParam("部门ID") @PathVariable Long deptId) {
|
public AjaxResult<SysDept> getInfo(@ApiParam("部门ID") @PathVariable Long deptId) {
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return R.ok(deptService.selectDeptById(deptId));
|
return AjaxResult.success(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,9 +77,9 @@ public class SysDeptController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("获取部门下拉树列表")
|
@ApiOperation("获取部门下拉树列表")
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public R<List<Tree<Long>>> treeselect(SysDept dept) {
|
public AjaxResult<List<Tree<Long>>> treeselect(SysDept dept) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return R.ok(deptService.buildDeptTreeSelect(depts));
|
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,24 +87,24 @@ public class SysDeptController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("加载对应角色部门列表树")
|
@ApiOperation("加载对应角色部门列表树")
|
||||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||||
public R<Map<String, Object>> roleDeptTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
|
public AjaxResult<Map<String, Object>> roleDeptTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增部门")
|
@ApiOperation("新增部门")
|
||||||
@SaCheckPermission("system:dept:add")
|
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysDept dept) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysDept dept) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||||
return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
return toAjax(deptService.insertDept(dept));
|
return toAjax(deptService.insertDept(dept));
|
||||||
}
|
}
|
||||||
@ -112,19 +113,17 @@ public class SysDeptController extends BaseController {
|
|||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改部门")
|
@ApiOperation("修改部门")
|
||||||
@SaCheckPermission("system:dept:edit")
|
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysDept dept) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysDept dept) {
|
||||||
Long deptId = dept.getDeptId();
|
|
||||||
deptService.checkDeptDataScope(deptId);
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||||
return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
} else if (dept.getParentId().equals(deptId)) {
|
} else if (dept.getParentId().equals(dept.getDeptId())) {
|
||||||
return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||||
&& deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
|
||||||
return R.fail("该部门包含未停用的子部门!");
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
return toAjax(deptService.updateDept(dept));
|
return toAjax(deptService.updateDept(dept));
|
||||||
}
|
}
|
||||||
@ -133,17 +132,16 @@ public class SysDeptController extends BaseController {
|
|||||||
* 删除部门
|
* 删除部门
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除部门")
|
@ApiOperation("删除部门")
|
||||||
@SaCheckPermission("system:dept:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("部门ID串") @PathVariable Long deptId) {
|
||||||
if (deptService.hasChildByDeptId(deptId)) {
|
if (deptService.hasChildByDeptId(deptId)) {
|
||||||
return R.fail("存在下级部门,不允许删除");
|
return AjaxResult.error("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId)) {
|
if (deptService.checkDeptExistUser(deptId)) {
|
||||||
return R.fail("部门存在用户,不允许删除");
|
return AjaxResult.error("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
deptService.checkDeptDataScope(deptId);
|
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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.StringUtils;
|
||||||
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;
|
||||||
@ -16,6 +15,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/data")
|
@RequestMapping("/system/dict/data")
|
||||||
public class SysDictDataController extends BaseController {
|
public class SysDictDataController extends BaseController {
|
||||||
@ -39,7 +40,7 @@ public class SysDictDataController extends BaseController {
|
|||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@ApiOperation("查询字典数据列表")
|
@ApiOperation("查询字典数据列表")
|
||||||
@SaCheckPermission("system:dict:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -47,7 +48,7 @@ public class SysDictDataController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出字典数据列表")
|
@ApiOperation("导出字典数据列表")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:dict:export")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysDictData dictData, HttpServletResponse response) {
|
public void export(SysDictData dictData, HttpServletResponse response) {
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
@ -58,10 +59,10 @@ public class SysDictDataController extends BaseController {
|
|||||||
* 查询字典数据详细
|
* 查询字典数据详细
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询字典数据详细")
|
@ApiOperation("查询字典数据详细")
|
||||||
@SaCheckPermission("system:dict:query")
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
@GetMapping(value = "/{dictCode}")
|
@GetMapping(value = "/{dictCode}")
|
||||||
public R<SysDictData> getInfo(@ApiParam("字典code") @PathVariable Long dictCode) {
|
public AjaxResult<SysDictData> getInfo(@ApiParam("字典code") @PathVariable Long dictCode) {
|
||||||
return R.ok(dictDataService.selectDictDataById(dictCode));
|
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,22 +70,22 @@ public class SysDictDataController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("根据字典类型查询字典数据信息")
|
@ApiOperation("根据字典类型查询字典数据信息")
|
||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public R<List<SysDictData>> dictType(@ApiParam("字典类型") @PathVariable String dictType) {
|
public AjaxResult<List<SysDictData>> dictType(@ApiParam("字典类型") @PathVariable String dictType) {
|
||||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
if (ObjectUtil.isNull(data)) {
|
if (StringUtils.isNull(data)) {
|
||||||
data = new ArrayList<>();
|
data = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return R.ok(data);
|
return AjaxResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增字典类型")
|
@ApiOperation("新增字典类型")
|
||||||
@SaCheckPermission("system:dict:add")
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysDictData dict) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysDictData dict) {
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,10 +93,10 @@ public class SysDictDataController extends BaseController {
|
|||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改保存字典类型")
|
@ApiOperation("修改保存字典类型")
|
||||||
@SaCheckPermission("system:dict:edit")
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysDictData dict) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysDictData dict) {
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +104,11 @@ public class SysDictDataController extends BaseController {
|
|||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除字典类型")
|
@ApiOperation("删除字典类型")
|
||||||
@SaCheckPermission("system:dict:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("字典code串") @PathVariable Long[] dictCodes) {
|
||||||
dictDataService.deleteDictDataByIds(dictCodes);
|
dictDataService.deleteDictDataByIds(dictCodes);
|
||||||
return R.ok();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -15,6 +14,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/type")
|
@RequestMapping("/system/dict/type")
|
||||||
public class SysDictTypeController extends BaseController {
|
public class SysDictTypeController extends BaseController {
|
||||||
@ -36,7 +37,7 @@ public class SysDictTypeController extends BaseController {
|
|||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@ApiOperation("查询字典类型列表")
|
@ApiOperation("查询字典类型列表")
|
||||||
@SaCheckPermission("system:dict:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -44,7 +45,7 @@ public class SysDictTypeController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出字典类型列表")
|
@ApiOperation("导出字典类型列表")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:dict:export")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysDictType dictType, HttpServletResponse response) {
|
public void export(SysDictType dictType, HttpServletResponse response) {
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
@ -55,22 +56,22 @@ public class SysDictTypeController extends BaseController {
|
|||||||
* 查询字典类型详细
|
* 查询字典类型详细
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询字典类型详细")
|
@ApiOperation("查询字典类型详细")
|
||||||
@SaCheckPermission("system:dict:query")
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
@GetMapping(value = "/{dictId}")
|
@GetMapping(value = "/{dictId}")
|
||||||
public R<SysDictType> getInfo(@ApiParam("字典ID") @PathVariable Long dictId) {
|
public AjaxResult<SysDictType> getInfo(@ApiParam("字典ID") @PathVariable Long dictId) {
|
||||||
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增字典类型")
|
@ApiOperation("新增字典类型")
|
||||||
@SaCheckPermission("system:dict:add")
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysDictType dict) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysDictType dict) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
return toAjax(dictTypeService.insertDictType(dict));
|
return toAjax(dictTypeService.insertDictType(dict));
|
||||||
}
|
}
|
||||||
@ -79,12 +80,12 @@ public class SysDictTypeController extends BaseController {
|
|||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改字典类型")
|
@ApiOperation("修改字典类型")
|
||||||
@SaCheckPermission("system:dict:edit")
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysDictType dict) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysDictType dict) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
return toAjax(dictTypeService.updateDictType(dict));
|
return toAjax(dictTypeService.updateDictType(dict));
|
||||||
}
|
}
|
||||||
@ -93,24 +94,24 @@ public class SysDictTypeController extends BaseController {
|
|||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除字典类型")
|
@ApiOperation("删除字典类型")
|
||||||
@SaCheckPermission("system:dict:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("字典ID串") @PathVariable Long[] dictIds) {
|
||||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||||
return R.ok();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新字典缓存
|
* 刷新字典缓存
|
||||||
*/
|
*/
|
||||||
@ApiOperation("刷新字典缓存")
|
@ApiOperation("刷新字典缓存")
|
||||||
@SaCheckPermission("system:dict:remove")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
public R<Void> refreshCache() {
|
public AjaxResult<Void> refreshCache() {
|
||||||
dictTypeService.resetDictCache();
|
dictTypeService.resetDictCache();
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,8 +119,8 @@ public class SysDictTypeController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("获取字典选择框列表")
|
@ApiOperation("获取字典选择框列表")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysDictType>> optionselect() {
|
public AjaxResult<List<SysDictType>> optionselect() {
|
||||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
return R.ok(dictTypes);
|
return AjaxResult.success(dictTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Api(value = "首页控制器", tags = {"首页管理"})
|
@Api(value = "首页控制器", tags = {"首页管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
public class SysIndexController {
|
public class SysIndexController {
|
||||||
|
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.exception.NotLoginException;
|
|
||||||
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.AjaxResult;
|
||||||
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.SmsLoginBody;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
|
||||||
import com.ruoyi.system.domain.vo.RouterVo;
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
@ -18,13 +14,13 @@ import com.ruoyi.system.service.SysPermissionService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
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;
|
||||||
@ -37,7 +33,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "登录验证控制器", tags = {"登录验证管理"})
|
@Api(value = "登录验证控制器", tags = {"登录验证管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
public class SysLoginController {
|
public class SysLoginController {
|
||||||
|
|
||||||
@ -52,63 +48,15 @@ public class SysLoginController {
|
|||||||
* @param loginBody 登录信息
|
* @param loginBody 登录信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
|
||||||
@ApiOperation("登录方法")
|
@ApiOperation("登录方法")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
|
public AjaxResult<Map<String, Object>> login(@RequestBody LoginBody loginBody) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||||
loginBody.getUuid());
|
loginBody.getUuid());
|
||||||
ajax.put(Constants.TOKEN, token);
|
ajax.put(Constants.TOKEN, token);
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信登录(示例)
|
|
||||||
*
|
|
||||||
* @param smsLoginBody 登录信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Anonymous
|
|
||||||
@ApiOperation("短信登录(示例)")
|
|
||||||
@PostMapping("/smsLogin")
|
|
||||||
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
|
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
|
||||||
// 生成令牌
|
|
||||||
String token = loginService.smsLogin(smsLoginBody.getPhonenumber(), smsLoginBody.getSmsCode());
|
|
||||||
ajax.put(Constants.TOKEN, token);
|
|
||||||
return R.ok(ajax);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序登录(示例)
|
|
||||||
*
|
|
||||||
* @param xcxCode 小程序code
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Anonymous
|
|
||||||
@ApiOperation("小程序登录(示例)")
|
|
||||||
@PostMapping("/xcxLogin")
|
|
||||||
public R<Map<String, Object>> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
|
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
|
||||||
// 生成令牌
|
|
||||||
String token = loginService.xcxLogin(xcxCode);
|
|
||||||
ajax.put(Constants.TOKEN, token);
|
|
||||||
return R.ok(ajax);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Anonymous
|
|
||||||
@ApiOperation("登出方法")
|
|
||||||
@PostMapping("/logout")
|
|
||||||
public R<Void> logout() {
|
|
||||||
try {
|
|
||||||
String username = LoginHelper.getUsername();
|
|
||||||
StpUtil.logout();
|
|
||||||
loginService.logout(username);
|
|
||||||
} catch (NotLoginException e) {
|
|
||||||
}
|
|
||||||
return R.ok("退出成功");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,8 +66,8 @@ public class SysLoginController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("获取用户信息")
|
@ApiOperation("获取用户信息")
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public R<Map<String, Object>> getInfo() {
|
public AjaxResult<Map<String, Object>> getInfo() {
|
||||||
SysUser user = userService.selectUserById(LoginHelper.getUserId());
|
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
|
||||||
// 角色集合
|
// 角色集合
|
||||||
Set<String> roles = permissionService.getRolePermission(user);
|
Set<String> roles = permissionService.getRolePermission(user);
|
||||||
// 权限集合
|
// 权限集合
|
||||||
@ -128,7 +76,7 @@ public class SysLoginController {
|
|||||||
ajax.put("user", user);
|
ajax.put("user", user);
|
||||||
ajax.put("roles", roles);
|
ajax.put("roles", roles);
|
||||||
ajax.put("permissions", permissions);
|
ajax.put("permissions", permissions);
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,9 +86,9 @@ public class SysLoginController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("获取路由信息")
|
@ApiOperation("获取路由信息")
|
||||||
@GetMapping("getRouters")
|
@GetMapping("getRouters")
|
||||||
public R<List<RouterVo>> getRouters() {
|
public AjaxResult<List<RouterVo>> getRouters() {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||||
return R.ok(menuService.buildMenus(menus));
|
return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
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;
|
||||||
@ -14,6 +13,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "菜单信息控制器", tags = {"菜单信息管理"})
|
@Api(value = "菜单信息控制器", tags = {"菜单信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/menu")
|
@RequestMapping("/system/menu")
|
||||||
public class SysMenuController extends BaseController {
|
public class SysMenuController extends BaseController {
|
||||||
@ -39,21 +40,21 @@ public class SysMenuController extends BaseController {
|
|||||||
* 获取菜单列表
|
* 获取菜单列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取菜单列表")
|
@ApiOperation("获取菜单列表")
|
||||||
@SaCheckPermission("system:menu:list")
|
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<SysMenu>> list(SysMenu menu) {
|
public AjaxResult<List<SysMenu>> list(SysMenu menu) {
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
return R.ok(menus);
|
return AjaxResult.success(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单编号获取详细信息
|
* 根据菜单编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据菜单编号获取详细信息")
|
@ApiOperation("根据菜单编号获取详细信息")
|
||||||
@SaCheckPermission("system:menu:query")
|
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||||
@GetMapping(value = "/{menuId}")
|
@GetMapping(value = "/{menuId}")
|
||||||
public R<SysMenu> getInfo(@ApiParam("菜单ID") @PathVariable Long menuId) {
|
public AjaxResult<SysMenu> getInfo(@ApiParam("菜单ID") @PathVariable Long menuId) {
|
||||||
return R.ok(menuService.selectMenuById(menuId));
|
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,9 +62,9 @@ public class SysMenuController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("获取菜单下拉树列表")
|
@ApiOperation("获取菜单下拉树列表")
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public R<List<Tree<Long>>> treeselect(SysMenu menu) {
|
public AjaxResult<List<Tree<Long>>> treeselect(SysMenu menu) {
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
return R.ok(menuService.buildMenuTreeSelect(menus));
|
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,26 +72,26 @@ public class SysMenuController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("加载对应角色菜单列表树")
|
@ApiOperation("加载对应角色菜单列表树")
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public R<Map<String, Object>> roleMenuTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
|
public AjaxResult<Map<String, Object>> roleMenuTreeselect(@ApiParam("角色ID") @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));
|
||||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增菜单
|
* 新增菜单
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增菜单")
|
@ApiOperation("新增菜单")
|
||||||
@SaCheckPermission("system:menu:add")
|
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysMenu menu) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysMenu menu) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
||||||
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.insertMenu(menu));
|
return toAjax(menuService.insertMenu(menu));
|
||||||
}
|
}
|
||||||
@ -99,16 +100,16 @@ public class SysMenuController extends BaseController {
|
|||||||
* 修改菜单
|
* 修改菜单
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改菜单")
|
@ApiOperation("修改菜单")
|
||||||
@SaCheckPermission("system:menu:edit")
|
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysMenu menu) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysMenu menu) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
||||||
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||||
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
}
|
}
|
||||||
@ -117,15 +118,15 @@ public class SysMenuController extends BaseController {
|
|||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除菜单")
|
@ApiOperation("删除菜单")
|
||||||
@SaCheckPermission("system:menu:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("菜单ID") @PathVariable("menuId") Long menuId) {
|
||||||
if (menuService.hasChildByMenuId(menuId)) {
|
if (menuService.hasChildByMenuId(menuId)) {
|
||||||
return R.fail("存在子菜单,不允许删除");
|
return AjaxResult.error("存在子菜单,不允许删除");
|
||||||
}
|
}
|
||||||
if (menuService.checkMenuExistRole(menuId)) {
|
if (menuService.checkMenuExistRole(menuId)) {
|
||||||
return R.fail("菜单已分配,不允许删除");
|
return AjaxResult.error("菜单已分配,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -13,6 +12,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "公告信息控制器", tags = {"公告信息管理"})
|
@Api(value = "公告信息控制器", tags = {"公告信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/notice")
|
@RequestMapping("/system/notice")
|
||||||
public class SysNoticeController extends BaseController {
|
public class SysNoticeController extends BaseController {
|
||||||
@ -34,7 +35,7 @@ public class SysNoticeController extends BaseController {
|
|||||||
* 获取通知公告列表
|
* 获取通知公告列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取通知公告列表")
|
@ApiOperation("获取通知公告列表")
|
||||||
@SaCheckPermission("system:notice:list")
|
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
||||||
return noticeService.selectPageNoticeList(notice, pageQuery);
|
return noticeService.selectPageNoticeList(notice, pageQuery);
|
||||||
@ -44,20 +45,20 @@ public class SysNoticeController extends BaseController {
|
|||||||
* 根据通知公告编号获取详细信息
|
* 根据通知公告编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据通知公告编号获取详细信息")
|
@ApiOperation("根据通知公告编号获取详细信息")
|
||||||
@SaCheckPermission("system:notice:query")
|
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||||
@GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/{noticeId}")
|
||||||
public R<SysNotice> getInfo(@ApiParam("公告ID") @PathVariable Long noticeId) {
|
public AjaxResult<SysNotice> getInfo(@ApiParam("公告ID") @PathVariable Long noticeId) {
|
||||||
return R.ok(noticeService.selectNoticeById(noticeId));
|
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增通知公告
|
* 新增通知公告
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增通知公告")
|
@ApiOperation("新增通知公告")
|
||||||
@SaCheckPermission("system:notice:add")
|
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysNotice notice) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysNotice notice) {
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +66,10 @@ public class SysNoticeController extends BaseController {
|
|||||||
* 修改通知公告
|
* 修改通知公告
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改通知公告")
|
@ApiOperation("修改通知公告")
|
||||||
@SaCheckPermission("system:notice:edit")
|
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysNotice notice) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysNotice notice) {
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +77,10 @@ public class SysNoticeController extends BaseController {
|
|||||||
* 删除通知公告
|
* 删除通知公告
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除通知公告")
|
@ApiOperation("删除通知公告")
|
||||||
@SaCheckPermission("system:notice:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("公告ID串") @PathVariable Long[] noticeIds) {
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -18,6 +17,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "对象存储配置控制器", tags = {"对象存储配置管理"})
|
@Api(value = "对象存储配置控制器", tags = {"对象存储配置管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/oss/config")
|
@RequestMapping("/system/oss/config")
|
||||||
public class SysOssConfigController extends BaseController {
|
public class SysOssConfigController extends BaseController {
|
||||||
@ -45,7 +46,7 @@ public class SysOssConfigController extends BaseController {
|
|||||||
* 查询对象存储配置列表
|
* 查询对象存储配置列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询对象存储配置列表")
|
@ApiOperation("查询对象存储配置列表")
|
||||||
@SaCheckPermission("system:oss:list")
|
@PreAuthorize("@ss.hasPermi('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) {
|
||||||
return iSysOssConfigService.queryPageList(bo, pageQuery);
|
return iSysOssConfigService.queryPageList(bo, pageQuery);
|
||||||
@ -55,23 +56,23 @@ public class SysOssConfigController extends BaseController {
|
|||||||
* 获取对象存储配置详细信息
|
* 获取对象存储配置详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取对象存储配置详细信息")
|
@ApiOperation("获取对象存储配置详细信息")
|
||||||
@SaCheckPermission("system:oss:query")
|
@PreAuthorize("@ss.hasPermi('system:oss:query')")
|
||||||
@GetMapping("/{ossConfigId}")
|
@GetMapping("/{ossConfigId}")
|
||||||
public R<SysOssConfigVo> getInfo(@ApiParam("OSS配置ID")
|
public AjaxResult<SysOssConfigVo> getInfo(@ApiParam("OSS配置ID")
|
||||||
@NotNull(message = "主键不能为空")
|
@NotNull(message = "主键不能为空")
|
||||||
@PathVariable("ossConfigId") Long ossConfigId) {
|
@PathVariable("ossConfigId") Integer ossConfigId) {
|
||||||
return R.ok(iSysOssConfigService.queryById(ossConfigId));
|
return AjaxResult.success(iSysOssConfigService.queryById(ossConfigId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增对象存储配置
|
* 新增对象存储配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增对象存储配置")
|
@ApiOperation("新增对象存储配置")
|
||||||
@SaCheckPermission("system:oss:add")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) {
|
||||||
return toAjax(iSysOssConfigService.insertByBo(bo) ? 1 : 0);
|
return toAjax(iSysOssConfigService.insertByBo(bo) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +80,11 @@ public class SysOssConfigController extends BaseController {
|
|||||||
* 修改对象存储配置
|
* 修改对象存储配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改对象存储配置")
|
@ApiOperation("修改对象存储配置")
|
||||||
@SaCheckPermission("system:oss:edit")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) {
|
||||||
return toAjax(iSysOssConfigService.updateByBo(bo) ? 1 : 0);
|
return toAjax(iSysOssConfigService.updateByBo(bo) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,10 +92,10 @@ public class SysOssConfigController extends BaseController {
|
|||||||
* 删除对象存储配置
|
* 删除对象存储配置
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除对象存储配置")
|
@ApiOperation("删除对象存储配置")
|
||||||
@SaCheckPermission("system:oss:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("OSS配置ID串")
|
||||||
@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) ? 1 : 0);
|
||||||
@ -104,10 +105,10 @@ public class SysOssConfigController extends BaseController {
|
|||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@ApiOperation("状态修改")
|
@ApiOperation("状态修改")
|
||||||
@SaCheckPermission("system:oss:edit")
|
@PreAuthorize("@ss.hasPermi('system:oss:edit')")
|
||||||
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
|
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public R<Void> changeStatus(@RequestBody SysOssConfigBo bo) {
|
public AjaxResult<Void> changeStatus(@RequestBody SysOssConfigBo bo) {
|
||||||
return toAjax(iSysOssConfigService.updateOssConfigStatus(bo));
|
return toAjax(iSysOssConfigService.updateOssConfigStatus(bo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,34 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.http.HttpException;
|
import cn.hutool.http.HttpException;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
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.AjaxResult;
|
||||||
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.QueryGroup;
|
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.JsonUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUtils;
|
import com.ruoyi.common.utils.file.FileUtils;
|
||||||
|
import com.ruoyi.oss.constant.OssConstant;
|
||||||
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
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.ISysConfigService;
|
||||||
import com.ruoyi.system.service.ISysOssService;
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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;
|
||||||
@ -32,7 +39,6 @@ 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;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,61 +47,49 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "对象存储控制器", tags = {"对象存储管理"})
|
@Api(value = "OSS对象存储控制器", tags = {"OSS对象存储管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/oss")
|
@RequestMapping("/system/oss")
|
||||||
public class SysOssController extends BaseController {
|
public class SysOssController extends BaseController {
|
||||||
|
|
||||||
private final ISysOssService iSysOssService;
|
private final ISysOssService iSysOssService;
|
||||||
|
private final ISysConfigService iSysConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询OSS对象存储列表
|
* 查询OSS对象存储列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询OSS对象存储列表")
|
@ApiOperation("查询OSS对象存储列表")
|
||||||
@SaCheckPermission("system:oss:list")
|
@PreAuthorize("@ss.hasPermi('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) {
|
||||||
return iSysOssService.queryPageList(bo, pageQuery);
|
return iSysOssService.queryPageList(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询OSS对象基于id串
|
|
||||||
*/
|
|
||||||
@ApiOperation("查询OSS对象基于ID")
|
|
||||||
@SaCheckPermission("system:oss:list")
|
|
||||||
@GetMapping("/listByIds/{ossIds}")
|
|
||||||
public R<List<SysOssVo>> listByIds(@ApiParam("OSS对象ID串")
|
|
||||||
@NotEmpty(message = "主键不能为空")
|
|
||||||
@PathVariable Long[] ossIds) {
|
|
||||||
List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds));
|
|
||||||
return R.ok(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传OSS对象存储
|
* 上传OSS对象存储
|
||||||
*/
|
*/
|
||||||
@ApiOperation("上传OSS对象存储")
|
@ApiOperation("上传OSS对象存储")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataTypeClass = File.class, required = true)
|
@ApiImplicitParam(name = "file", value = "文件", dataTypeClass = File.class, required = true),
|
||||||
})
|
})
|
||||||
@SaCheckPermission("system:oss:upload")
|
@PreAuthorize("@ss.hasPermi('system:oss:upload')")
|
||||||
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
|
public AjaxResult<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);
|
SysOss 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.getFileName());
|
||||||
map.put("ossId", oss.getOssId().toString());
|
return AjaxResult.success(map);
|
||||||
return R.ok(map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("下载OSS对象存储")
|
@ApiOperation("下载OSS对象存储")
|
||||||
@SaCheckPermission("system:oss:download")
|
@PreAuthorize("@ss.hasPermi('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(@ApiParam("OSS对象ID") @PathVariable Long ossId, HttpServletResponse response) throws IOException {
|
||||||
SysOss sysOss = iSysOssService.getById(ossId);
|
SysOss sysOss = iSysOssService.getById(ossId);
|
||||||
@ -122,13 +116,28 @@ public class SysOssController extends BaseController {
|
|||||||
* 删除OSS对象存储
|
* 删除OSS对象存储
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除OSS对象存储")
|
@ApiOperation("删除OSS对象存储")
|
||||||
@SaCheckPermission("system:oss:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("OSS对象ID串")
|
||||||
@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) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变更图片列表预览状态
|
||||||
|
*/
|
||||||
|
@ApiOperation("变更图片列表预览状态")
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:oss:edit')")
|
||||||
|
@Log(title = "OSS对象存储", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/changePreviewListResource")
|
||||||
|
public AjaxResult<Void> changePreviewListResource(@RequestBody String body) {
|
||||||
|
Map<String, Boolean> map = JsonUtils.parseMap(body);
|
||||||
|
SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>()
|
||||||
|
.eq(SysConfig::getConfigKey, OssConstant.PEREVIEW_LIST_RESOURCE_KEY));
|
||||||
|
config.setConfigValue(map.get("previewListResource").toString());
|
||||||
|
return toAjax(iSysConfigService.updateConfig(config));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
@ -15,6 +14,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "岗位信息控制器", tags = {"岗位信息管理"})
|
@Api(value = "岗位信息控制器", tags = {"岗位信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/post")
|
@RequestMapping("/system/post")
|
||||||
public class SysPostController extends BaseController {
|
public class SysPostController extends BaseController {
|
||||||
@ -39,7 +40,7 @@ public class SysPostController extends BaseController {
|
|||||||
* 获取岗位列表
|
* 获取岗位列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取岗位列表")
|
@ApiOperation("获取岗位列表")
|
||||||
@SaCheckPermission("system:post:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -47,7 +48,7 @@ public class SysPostController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出岗位列表")
|
@ApiOperation("导出岗位列表")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:post:export")
|
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysPost post, HttpServletResponse response) {
|
public void export(SysPost post, HttpServletResponse response) {
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
@ -58,24 +59,24 @@ public class SysPostController extends BaseController {
|
|||||||
* 根据岗位编号获取详细信息
|
* 根据岗位编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据岗位编号获取详细信息")
|
@ApiOperation("根据岗位编号获取详细信息")
|
||||||
@SaCheckPermission("system:post:query")
|
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public R<SysPost> getInfo(@ApiParam("岗位ID") @PathVariable Long postId) {
|
public AjaxResult<SysPost> getInfo(@ApiParam("岗位ID") @PathVariable Long postId) {
|
||||||
return R.ok(postService.selectPostById(postId));
|
return AjaxResult.success(postService.selectPostById(postId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增岗位
|
* 新增岗位
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增岗位")
|
@ApiOperation("新增岗位")
|
||||||
@SaCheckPermission("system:post:add")
|
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysPost post) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysPost post) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||||
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||||
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
return toAjax(postService.insertPost(post));
|
return toAjax(postService.insertPost(post));
|
||||||
}
|
}
|
||||||
@ -84,14 +85,14 @@ public class SysPostController extends BaseController {
|
|||||||
* 修改岗位
|
* 修改岗位
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改岗位")
|
@ApiOperation("修改岗位")
|
||||||
@SaCheckPermission("system:post:edit")
|
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysPost post) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysPost post) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||||
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||||
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}
|
}
|
||||||
@ -100,10 +101,10 @@ public class SysPostController extends BaseController {
|
|||||||
* 删除岗位
|
* 删除岗位
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除岗位")
|
@ApiOperation("删除岗位")
|
||||||
@SaCheckPermission("system:post:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] postIds) {
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +113,8 @@ public class SysPostController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("获取岗位选择框列表")
|
@ApiOperation("获取岗位选择框列表")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysPost>> optionselect() {
|
public AjaxResult<List<SysPost>> optionselect() {
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
return R.ok(posts);
|
return AjaxResult.success(posts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
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.AjaxResult;
|
||||||
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.service.TokenService;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.file.MimeTypeUtils;
|
|
||||||
import com.ruoyi.system.domain.SysOss;
|
import com.ruoyi.system.domain.SysOss;
|
||||||
import com.ruoyi.system.service.ISysOssService;
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
@ -19,12 +18,12 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -35,12 +34,13 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "个人信息控制器", tags = {"个人信息管理"})
|
@Api(value = "个人信息控制器", tags = {"个人信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/user/profile")
|
@RequestMapping("/system/user/profile")
|
||||||
public class SysProfileController extends BaseController {
|
public class SysProfileController extends BaseController {
|
||||||
|
|
||||||
private final ISysUserService userService;
|
private final ISysUserService userService;
|
||||||
|
private final TokenService tokenService;
|
||||||
private final ISysOssService iSysOssService;
|
private final ISysOssService iSysOssService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,13 +48,14 @@ public class SysProfileController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("个人信息")
|
@ApiOperation("个人信息")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public R<Map<String, Object>> profile() {
|
public AjaxResult<Map<String, Object>> profile() {
|
||||||
SysUser user = userService.selectUserById(getUserId());
|
LoginUser loginUser = getLoginUser();
|
||||||
|
SysUser user = userService.selectUserById(loginUser.getUserId());
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("user", user);
|
ajax.put("user", user);
|
||||||
ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName()));
|
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||||
ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName()));
|
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,22 +64,24 @@ public class SysProfileController extends BaseController {
|
|||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> updateProfile(@RequestBody SysUser user) {
|
public AjaxResult<Void> updateProfile(@RequestBody SysUser user) {
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
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 AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(user.getEmail())
|
if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setUserId(getUserId());
|
LoginUser loginUser = getLoginUser();
|
||||||
|
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
|
||||||
|
user.setUserId(sysUser.getUserId());
|
||||||
user.setUserName(null);
|
user.setUserName(null);
|
||||||
user.setPassword(null);
|
user.setPassword(null);
|
||||||
if (userService.updateUserProfile(user) > 0) {
|
if (userService.updateUserProfile(user) > 0) {
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return R.fail("修改个人信息异常,请联系管理员");
|
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,21 +94,20 @@ public class SysProfileController extends BaseController {
|
|||||||
})
|
})
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updatePwd")
|
@PutMapping("/updatePwd")
|
||||||
public R<Void> updatePwd(String oldPassword, String newPassword) {
|
public AjaxResult<Void> updatePwd(String oldPassword, String newPassword) {
|
||||||
SysUser user = userService.selectUserById(LoginHelper.getUserId());
|
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
|
||||||
String userName = user.getUserName();
|
String userName = user.getUserName();
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
if (!BCrypt.checkpw(oldPassword, password)) {
|
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||||
return R.fail("修改密码失败,旧密码错误");
|
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if (BCrypt.checkpw(newPassword, password)) {
|
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
||||||
return R.fail("新密码不能与旧密码相同");
|
return AjaxResult.error("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
|
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
|
||||||
if (userService.resetUserPwd(userName, BCrypt.hashpw(newPassword)) > 0) {
|
return AjaxResult.success();
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
return R.fail("修改密码异常,请联系管理员");
|
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,24 +115,21 @@ public class SysProfileController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("头像上传")
|
@ApiOperation("头像上传")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "avatarfile", value = "用户头像", paramType = "query", dataTypeClass = File.class, required = true)
|
@ApiImplicitParam(name = "avatarfile", value = "用户头像", dataTypeClass = File.class, required = true),
|
||||||
})
|
})
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/avatar")
|
@PostMapping("/avatar")
|
||||||
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) {
|
public AjaxResult<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) {
|
||||||
Map<String, Object> ajax = new HashMap<>();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
String extension = FileUtil.extName(file.getOriginalFilename());
|
LoginUser loginUser = getLoginUser();
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
|
||||||
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
|
|
||||||
}
|
|
||||||
SysOss oss = iSysOssService.upload(file);
|
SysOss oss = iSysOssService.upload(file);
|
||||||
String avatar = oss.getUrl();
|
String avatar = oss.getUrl();
|
||||||
if (userService.updateUserAvatar(getUsername(), avatar)) {
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
|
||||||
ajax.put("imgUrl", avatar);
|
ajax.put("imgUrl", avatar);
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return R.fail("上传图片异常,请联系管理员");
|
return AjaxResult.error("上传图片异常,请联系管理员", ajax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.Anonymous;
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -21,21 +22,20 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "注册验证控制器", tags = {"注册验证管理"})
|
@Api(value = "注册验证控制器", tags = {"注册验证管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
public class SysRegisterController extends BaseController {
|
public class SysRegisterController extends BaseController {
|
||||||
|
|
||||||
private final SysRegisterService registerService;
|
private final SysRegisterService registerService;
|
||||||
private final ISysConfigService configService;
|
private final ISysConfigService configService;
|
||||||
|
|
||||||
@Anonymous
|
|
||||||
@ApiOperation("用户注册")
|
@ApiOperation("用户注册")
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
public AjaxResult<Void> register(@RequestBody RegisterBody user) {
|
||||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||||
return R.fail("当前系统没有开启注册功能!");
|
return error("当前系统没有开启注册功能!");
|
||||||
}
|
}
|
||||||
registerService.register(user);
|
String msg = registerService.register(user);
|
||||||
return R.ok();
|
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
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.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
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;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.core.service.TokenService;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
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.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
@ -20,6 +19,8 @@ import com.ruoyi.system.service.ISysUserService;
|
|||||||
import com.ruoyi.system.service.SysPermissionService;
|
import com.ruoyi.system.service.SysPermissionService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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,17 +34,18 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "角色信息控制器", tags = {"角色信息管理"})
|
@Api(value = "角色信息控制器", tags = {"角色信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/role")
|
@RequestMapping("/system/role")
|
||||||
public class SysRoleController extends BaseController {
|
public class SysRoleController extends BaseController {
|
||||||
|
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
|
private final TokenService tokenService;
|
||||||
private final ISysUserService userService;
|
private final ISysUserService userService;
|
||||||
private final SysPermissionService permissionService;
|
private final SysPermissionService permissionService;
|
||||||
|
|
||||||
@ApiOperation("查询角色信息列表")
|
@ApiOperation("查询角色信息列表")
|
||||||
@SaCheckPermission("system:role:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -51,7 +53,7 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出角色信息列表")
|
@ApiOperation("导出角色信息列表")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:role:export")
|
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysRole role, HttpServletResponse response) {
|
public void export(SysRole role, HttpServletResponse response) {
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
@ -62,25 +64,25 @@ public class SysRoleController extends BaseController {
|
|||||||
* 根据角色编号获取详细信息
|
* 根据角色编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据角色编号获取详细信息")
|
@ApiOperation("根据角色编号获取详细信息")
|
||||||
@SaCheckPermission("system:role:query")
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
@GetMapping(value = "/{roleId}")
|
@GetMapping(value = "/{roleId}")
|
||||||
public R<SysRole> getInfo(@ApiParam("角色ID") @PathVariable Long roleId) {
|
public AjaxResult<SysRole> getInfo(@ApiParam("角色ID") @PathVariable Long roleId) {
|
||||||
roleService.checkRoleDataScope(roleId);
|
roleService.checkRoleDataScope(roleId);
|
||||||
return R.ok(roleService.selectRoleById(roleId));
|
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增角色
|
* 新增角色
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增角色")
|
@ApiOperation("新增角色")
|
||||||
@SaCheckPermission("system:role:add")
|
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysRole role) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysRole role) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||||
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||||
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
return toAjax(roleService.insertRole(role));
|
return toAjax(roleService.insertRole(role));
|
||||||
|
|
||||||
@ -90,41 +92,39 @@ public class SysRoleController extends BaseController {
|
|||||||
* 修改保存角色
|
* 修改保存角色
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改保存角色")
|
@ApiOperation("修改保存角色")
|
||||||
@SaCheckPermission("system:role:edit")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysRole role) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysRole role) {
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||||
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||||
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roleService.updateRole(role) > 0) {
|
if (roleService.updateRole(role) > 0) {
|
||||||
// 更新缓存用户权限
|
// 更新缓存用户权限
|
||||||
LoginUser loginUser = getLoginUser();
|
LoginUser loginUser = getLoginUser();
|
||||||
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
|
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
|
||||||
if (ObjectUtil.isNotNull(sysUser) && !sysUser.isAdmin()) {
|
if (StringUtils.isNotNull(sysUser) && !sysUser.isAdmin()) {
|
||||||
loginUser.setMenuPermission(permissionService.getMenuPermission(sysUser));
|
loginUser.setMenuPermissions(permissionService.getMenuPermission(sysUser));
|
||||||
LoginHelper.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
}
|
}
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存数据权限
|
* 修改保存数据权限
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改保存数据权限")
|
@ApiOperation("修改保存数据权限")
|
||||||
@SaCheckPermission("system:role:edit")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/dataScope")
|
@PutMapping("/dataScope")
|
||||||
public R<Void> dataScope(@RequestBody SysRole role) {
|
public AjaxResult<Void> dataScope(@RequestBody SysRole role) {
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
|
||||||
return toAjax(roleService.authDataScope(role));
|
return toAjax(roleService.authDataScope(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,12 +132,11 @@ public class SysRoleController extends BaseController {
|
|||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@ApiOperation("状态修改")
|
@ApiOperation("状态修改")
|
||||||
@SaCheckPermission("system:role:edit")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public R<Void> changeStatus(@RequestBody SysRole role) {
|
public AjaxResult<Void> changeStatus(@RequestBody SysRole role) {
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,10 +144,10 @@ public class SysRoleController extends BaseController {
|
|||||||
* 删除角色
|
* 删除角色
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除角色")
|
@ApiOperation("删除角色")
|
||||||
@SaCheckPermission("system:role:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] roleIds) {
|
||||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,17 +155,17 @@ public class SysRoleController extends BaseController {
|
|||||||
* 获取角色选择框列表
|
* 获取角色选择框列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取角色选择框列表")
|
@ApiOperation("获取角色选择框列表")
|
||||||
@SaCheckPermission("system:role:query")
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public R<List<SysRole>> optionselect() {
|
public AjaxResult<List<SysRole>> optionselect() {
|
||||||
return R.ok(roleService.selectRoleAll());
|
return AjaxResult.success(roleService.selectRoleAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询已分配用户角色列表
|
* 查询已分配用户角色列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询已分配用户角色列表")
|
@ApiOperation("查询已分配用户角色列表")
|
||||||
@SaCheckPermission("system:role:list")
|
@PreAuthorize("@ss.hasPermi('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) {
|
||||||
return userService.selectAllocatedList(user, pageQuery);
|
return userService.selectAllocatedList(user, pageQuery);
|
||||||
@ -176,7 +175,7 @@ public class SysRoleController extends BaseController {
|
|||||||
* 查询未分配用户角色列表
|
* 查询未分配用户角色列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询未分配用户角色列表")
|
@ApiOperation("查询未分配用户角色列表")
|
||||||
@SaCheckPermission("system:role:list")
|
@PreAuthorize("@ss.hasPermi('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) {
|
||||||
return userService.selectUnallocatedList(user, pageQuery);
|
return userService.selectUnallocatedList(user, pageQuery);
|
||||||
@ -186,10 +185,10 @@ public class SysRoleController extends BaseController {
|
|||||||
* 取消授权用户
|
* 取消授权用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("取消授权用户")
|
@ApiOperation("取消授权用户")
|
||||||
@SaCheckPermission("system:role:edit")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/cancel")
|
@PutMapping("/authUser/cancel")
|
||||||
public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
|
public AjaxResult<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
|
||||||
return toAjax(roleService.deleteAuthUser(userRole));
|
return toAjax(roleService.deleteAuthUser(userRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,10 +200,10 @@ public class SysRoleController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
||||||
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
||||||
})
|
})
|
||||||
@SaCheckPermission("system:role:edit")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/cancelAll")
|
@PutMapping("/authUser/cancelAll")
|
||||||
public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
|
public AjaxResult<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
|
||||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,11 +215,10 @@ public class SysRoleController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
||||||
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
||||||
})
|
})
|
||||||
@SaCheckPermission("system:role:edit")
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
|
public AjaxResult<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||||
roleService.checkRoleDataScope(roleId);
|
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
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;
|
||||||
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.AjaxResult;
|
||||||
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.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.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.excel.ExcelResult;
|
import com.ruoyi.common.excel.ExcelResult;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
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;
|
||||||
@ -27,6 +25,8 @@ import com.ruoyi.system.service.ISysRoleService;
|
|||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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;
|
||||||
@ -45,7 +45,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "用户信息控制器", tags = {"用户信息管理"})
|
@Api(value = "用户信息控制器", tags = {"用户信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/user")
|
@RequestMapping("/system/user")
|
||||||
public class SysUserController extends BaseController {
|
public class SysUserController extends BaseController {
|
||||||
@ -58,7 +58,7 @@ public class SysUserController extends BaseController {
|
|||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取用户列表")
|
@ApiOperation("获取用户列表")
|
||||||
@SaCheckPermission("system:user:list")
|
@PreAuthorize("@ss.hasPermi('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);
|
||||||
@ -66,7 +66,7 @@ public class SysUserController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导出用户列表")
|
@ApiOperation("导出用户列表")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:user:export")
|
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SysUser user, HttpServletResponse response) {
|
public void export(SysUser user, HttpServletResponse response) {
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
@ -87,11 +87,11 @@ public class SysUserController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
|
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
|
||||||
})
|
})
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
@SaCheckPermission("system:user:import")
|
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
|
public AjaxResult<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 AjaxResult.success(result.getAnalysis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("下载导入模板")
|
@ApiOperation("下载导入模板")
|
||||||
@ -104,41 +104,40 @@ public class SysUserController extends BaseController {
|
|||||||
* 根据用户编号获取详细信息
|
* 根据用户编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据用户编号获取详细信息")
|
@ApiOperation("根据用户编号获取详细信息")
|
||||||
@SaCheckPermission("system:user:query")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Map<String, Object>> getInfo(@ApiParam("用户ID") @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", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts", postService.selectPostAll());
|
||||||
if (ObjectUtil.isNotNull(userId)) {
|
if (StringUtils.isNotNull(userId)) {
|
||||||
SysUser sysUser = userService.selectUserById(userId);
|
ajax.put("user", userService.selectUserById(userId));
|
||||||
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", roleService.selectRoleListByUserId(userId));
|
||||||
}
|
}
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户
|
* 新增用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@SaCheckPermission("system:user:add")
|
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Void> add(@Validated @RequestBody SysUser user) {
|
public AjaxResult<Void> add(@Validated @RequestBody SysUser user) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
||||||
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return AjaxResult.error("新增用户'" + 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))) {
|
||||||
return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setPassword(BCrypt.hashpw(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
return toAjax(userService.insertUser(user));
|
return toAjax(userService.insertUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,18 +145,17 @@ public class SysUserController extends BaseController {
|
|||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
@SaCheckPermission("system:user:edit")
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated @RequestBody SysUser user) {
|
public AjaxResult<Void> edit(@Validated @RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
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 AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
return toAjax(userService.updateUser(user));
|
return toAjax(userService.updateUser(user));
|
||||||
}
|
}
|
||||||
@ -166,12 +164,12 @@ public class SysUserController extends BaseController {
|
|||||||
* 删除用户
|
* 删除用户
|
||||||
*/
|
*/
|
||||||
@ApiOperation("删除用户")
|
@ApiOperation("删除用户")
|
||||||
@SaCheckPermission("system:user:remove")
|
@PreAuthorize("@ss.hasPermi('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 AjaxResult<Void> remove(@ApiParam("角色ID串") @PathVariable Long[] userIds) {
|
||||||
if (ArrayUtil.contains(userIds, getUserId())) {
|
if (ArrayUtil.contains(userIds, getUserId())) {
|
||||||
return R.fail("当前用户不能删除");
|
return error("当前用户不能删除");
|
||||||
}
|
}
|
||||||
return toAjax(userService.deleteUserByIds(userIds));
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
}
|
}
|
||||||
@ -180,13 +178,12 @@ public class SysUserController extends BaseController {
|
|||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@ApiOperation("重置密码")
|
@ApiOperation("重置密码")
|
||||||
@SaCheckPermission("system:user:resetPwd")
|
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/resetPwd")
|
@PutMapping("/resetPwd")
|
||||||
public R<Void> resetPwd(@RequestBody SysUser user) {
|
public AjaxResult<Void> resetPwd(@RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setPassword(BCrypt.hashpw(user.getPassword()));
|
|
||||||
return toAjax(userService.resetPwd(user));
|
return toAjax(userService.resetPwd(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,12 +191,11 @@ public class SysUserController extends BaseController {
|
|||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
@ApiOperation("状态修改")
|
@ApiOperation("状态修改")
|
||||||
@SaCheckPermission("system:user:edit")
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public R<Void> changeStatus(@RequestBody SysUser user) {
|
public AjaxResult<Void> changeStatus(@RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,15 +203,15 @@ public class SysUserController extends BaseController {
|
|||||||
* 根据用户编号获取授权角色
|
* 根据用户编号获取授权角色
|
||||||
*/
|
*/
|
||||||
@ApiOperation("根据用户编号获取授权角色")
|
@ApiOperation("根据用户编号获取授权角色")
|
||||||
@SaCheckPermission("system:user:query")
|
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||||
@GetMapping("/authRole/{userId}")
|
@GetMapping("/authRole/{userId}")
|
||||||
public R<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") Long userId) {
|
public AjaxResult<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") 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", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
return R.ok(ajax);
|
return AjaxResult.success(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,12 +222,11 @@ public class SysUserController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "userId", value = "用户Id", paramType = "query", dataTypeClass = String.class),
|
@ApiImplicitParam(name = "userId", value = "用户Id", paramType = "query", dataTypeClass = String.class),
|
||||||
@ApiImplicitParam(name = "roleIds", value = "角色ID串", paramType = "query", dataTypeClass = String.class)
|
@ApiImplicitParam(name = "roleIds", value = "角色ID串", paramType = "query", dataTypeClass = String.class)
|
||||||
})
|
})
|
||||||
@SaCheckPermission("system:user:edit")
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authRole")
|
@PutMapping("/authRole")
|
||||||
public R<Void> insertAuthRole(Long userId, Long[] roleIds) {
|
public AjaxResult<Void> insertAuthRole(Long userId, Long[] roleIds) {
|
||||||
userService.checkUserDataScope(userId);
|
|
||||||
userService.insertUserAuth(userId, roleIds);
|
userService.insertUserAuth(userId, roleIds);
|
||||||
return R.ok();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
--- # 监控中心配置
|
--- # 监控配置
|
||||||
spring.boot.admin.client:
|
spring:
|
||||||
|
boot:
|
||||||
|
admin:
|
||||||
|
# Spring Boot Admin Client 客户端的相关配置
|
||||||
|
client:
|
||||||
# 增加客户端开关
|
# 增加客户端开关
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# 设置 Spring Boot Admin Server 地址
|
||||||
url: http://localhost:9090/admin
|
url: http://localhost:9090/admin
|
||||||
instance:
|
instance:
|
||||||
service-host-type: IP
|
prefer-ip: true # 注册实例时,优先使用 IP
|
||||||
username: ruoyi
|
username: ruoyi
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
--- # xxl-job 配置
|
--- # xxl-job 配置
|
||||||
xxl.job:
|
xxl:
|
||||||
|
job:
|
||||||
# 执行器开关
|
# 执行器开关
|
||||||
enabled: true
|
enabled: true
|
||||||
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
||||||
admin-addresses: http://localhost:9100/xxl-job-admin
|
admin-addresses: http://localhost:9100/xxl-job-admin
|
||||||
# 执行器通讯TOKEN:非空时启用
|
# 执行器通讯TOKEN:非空时启用
|
||||||
access-token: xxl-job
|
access-token: xxl-job
|
||||||
|
# 执行器配置
|
||||||
executor:
|
executor:
|
||||||
# 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册
|
# 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册
|
||||||
appname: xxl-job-executor
|
appname: xxl-job-executor
|
||||||
@ -40,8 +47,6 @@ spring:
|
|||||||
p6spy: true
|
p6spy: true
|
||||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||||
primary: master
|
primary: master
|
||||||
# 严格模式 匹配不到数据源则报错
|
|
||||||
strict: true
|
|
||||||
datasource:
|
datasource:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
@ -58,23 +63,6 @@ spring:
|
|||||||
url:
|
url:
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
# oracle:
|
|
||||||
# driverClassName: oracle.jdbc.OracleDriver
|
|
||||||
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
|
||||||
# username: ROOT
|
|
||||||
# password: root
|
|
||||||
# druid:
|
|
||||||
# validationQuery: SELECT 1 FROM DUAL
|
|
||||||
# postgres:
|
|
||||||
# driverClassName: org.postgresql.Driver
|
|
||||||
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
|
||||||
# username: root
|
|
||||||
# password: root
|
|
||||||
# sqlserver:
|
|
||||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
|
||||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;rewriteBatchedStatements=true
|
|
||||||
# username: SA
|
|
||||||
# password: root
|
|
||||||
druid:
|
druid:
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
initialSize: 5
|
initialSize: 5
|
||||||
@ -91,7 +79,7 @@ spring:
|
|||||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
maxEvictableIdleTimeMillis: 900000
|
maxEvictableIdleTimeMillis: 900000
|
||||||
# 配置检测连接是否有效
|
# 配置检测连接是否有效
|
||||||
validationQuery: SELECT 1
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
testWhileIdle: true
|
testWhileIdle: true
|
||||||
testOnBorrow: false
|
testOnBorrow: false
|
||||||
testOnReturn: false
|
testOnReturn: false
|
||||||
@ -99,7 +87,9 @@ spring:
|
|||||||
filters: stat
|
filters: stat
|
||||||
|
|
||||||
--- # druid 配置
|
--- # druid 配置
|
||||||
spring.datasource.druid:
|
spring:
|
||||||
|
datasource:
|
||||||
|
druid:
|
||||||
webStatFilter:
|
webStatFilter:
|
||||||
enabled: true
|
enabled: true
|
||||||
statViewServlet:
|
statViewServlet:
|
||||||
@ -130,8 +120,8 @@ spring:
|
|||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 0
|
||||||
# 密码(如没有密码请注释掉)
|
# 密码
|
||||||
# password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
# 是否开启ssl
|
# 是否开启ssl
|
||||||
@ -139,54 +129,32 @@ spring:
|
|||||||
|
|
||||||
redisson:
|
redisson:
|
||||||
# 线程池数量
|
# 线程池数量
|
||||||
threads: 4
|
threads: 16
|
||||||
# Netty线程池数量
|
# Netty线程池数量
|
||||||
nettyThreads: 8
|
nettyThreads: 32
|
||||||
|
# 传输模式
|
||||||
|
transportMode: "NIO"
|
||||||
# 单节点配置
|
# 单节点配置
|
||||||
singleServerConfig:
|
singleServerConfig:
|
||||||
# 客户端名称
|
# 客户端名称
|
||||||
clientName: ${ruoyi.name}
|
clientName: ${ruoyi.name}
|
||||||
# 最小空闲连接数
|
# 最小空闲连接数
|
||||||
connectionMinimumIdleSize: 8
|
connectionMinimumIdleSize: 32
|
||||||
# 连接池大小
|
# 连接池大小
|
||||||
connectionPoolSize: 32
|
connectionPoolSize: 64
|
||||||
# 连接空闲超时,单位:毫秒
|
# 连接空闲超时,单位:毫秒
|
||||||
idleConnectionTimeout: 10000
|
idleConnectionTimeout: 10000
|
||||||
# 命令等待超时,单位:毫秒
|
# 命令等待超时,单位:毫秒
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
|
# 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
|
||||||
|
retryAttempts: 3
|
||||||
|
# 命令重试发送时间间隔,单位:毫秒
|
||||||
|
retryInterval: 1500
|
||||||
|
# 发布和订阅连接的最小空闲连接数
|
||||||
|
subscriptionConnectionMinimumIdleSize: 1
|
||||||
# 发布和订阅连接池大小
|
# 发布和订阅连接池大小
|
||||||
subscriptionConnectionPoolSize: 50
|
subscriptionConnectionPoolSize: 50
|
||||||
|
# 单个连接最大订阅数量
|
||||||
--- # mail 邮件发送
|
subscriptionsPerConnection: 5
|
||||||
mail:
|
# DNS监测时间间隔,单位:毫秒
|
||||||
enabled: false
|
dnsMonitoringInterval: 5000
|
||||||
host: smtp.163.com
|
|
||||||
port: 465
|
|
||||||
# 是否需要用户名密码验证
|
|
||||||
auth: true
|
|
||||||
# 发送方,遵循RFC-822标准
|
|
||||||
from: xxx@163.com
|
|
||||||
# 用户名(注意:如果使用foxmail邮箱,此处user为qq号)
|
|
||||||
user: xxx@163.com
|
|
||||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置密码,详情查看相关帮助)
|
|
||||||
pass: xxxxxxxxxx
|
|
||||||
# 使用 STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
|
||||||
starttlsEnable: true
|
|
||||||
# 使用SSL安全连接
|
|
||||||
sslEnable: true
|
|
||||||
# SMTP超时时长,单位毫秒,缺省值不超时
|
|
||||||
timeout: 0
|
|
||||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
|
||||||
connectionTimeout: 0
|
|
||||||
|
|
||||||
--- # sms 短信
|
|
||||||
sms:
|
|
||||||
enabled: false
|
|
||||||
# 阿里云 dysmsapi.aliyuncs.com
|
|
||||||
# 腾讯云 sms.tencentcloudapi.com
|
|
||||||
endpoint: "dysmsapi.aliyuncs.com"
|
|
||||||
accessKeyId: xxxxxxx
|
|
||||||
accessKeySecret: xxxxxx
|
|
||||||
signName: 测试
|
|
||||||
# 腾讯专用
|
|
||||||
sdkAppId:
|
|
||||||
|
@ -1,24 +1,35 @@
|
|||||||
--- # 临时文件存储位置 避免临时文件被系统清理报错
|
--- # 配置临时路径存储
|
||||||
spring.servlet.multipart.location: /ruoyi/server/temp
|
spring:
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
# 临时文件存储位置 避免临时文件被系统清理报错
|
||||||
|
location: /ruoyi/server/temp
|
||||||
|
|
||||||
--- # 监控中心配置
|
--- # 监控配置
|
||||||
spring.boot.admin.client:
|
spring:
|
||||||
|
boot:
|
||||||
|
admin:
|
||||||
|
# Spring Boot Admin Client 客户端的相关配置
|
||||||
|
client:
|
||||||
# 增加客户端开关
|
# 增加客户端开关
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# 设置 Spring Boot Admin Server 地址
|
||||||
url: http://172.30.0.90:9090/admin
|
url: http://172.30.0.90:9090/admin
|
||||||
instance:
|
instance:
|
||||||
service-host-type: IP
|
prefer-ip: true # 注册实例时,优先使用 IP
|
||||||
username: ruoyi
|
username: ruoyi
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
--- # xxl-job 配置
|
--- # xxl-job 配置
|
||||||
xxl.job:
|
xxl:
|
||||||
|
job:
|
||||||
# 执行器开关
|
# 执行器开关
|
||||||
enabled: true
|
enabled: true
|
||||||
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
||||||
admin-addresses: http://172.30.0.92:9100/xxl-job-admin
|
admin-addresses: http://172.30.0.92:9100/xxl-job-admin
|
||||||
# 执行器通讯TOKEN:非空时启用
|
# 执行器通讯TOKEN:非空时启用
|
||||||
access-token: xxl-job
|
access-token: xxl-job
|
||||||
|
# 执行器配置
|
||||||
executor:
|
executor:
|
||||||
# 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册
|
# 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册
|
||||||
appname: xxl-job-executor
|
appname: xxl-job-executor
|
||||||
@ -43,8 +54,6 @@ spring:
|
|||||||
p6spy: false
|
p6spy: false
|
||||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||||
primary: master
|
primary: master
|
||||||
# 严格模式 匹配不到数据源则报错
|
|
||||||
strict: true
|
|
||||||
datasource:
|
datasource:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
@ -61,23 +70,6 @@ spring:
|
|||||||
url:
|
url:
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
# oracle:
|
|
||||||
# driverClassName: oracle.jdbc.OracleDriver
|
|
||||||
# url: jdbc:oracle:thin:@//172.30.0.36:1521/XE
|
|
||||||
# username: ROOT
|
|
||||||
# password: root
|
|
||||||
# druid:
|
|
||||||
# validationQuery: SELECT 1 FROM DUAL
|
|
||||||
# postgres:
|
|
||||||
# driverClassName: org.postgresql.Driver
|
|
||||||
# url: jdbc:postgresql://172.30.0.36:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
|
||||||
# username: root
|
|
||||||
# password: root
|
|
||||||
# sqlserver:
|
|
||||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
|
||||||
# url: jdbc:sqlserver://172.30.0.36:1433;DatabaseName=tempdb;SelectMethod=cursor;rewriteBatchedStatements=true
|
|
||||||
# username: SA
|
|
||||||
# password: root
|
|
||||||
druid:
|
druid:
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
initialSize: 5
|
initialSize: 5
|
||||||
@ -94,7 +86,7 @@ spring:
|
|||||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
maxEvictableIdleTimeMillis: 900000
|
maxEvictableIdleTimeMillis: 900000
|
||||||
# 配置检测连接是否有效
|
# 配置检测连接是否有效
|
||||||
validationQuery: SELECT 1
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
testWhileIdle: true
|
testWhileIdle: true
|
||||||
testOnBorrow: false
|
testOnBorrow: false
|
||||||
testOnReturn: false
|
testOnReturn: false
|
||||||
@ -102,7 +94,9 @@ spring:
|
|||||||
filters: stat
|
filters: stat
|
||||||
|
|
||||||
--- # druid 配置
|
--- # druid 配置
|
||||||
spring.datasource.druid:
|
spring:
|
||||||
|
datasource:
|
||||||
|
druid:
|
||||||
webStatFilter:
|
webStatFilter:
|
||||||
enabled: true
|
enabled: true
|
||||||
statViewServlet:
|
statViewServlet:
|
||||||
@ -133,8 +127,8 @@ spring:
|
|||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 0
|
||||||
# 密码(如没有密码请注释掉)
|
# 密码
|
||||||
# password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
# 是否开启ssl
|
# 是否开启ssl
|
||||||
@ -145,6 +139,8 @@ redisson:
|
|||||||
threads: 16
|
threads: 16
|
||||||
# Netty线程池数量
|
# Netty线程池数量
|
||||||
nettyThreads: 32
|
nettyThreads: 32
|
||||||
|
# 传输模式
|
||||||
|
transportMode: "NIO"
|
||||||
# 单节点配置
|
# 单节点配置
|
||||||
singleServerConfig:
|
singleServerConfig:
|
||||||
# 客户端名称
|
# 客户端名称
|
||||||
@ -157,39 +153,15 @@ redisson:
|
|||||||
idleConnectionTimeout: 10000
|
idleConnectionTimeout: 10000
|
||||||
# 命令等待超时,单位:毫秒
|
# 命令等待超时,单位:毫秒
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
|
# 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
|
||||||
|
retryAttempts: 3
|
||||||
|
# 命令重试发送时间间隔,单位:毫秒
|
||||||
|
retryInterval: 1500
|
||||||
|
# 发布和订阅连接的最小空闲连接数
|
||||||
|
subscriptionConnectionMinimumIdleSize: 1
|
||||||
# 发布和订阅连接池大小
|
# 发布和订阅连接池大小
|
||||||
subscriptionConnectionPoolSize: 50
|
subscriptionConnectionPoolSize: 50
|
||||||
|
# 单个连接最大订阅数量
|
||||||
--- # mail 邮件发送
|
subscriptionsPerConnection: 5
|
||||||
mail:
|
# DNS监测时间间隔,单位:毫秒
|
||||||
enabled: false
|
dnsMonitoringInterval: 5000
|
||||||
host: smtp.163.com
|
|
||||||
port: 465
|
|
||||||
# 是否需要用户名密码验证
|
|
||||||
auth: true
|
|
||||||
# 发送方,遵循RFC-822标准
|
|
||||||
from: xxx@163.com
|
|
||||||
# 用户名(注意:如果使用foxmail邮箱,此处user为qq号)
|
|
||||||
user: xxx@163.com
|
|
||||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置密码,详情查看相关帮助)
|
|
||||||
pass: xxxxxxxxxx
|
|
||||||
# 使用 STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
|
||||||
starttlsEnable: true
|
|
||||||
# 使用SSL安全连接
|
|
||||||
sslEnable: true
|
|
||||||
# SMTP超时时长,单位毫秒,缺省值不超时
|
|
||||||
timeout: 0
|
|
||||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
|
||||||
connectionTimeout: 0
|
|
||||||
|
|
||||||
--- # sms 短信
|
|
||||||
sms:
|
|
||||||
enabled: false
|
|
||||||
# 阿里云 dysmsapi.aliyuncs.com
|
|
||||||
# 腾讯云 sms.tencentcloudapi.com
|
|
||||||
endpoint: "dysmsapi.aliyuncs.com"
|
|
||||||
accessKeyId: xxxxxxx
|
|
||||||
accessKeySecret: xxxxxx
|
|
||||||
signName: 测试
|
|
||||||
# 腾讯专用
|
|
||||||
sdkAppId:
|
|
||||||
|
@ -5,7 +5,7 @@ ruoyi:
|
|||||||
# 版本
|
# 版本
|
||||||
version: ${ruoyi-vue-plus.version}
|
version: ${ruoyi-vue-plus.version}
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2022
|
copyrightYear: 2021
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: true
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
@ -75,10 +75,10 @@ spring:
|
|||||||
restart:
|
restart:
|
||||||
# 热部署开关
|
# 热部署开关
|
||||||
enabled: true
|
enabled: true
|
||||||
mvc:
|
# 与vue整合部署使用
|
||||||
pathmatch:
|
thymeleaf:
|
||||||
# 适配 boot 2.6 路由与 springfox 兼容
|
# 将系统模板放置到最前面 否则会与 springboot-admin 页面冲突
|
||||||
matching-strategy: ANT_PATH_MATCHER
|
template-resolver-order: 1
|
||||||
jackson:
|
jackson:
|
||||||
# 日期格式化
|
# 日期格式化
|
||||||
date-format: yyyy-MM-dd HH:mm:ss
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
@ -91,50 +91,42 @@ spring:
|
|||||||
# 允许对象忽略json中不存在的属性
|
# 允许对象忽略json中不存在的属性
|
||||||
fail_on_unknown_properties: false
|
fail_on_unknown_properties: false
|
||||||
|
|
||||||
# Sa-Token配置
|
# token配置
|
||||||
sa-token:
|
token:
|
||||||
# token名称 (同时也是cookie名称)
|
# 令牌自定义标识
|
||||||
token-name: Authorization
|
header: Authorization
|
||||||
# token有效期 设为一天 (必定过期) 单位: 秒
|
# 令牌密钥
|
||||||
timeout: 86400
|
secret: abcdefghijklmnopqrstuvwxyz
|
||||||
# token临时有效期 (指定时间无操作就过期) 单位: 秒
|
# 令牌有效期(默认30分钟)
|
||||||
activity-timeout: 1800
|
expireTime: 30
|
||||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
|
||||||
is-concurrent: true
|
|
||||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
|
||||||
is-share: false
|
|
||||||
# 是否尝试从header里读取token
|
|
||||||
is-read-head: true
|
|
||||||
# 是否尝试从cookie里读取token
|
|
||||||
is-read-cookie: false
|
|
||||||
# token前缀
|
|
||||||
token-prefix: "Bearer"
|
|
||||||
# jwt秘钥
|
|
||||||
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
|
|
||||||
# 是否输出操作日志
|
|
||||||
is-log: true
|
|
||||||
|
|
||||||
# security配置
|
# security配置
|
||||||
security:
|
security:
|
||||||
# 排除路径
|
# 登出路径
|
||||||
excludes:
|
logout-url: /logout
|
||||||
# 静态资源
|
# 匿名路径
|
||||||
- /*.html
|
anonymous:
|
||||||
- /**/*.html
|
- /login
|
||||||
- /**/*.css
|
- /register
|
||||||
- /**/*.js
|
- /captchaImage
|
||||||
# swagger 文档配置
|
# swagger 文档配置
|
||||||
- /favicon.ico
|
|
||||||
- /doc.html
|
- /doc.html
|
||||||
- /swagger-resources/**
|
- /swagger-resources/**
|
||||||
- /webjars/**
|
- /webjars/**
|
||||||
- /*/api-docs
|
- /*/api-docs
|
||||||
# druid 监控配置
|
# druid 监控配置
|
||||||
- /druid/**
|
- /druid/**
|
||||||
|
# 用户放行
|
||||||
|
permit-all:
|
||||||
# actuator 监控配置
|
# actuator 监控配置
|
||||||
- /actuator
|
- /actuator
|
||||||
- /actuator/**
|
- /actuator/**
|
||||||
|
|
||||||
|
# 重复提交
|
||||||
|
repeat-submit:
|
||||||
|
# 全局间隔时间(毫秒)
|
||||||
|
interval: 5000
|
||||||
|
|
||||||
# MyBatisPlus配置
|
# MyBatisPlus配置
|
||||||
# https://baomidou.com/config/
|
# https://baomidou.com/config/
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
@ -147,15 +139,25 @@ mybatis-plus:
|
|||||||
typeAliasesPackage: com.ruoyi.**.domain
|
typeAliasesPackage: com.ruoyi.**.domain
|
||||||
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
|
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
|
||||||
checkConfigLocation: false
|
checkConfigLocation: false
|
||||||
|
# 通过该属性可指定 MyBatis 的执行器,MyBatis 的执行器总共有三种:
|
||||||
|
# SIMPLE:每个语句创建新的预处理器 REUSE:会复用预处理器 BATCH:批量执行所有的更新
|
||||||
|
executorType: SIMPLE
|
||||||
configuration:
|
configuration:
|
||||||
# 自动驼峰命名规则(camel case)映射
|
# 自动驼峰命名规则(camel case)映射
|
||||||
mapUnderscoreToCamelCase: true
|
mapUnderscoreToCamelCase: true
|
||||||
|
# 当设置为 true 的时候,懒加载的对象可能被任何懒属性全部加载,否则,每个属性都按需加载。需要和 lazyLoadingEnabled 一起使用。
|
||||||
|
aggressiveLazyLoading: true
|
||||||
# MyBatis 自动映射策略
|
# MyBatis 自动映射策略
|
||||||
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||||
autoMappingBehavior: PARTIAL
|
autoMappingBehavior: PARTIAL
|
||||||
# MyBatis 自动映射时未知列或未知属性处理策
|
# MyBatis 自动映射时未知列或未知属性处理策
|
||||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||||
autoMappingUnknownColumnBehavior: NONE
|
autoMappingUnknownColumnBehavior: NONE
|
||||||
|
# Mybatis一级缓存,默认为 SESSION
|
||||||
|
# SESSION session级别缓存 STATEMENT 关闭一级缓存
|
||||||
|
localCacheScope: SESSION
|
||||||
|
# 开启Mybatis二级缓存,默认为 true
|
||||||
|
cacheEnabled: false
|
||||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
@ -163,10 +165,16 @@ mybatis-plus:
|
|||||||
global-config:
|
global-config:
|
||||||
# 是否打印 Logo banner
|
# 是否打印 Logo banner
|
||||||
banner: true
|
banner: true
|
||||||
|
# 是否初始化 SqlRunner
|
||||||
|
enableSqlRunner: false
|
||||||
dbConfig:
|
dbConfig:
|
||||||
# 主键类型
|
# 主键类型
|
||||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
||||||
idType: ASSIGN_ID
|
idType: AUTO
|
||||||
|
# 表名是否使用驼峰转下划线命名,只对表名生效
|
||||||
|
tableUnderline: true
|
||||||
|
# 大写命名,对表名和字段名均生效
|
||||||
|
capitalMode: false
|
||||||
# 逻辑已删除值
|
# 逻辑已删除值
|
||||||
logicDeleteValue: 2
|
logicDeleteValue: 2
|
||||||
# 逻辑未删除值
|
# 逻辑未删除值
|
||||||
@ -209,10 +217,6 @@ knife4j:
|
|||||||
enable: true
|
enable: true
|
||||||
# 是否开启生产环境保护策略
|
# 是否开启生产环境保护策略
|
||||||
production: @knife4j.production@
|
production: @knife4j.production@
|
||||||
basic:
|
|
||||||
enable: true
|
|
||||||
username: ruoyi
|
|
||||||
password: 123456
|
|
||||||
# 前端Ui的个性化配置属性
|
# 前端Ui的个性化配置属性
|
||||||
setting:
|
setting:
|
||||||
# 默认语言
|
# 默认语言
|
||||||
@ -237,10 +241,20 @@ xss:
|
|||||||
thread-pool:
|
thread-pool:
|
||||||
# 是否开启线程池
|
# 是否开启线程池
|
||||||
enabled: false
|
enabled: false
|
||||||
|
# 核心线程池大小
|
||||||
|
corePoolSize: 8
|
||||||
|
# 最大可创建的线程数
|
||||||
|
maxPoolSize: 16
|
||||||
# 队列最大长度
|
# 队列最大长度
|
||||||
queueCapacity: 128
|
queueCapacity: 128
|
||||||
# 线程池维护线程所允许的空闲时间
|
# 线程池维护线程所允许的空闲时间
|
||||||
keepAliveSeconds: 300
|
keepAliveSeconds: 300
|
||||||
|
# 线程池对拒绝任务(无线程可用)的处理策略
|
||||||
|
# CALLER_RUNS_POLICY 调用方执行
|
||||||
|
# DISCARD_OLDEST_POLICY 放弃最旧的
|
||||||
|
# DISCARD_POLICY 丢弃
|
||||||
|
# ABORT_POLICY 中止
|
||||||
|
rejectedExecutionHandler: CALLER_RUNS_POLICY
|
||||||
|
|
||||||
--- # redisson 缓存配置
|
--- # redisson 缓存配置
|
||||||
redisson:
|
redisson:
|
||||||
@ -268,6 +282,8 @@ lock4j:
|
|||||||
management:
|
management:
|
||||||
endpoints:
|
endpoints:
|
||||||
web:
|
web:
|
||||||
|
# Actuator 提供的 API 接口的根目录。默认为 /actuator
|
||||||
|
base-path: /actuator
|
||||||
exposure:
|
exposure:
|
||||||
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
|
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
|
||||||
# 生产环境不建议放开所有 根据项目需求放开即可
|
# 生产环境不建议放开所有 根据项目需求放开即可
|
||||||
|
@ -11,19 +11,12 @@ user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
|||||||
role.blocked=角色已封禁,请联系管理员
|
role.blocked=角色已封禁,请联系管理员
|
||||||
user.logout.success=退出成功
|
user.logout.success=退出成功
|
||||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||||
user.username.not.blank=用户名不能为空
|
|
||||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||||
user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
|
||||||
user.password.not.blank=用户密码不能为空
|
|
||||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
|
||||||
user.password.not.valid=* 5-50个字符
|
user.password.not.valid=* 5-50个字符
|
||||||
user.email.not.valid=邮箱格式错误
|
user.email.not.valid=邮箱格式错误
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
|
||||||
user.mobile.phone.number.not.valid=手机号格式错误
|
user.mobile.phone.number.not.valid=手机号格式错误
|
||||||
user.login.success=登录成功
|
user.login.success=登录成功
|
||||||
user.register.success=注册成功
|
user.register.success=注册成功
|
||||||
user.register.save.error=保存用户 {0} 失败,注册账号已存在
|
|
||||||
user.register.error=注册失败,请联系系统管理人员
|
|
||||||
user.notfound=请重新登录
|
user.notfound=请重新登录
|
||||||
user.forcelogout=管理员强制退出,请重新登录
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
user.unknown.error=未知错误,请重新登录
|
user.unknown.error=未知错误,请重新登录
|
||||||
@ -37,9 +30,3 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
|
|||||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||||
repeat.submit.message=不允许重复提交,请稍候再试
|
|
||||||
rate.limiter.message=访问过于频繁,请稍候再试
|
|
||||||
sms.code.not.blank=短信验证码不能为空
|
|
||||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
|
||||||
sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟
|
|
||||||
xcx.code.not.blank=小程序code不能为空
|
|
||||||
|
@ -11,19 +11,12 @@ user.blocked=Sorry, your account: {0} has been disabled. Please contact the admi
|
|||||||
role.blocked=Role disabled,please contact administrators
|
role.blocked=Role disabled,please contact administrators
|
||||||
user.logout.success=Exit successful
|
user.logout.success=Exit successful
|
||||||
length.not.valid=The length must be between {min} and {max} characters
|
length.not.valid=The length must be between {min} and {max} characters
|
||||||
user.username.not.blank=Username cannot be blank
|
|
||||||
user.username.not.valid=* 2 to 20 chinese characters, letters, numbers or underscores, and must start with a non number
|
user.username.not.valid=* 2 to 20 chinese characters, letters, numbers or underscores, and must start with a non number
|
||||||
user.username.length.valid=Account length must be between {min} and {max} characters
|
|
||||||
user.password.not.blank=Password cannot be empty
|
|
||||||
user.password.length.valid=Password length must be between {min} and {max} characters
|
|
||||||
user.password.not.valid=* 5-50 characters
|
user.password.not.valid=* 5-50 characters
|
||||||
user.email.not.valid=Mailbox format error
|
user.email.not.valid=Mailbox format error
|
||||||
user.phonenumber.not.blank=Phone number cannot be blank
|
|
||||||
user.mobile.phone.number.not.valid=Phone number format error
|
user.mobile.phone.number.not.valid=Phone number format error
|
||||||
user.login.success=Login successful
|
user.login.success=Login successful
|
||||||
user.register.success=Register successful
|
user.register.success=Register successful
|
||||||
user.register.save.error=Failed to save user {0}, The registered account already exists
|
|
||||||
user.register.error=Register failed, please contact system administrator
|
|
||||||
user.notfound=Please login again
|
user.notfound=Please login again
|
||||||
user.forcelogout=The administrator is forced to exit,please login again
|
user.forcelogout=The administrator is forced to exit,please login again
|
||||||
user.unknown.error=Unknown error, please login again
|
user.unknown.error=Unknown error, please login again
|
||||||
@ -37,9 +30,3 @@ no.update.permission=You do not have permission to modify data,please contact
|
|||||||
no.delete.permission=You do not have permission to delete data,please contact your administrator to add permissions [{0}]
|
no.delete.permission=You do not have permission to delete data,please contact your administrator to add permissions [{0}]
|
||||||
no.export.permission=You do not have permission to export data,please contact your administrator to add permissions [{0}]
|
no.export.permission=You do not have permission to export data,please contact your administrator to add permissions [{0}]
|
||||||
no.view.permission=You do not have permission to view data,please contact your administrator to add permissions [{0}]
|
no.view.permission=You do not have permission to view data,please contact your administrator to add permissions [{0}]
|
||||||
repeat.submit.message=Repeat submit is not allowed, 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.retry.limit.count=Sms code input error {0} times
|
|
||||||
sms.code.retry.limit.exceed=Too many sms code errors, account locked for {0} minutes
|
|
||||||
xcx.code.not.blank=Mini program code cannot be blank
|
|
||||||
|
@ -11,19 +11,12 @@ user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
|||||||
role.blocked=角色已封禁,请联系管理员
|
role.blocked=角色已封禁,请联系管理员
|
||||||
user.logout.success=退出成功
|
user.logout.success=退出成功
|
||||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||||
user.username.not.blank=用户名不能为空
|
|
||||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||||
user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
|
||||||
user.password.not.blank=用户密码不能为空
|
|
||||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
|
||||||
user.password.not.valid=* 5-50个字符
|
user.password.not.valid=* 5-50个字符
|
||||||
user.email.not.valid=邮箱格式错误
|
user.email.not.valid=邮箱格式错误
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
|
||||||
user.mobile.phone.number.not.valid=手机号格式错误
|
user.mobile.phone.number.not.valid=手机号格式错误
|
||||||
user.login.success=登录成功
|
user.login.success=登录成功
|
||||||
user.register.success=注册成功
|
user.register.success=注册成功
|
||||||
user.register.save.error=保存用户 {0} 失败,注册账号已存在
|
|
||||||
user.register.error=注册失败,请联系系统管理人员
|
|
||||||
user.notfound=请重新登录
|
user.notfound=请重新登录
|
||||||
user.forcelogout=管理员强制退出,请重新登录
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
user.unknown.error=未知错误,请重新登录
|
user.unknown.error=未知错误,请重新登录
|
||||||
@ -37,9 +30,3 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
|
|||||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||||
repeat.submit.message=不允许重复提交,请稍候再试
|
|
||||||
rate.limiter.message=访问过于频繁,请稍候再试
|
|
||||||
sms.code.not.blank=短信验证码不能为空
|
|
||||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
|
||||||
sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟
|
|
||||||
xcx.code.not.blank=小程序code不能为空
|
|
||||||
|
@ -77,31 +77,19 @@
|
|||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- info异步输出 -->
|
<!-- 系统模块日志级别控制 -->
|
||||||
<appender name="async_info" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
|
<logger name="com.ruoyi" level="info" />
|
||||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
<!-- Spring日志级别控制 -->
|
||||||
<discardingThreshold>0</discardingThreshold>
|
<logger name="org.springframework" level="warn" />
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
|
||||||
<queueSize>512</queueSize>
|
|
||||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
|
||||||
<appender-ref ref="file_info"/>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- error异步输出 -->
|
<root level="info">
|
||||||
<appender name="async_error" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
|
<appender-ref ref="console" />
|
||||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
</root>
|
||||||
<discardingThreshold>0</discardingThreshold>
|
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
|
||||||
<queueSize>512</queueSize>
|
|
||||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
|
||||||
<appender-ref ref="file_error"/>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
<!--系统操作日志-->
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="console" />
|
<appender-ref ref="file_info" />
|
||||||
<appender-ref ref="async_info" />
|
<appender-ref ref="file_error" />
|
||||||
<appender-ref ref="async_error" />
|
|
||||||
<appender-ref ref="file_console" />
|
<appender-ref ref="file_console" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
@ -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>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -29,15 +29,10 @@
|
|||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
|
<!-- spring security 安全认证 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
|
||||||
<!-- Sa-Token 整合 jwt -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.dev33</groupId>
|
|
||||||
<artifactId>sa-token-jwt</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 自定义验证注解 -->
|
<!-- 自定义验证注解 -->
|
||||||
@ -58,17 +53,34 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cglib</groupId>
|
||||||
|
<artifactId>cglib</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- yml解析器 -->
|
<!-- yml解析器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- jdk11 缺失依赖 jaxb-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- servlet包 -->
|
<!-- servlet包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
@ -115,11 +127,6 @@
|
|||||||
<artifactId>hutool-extra</artifactId>
|
<artifactId>hutool-extra</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.mail</groupId>
|
|
||||||
<artifactId>jakarta.mail</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
@ -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 {
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import com.ruoyi.common.excel.CellMergeStrategy;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* excel 列单元格合并(合并列相同项)
|
|
||||||
*
|
|
||||||
* 需搭配 {@link CellMergeStrategy} 策略使用
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Inherited
|
|
||||||
public @interface CellMerge {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* col index
|
|
||||||
*/
|
|
||||||
int index() default -1;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据权限过滤注解
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @deprecated 3.6.0 移除 {@link com.ruoyi.common.annotation.DataPermission}
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Deprecated
|
||||||
|
public @interface DataScope {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门表的别名
|
||||||
|
*/
|
||||||
|
String deptAlias() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户表的别名
|
||||||
|
*/
|
||||||
|
String userAlias() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否过滤用户权限
|
||||||
|
*/
|
||||||
|
boolean isUser() default false;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
|
import com.ruoyi.common.enums.DataSourceType;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义多数据源切换注解
|
||||||
|
* <p>
|
||||||
|
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @deprecated 3.6.0 移除 使用原生注解处理 方法更全 {@link com.baomidou.dynamic.datasource.annotation.DS}
|
||||||
|
*/
|
||||||
|
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
@Deprecated
|
||||||
|
public @interface DataSource {
|
||||||
|
/**
|
||||||
|
* 切换数据源名称
|
||||||
|
*/
|
||||||
|
DataSourceType value() default DataSourceType.MASTER;
|
||||||
|
}
|
@ -22,8 +22,8 @@ public @interface RepeatSubmit {
|
|||||||
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
|
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提示消息 支持国际化 格式为 {code}
|
* 提示消息
|
||||||
*/
|
*/
|
||||||
String message() default "{repeat.submit.message}";
|
String message() default "不允许重复提交,请稍候再试";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
|
||||||
import com.ruoyi.common.jackson.SensitiveJsonSerializer;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据脱敏注解
|
|
||||||
*
|
|
||||||
* @author zhujie
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@JsonSerialize(using = SensitiveJsonSerializer.class)
|
|
||||||
public @interface Sensitive {
|
|
||||||
SensitiveStrategy strategy();
|
|
||||||
}
|
|
@ -15,7 +15,7 @@ public class UnsignedMathGenerator implements CodeGenerator {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -5514819971774091076L;
|
private static final long serialVersionUID = -5514819971774091076L;
|
||||||
|
|
||||||
private static final String OPERATORS = "+-*";
|
private static final String operators = "+-*";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参与计算数字最大长度
|
* 参与计算数字最大长度
|
||||||
@ -41,14 +41,14 @@ public class UnsignedMathGenerator implements CodeGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public String generate() {
|
public String generate() {
|
||||||
final int limit = getLimit();
|
final int limit = getLimit();
|
||||||
int a = RandomUtil.randomInt(limit);
|
int min = RandomUtil.randomInt(limit);
|
||||||
int b = RandomUtil.randomInt(limit);
|
int max = RandomUtil.randomInt(min, limit);
|
||||||
String max = Integer.toString(Math.max(a,b));
|
String number1 = Integer.toString(max);
|
||||||
String min = Integer.toString(Math.min(a,b));
|
String number2 = Integer.toString(min);
|
||||||
max = StringUtils.rightPad(max, this.numberLength, CharUtil.SPACE);
|
number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE);
|
||||||
min = StringUtils.rightPad(min, this.numberLength, CharUtil.SPACE);
|
number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE);
|
||||||
|
|
||||||
return max + RandomUtil.randomChar(OPERATORS) + min + '=';
|
return number1 + RandomUtil.randomChar(operators) + number2 + '=';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.common.config;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "ruoyi")
|
@ConfigurationProperties(prefix = "ruoyi")
|
||||||
public class RuoYiConfig {
|
public class RuoYiConfig {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用常量信息
|
* 通用常量信息
|
||||||
*
|
*
|
||||||
@ -65,12 +66,7 @@ public interface Constants {
|
|||||||
/**
|
/**
|
||||||
* 登录用户 redis key
|
* 登录用户 redis key
|
||||||
*/
|
*/
|
||||||
String LOGIN_TOKEN_KEY = "Authorization:login:token:";
|
String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线用户 redis key
|
|
||||||
*/
|
|
||||||
String ONLINE_TOKEN_KEY = "online_tokens:";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防重提交 redis key
|
* 防重提交 redis key
|
||||||
@ -107,11 +103,41 @@ public interface Constants {
|
|||||||
*/
|
*/
|
||||||
String TOKEN = "token";
|
String TOKEN = "token";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌前缀
|
||||||
|
*/
|
||||||
|
String TOKEN_PREFIX = "Bearer ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌前缀
|
* 令牌前缀
|
||||||
*/
|
*/
|
||||||
String LOGIN_USER_KEY = "login_user_key";
|
String LOGIN_USER_KEY = "login_user_key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
String JWT_USERID = "userid";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
String JWT_USERNAME = "sub";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
String JWT_AVATAR = "avatar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
String JWT_CREATED = "created";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户权限
|
||||||
|
*/
|
||||||
|
String JWT_AUTHORITIES = "authorities";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数管理 cache key
|
* 参数管理 cache key
|
||||||
*/
|
*/
|
||||||
@ -123,4 +149,3 @@ public interface Constants {
|
|||||||
String SYS_DICT_KEY = "sys_dict:";
|
String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,11 +181,6 @@ public interface GenConstants {
|
|||||||
*/
|
*/
|
||||||
String QUERY_LIKE = "LIKE";
|
String QUERY_LIKE = "LIKE";
|
||||||
|
|
||||||
/**
|
|
||||||
* 相等查询
|
|
||||||
*/
|
|
||||||
String QUERY_EQ = "EQ";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 需要
|
* 需要
|
||||||
*/
|
*/
|
||||||
|
@ -22,21 +22,11 @@ public interface UserConstants {
|
|||||||
*/
|
*/
|
||||||
String EXCEPTION = "1";
|
String EXCEPTION = "1";
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户正常状态
|
|
||||||
*/
|
|
||||||
String USER_NORMAL = "0";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户封禁状态
|
* 用户封禁状态
|
||||||
*/
|
*/
|
||||||
String USER_DISABLE = "1";
|
String USER_DISABLE = "1";
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色正常状态
|
|
||||||
*/
|
|
||||||
String ROLE_NORMAL = "0";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色封禁状态
|
* 角色封禁状态
|
||||||
*/
|
*/
|
||||||
@ -72,16 +62,6 @@ public interface UserConstants {
|
|||||||
*/
|
*/
|
||||||
String NO_FRAME = "1";
|
String NO_FRAME = "1";
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单正常状态
|
|
||||||
*/
|
|
||||||
String MENU_NORMAL = "0";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单停用状态
|
|
||||||
*/
|
|
||||||
String MENU_DISABLE = "1";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单类型(目录)
|
* 菜单类型(目录)
|
||||||
*/
|
*/
|
||||||
@ -129,10 +109,4 @@ public interface UserConstants {
|
|||||||
*/
|
*/
|
||||||
int PASSWORD_MIN_LENGTH = 5;
|
int PASSWORD_MIN_LENGTH = 5;
|
||||||
int PASSWORD_MAX_LENGTH = 20;
|
int PASSWORD_MAX_LENGTH = 20;
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理员ID
|
|
||||||
*/
|
|
||||||
Long ADMIN_ID = 1L;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,8 @@ import cn.hutool.core.convert.Convert;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.excel.converters.Converter;
|
import com.alibaba.excel.converters.Converter;
|
||||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.CellData;
|
||||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
|
||||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
|
||||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@ -32,19 +31,19 @@ public class ExcelBigNumberConvert implements Converter<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
return Convert.toLong(cellData.getData());
|
return Convert.toLong(cellData.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WriteCellData<Object> convertToExcelData(Long object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
public CellData<Object> convertToExcelData(Long object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
if (ObjectUtil.isNotNull(object)) {
|
if (ObjectUtil.isNotNull(object)) {
|
||||||
String str = Convert.toStr(object);
|
String str = Convert.toStr(object);
|
||||||
if (str.length() > 15) {
|
if (str.length() > 15) {
|
||||||
return new WriteCellData<>(str);
|
return new CellData<>(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteCellData<Object> cellData = new WriteCellData<>(new BigDecimal(object));
|
CellData<Object> cellData = new CellData<>(new BigDecimal(object));
|
||||||
cellData.setType(CellDataTypeEnum.NUMBER);
|
cellData.setType(CellDataTypeEnum.NUMBER);
|
||||||
return cellData;
|
return cellData;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package com.ruoyi.common.convert;
|
|||||||
|
|
||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.alibaba.excel.converters.Converter;
|
import com.alibaba.excel.converters.Converter;
|
||||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.CellData;
|
||||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
|
||||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
|
||||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||||
import com.ruoyi.common.core.service.DictService;
|
import com.ruoyi.common.core.service.DictService;
|
||||||
@ -37,7 +35,7 @@ public class ExcelDictConvert implements Converter<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
ExcelDictFormat anno = getAnnotation(contentProperty.getField());
|
ExcelDictFormat anno = getAnnotation(contentProperty.getField());
|
||||||
String type = anno.dictType();
|
String type = anno.dictType();
|
||||||
String label = cellData.getStringValue();
|
String label = cellData.getStringValue();
|
||||||
@ -51,9 +49,9 @@ public class ExcelDictConvert implements Converter<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WriteCellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
public CellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
if (ObjectUtil.isNull(object)) {
|
if (StringUtils.isNull(object)) {
|
||||||
return new WriteCellData<>("");
|
return new CellData<>("");
|
||||||
}
|
}
|
||||||
ExcelDictFormat anno = getAnnotation(contentProperty.getField());
|
ExcelDictFormat anno = getAnnotation(contentProperty.getField());
|
||||||
String type = anno.dictType();
|
String type = anno.dictType();
|
||||||
@ -64,7 +62,7 @@ public class ExcelDictConvert implements Converter<Object> {
|
|||||||
} else {
|
} else {
|
||||||
label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator());
|
label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator());
|
||||||
}
|
}
|
||||||
return new WriteCellData<>(label);
|
return new CellData<>(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExcelDictFormat getAnnotation(Field field) {
|
private ExcelDictFormat getAnnotation(Field field) {
|
||||||
|
@ -1,25 +1,53 @@
|
|||||||
package com.ruoyi.common.core.controller;
|
package com.ruoyi.common.core.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web层通用数据处理
|
* web层通用数据处理
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class BaseController {
|
public class BaseController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public AjaxResult<Void> success() {
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult<Void> error() {
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*/
|
||||||
|
public AjaxResult<Void> success(String message) {
|
||||||
|
return AjaxResult.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult<Void> error(String message) {
|
||||||
|
return AjaxResult.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应返回结果
|
* 响应返回结果
|
||||||
*
|
*
|
||||||
* @param rows 影响行数
|
* @param rows 影响行数
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected R<Void> toAjax(int rows) {
|
protected AjaxResult<Void> toAjax(int rows) {
|
||||||
return rows > 0 ? R.ok() : R.fail();
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,8 +56,8 @@ public class BaseController {
|
|||||||
* @param result 结果
|
* @param result 结果
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected R<Void> toAjax(boolean result) {
|
protected AjaxResult<Void> toAjax(boolean result) {
|
||||||
return result ? R.ok() : R.fail();
|
return result ? success() : error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,27 +71,27 @@ public class BaseController {
|
|||||||
* 获取用户缓存信息
|
* 获取用户缓存信息
|
||||||
*/
|
*/
|
||||||
public LoginUser getLoginUser() {
|
public LoginUser getLoginUser() {
|
||||||
return LoginHelper.getLoginUser();
|
return SecurityUtils.getLoginUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录用户id
|
* 获取登录用户id
|
||||||
*/
|
*/
|
||||||
public Long getUserId() {
|
public Long getUserId() {
|
||||||
return LoginHelper.getUserId();
|
return getLoginUser().getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录部门id
|
* 获取登录部门id
|
||||||
*/
|
*/
|
||||||
public Long getDeptId() {
|
public Long getDeptId() {
|
||||||
return LoginHelper.getDeptId();
|
return getLoginUser().getDeptId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录用户名
|
* 获取登录用户名
|
||||||
*/
|
*/
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return LoginHelper.getUsername();
|
return getLoginUser().getUsername();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,134 @@
|
|||||||
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作消息提醒
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("请求响应对象")
|
||||||
|
public class AjaxResult<T> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("消息状态码")
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回内容
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("消息内容")
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("数据对象")
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
*/
|
||||||
|
public AjaxResult(int code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult<Void> success() {
|
||||||
|
return AjaxResult.success("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功数据
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static <T> AjaxResult<T> success(T data) {
|
||||||
|
return AjaxResult.success("操作成功", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult<Void> success(String msg) {
|
||||||
|
return AjaxResult.success(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static <T> AjaxResult<T> success(String msg, T data) {
|
||||||
|
return new AjaxResult<>(HttpStatus.HTTP_OK, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static AjaxResult<Void> error() {
|
||||||
|
return AjaxResult.error("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult<Void> error(String msg) {
|
||||||
|
return AjaxResult.error(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static <T> AjaxResult<T> error(String msg, T data) {
|
||||||
|
return new AjaxResult<>(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult<Void> error(int code, String msg) {
|
||||||
|
return new AjaxResult<>(code, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -17,6 +18,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class BaseEntity implements Serializable {
|
public class BaseEntity implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -7,6 +7,7 @@ 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 io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class PageQuery implements Serializable {
|
public class PageQuery implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
package com.ruoyi.common.core.domain;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应信息主体
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@ApiModel("请求响应对象")
|
|
||||||
public class R<T> implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 成功
|
|
||||||
*/
|
|
||||||
public static final int SUCCESS = 200;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 失败
|
|
||||||
*/
|
|
||||||
public static final int FAIL = 500;
|
|
||||||
|
|
||||||
@ApiModelProperty("消息状态码")
|
|
||||||
private int code;
|
|
||||||
|
|
||||||
@ApiModelProperty("消息内容")
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
@ApiModelProperty("数据对象")
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
public static <T> R<T> ok() {
|
|
||||||
return restResult(null, SUCCESS, "操作成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(T data) {
|
|
||||||
return restResult(data, SUCCESS, "操作成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(String msg) {
|
|
||||||
return restResult(null, SUCCESS, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(String msg, T data) {
|
|
||||||
return restResult(data, SUCCESS, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail() {
|
|
||||||
return restResult(null, FAIL, "操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(String msg) {
|
|
||||||
return restResult(null, FAIL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(T data) {
|
|
||||||
return restResult(data, FAIL, "操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(String msg, T data) {
|
|
||||||
return restResult(data, FAIL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(int code, String msg) {
|
|
||||||
return restResult(null, code, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
|
||||||
R<T> r = new R<>();
|
|
||||||
r.setCode(code);
|
|
||||||
r.setData(data);
|
|
||||||
r.setMsg(msg);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -16,7 +17,8 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class TreeEntity<T> extends BaseEntity {
|
@Accessors(chain = true)
|
||||||
|
public class TreeEntity extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -38,6 +40,6 @@ public class TreeEntity<T> extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "子部门")
|
@ApiModelProperty(value = "子部门")
|
||||||
private List<T> children = new ArrayList<>();
|
private List<?> children = new ArrayList<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.common.core.domain.dto;
|
package com.ruoyi.common.core.domain.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -12,6 +14,8 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class OperLogDTO implements Serializable {
|
public class OperLogDTO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package com.ruoyi.common.core.domain.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class RoleDTO implements Serializable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色ID
|
|
||||||
*/
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色名称
|
|
||||||
*/
|
|
||||||
private String roleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色权限
|
|
||||||
*/
|
|
||||||
private String roleKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
|
||||||
*/
|
|
||||||
private String dataScope;
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package com.ruoyi.common.core.domain.dto;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前在线会话
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class UserOnlineDTO implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 会话编号
|
|
||||||
*/
|
|
||||||
private String tokenId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门名称
|
|
||||||
*/
|
|
||||||
private String deptName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名称
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录IP地址
|
|
||||||
*/
|
|
||||||
private String ipaddr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录地址
|
|
||||||
*/
|
|
||||||
private String loginLocation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 浏览器类型
|
|
||||||
*/
|
|
||||||
private String browser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作系统
|
|
||||||
*/
|
|
||||||
private String os;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录时间
|
|
||||||
*/
|
|
||||||
private Long loginTime;
|
|
||||||
|
|
||||||
}
|
|
@ -8,10 +8,10 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
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.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,9 +22,10 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("sys_dept")
|
@TableName("sys_dept")
|
||||||
@ApiModel("部门业务对象")
|
@ApiModel("部门业务对象")
|
||||||
public class SysDept extends TreeEntity<SysDept> {
|
public class SysDept extends TreeEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,8 +47,8 @@ public class SysDept extends TreeEntity<SysDept> {
|
|||||||
* 显示顺序
|
* 显示顺序
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "显示顺序")
|
@ApiModelProperty(value = "显示顺序")
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
private Integer orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 负责人
|
* 负责人
|
||||||
|
@ -12,6 +12,7 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
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.Size;
|
import javax.validation.constraints.Size;
|
||||||
@ -24,6 +25,7 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("sys_dict_data")
|
@TableName("sys_dict_data")
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@ApiModel("字典数据业务对象")
|
@ApiModel("字典数据业务对象")
|
||||||
@ -42,7 +44,7 @@ public class SysDictData extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "字典排序")
|
@ApiModelProperty(value = "字典排序")
|
||||||
@ExcelProperty(value = "字典排序")
|
@ExcelProperty(value = "字典排序")
|
||||||
private Integer dictSort;
|
private Long dictSort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典标签
|
* 字典标签
|
||||||
|
@ -14,7 +14,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,6 +24,7 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("sys_dict_type")
|
@TableName("sys_dict_type")
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@ApiModel("字典类型业务对象")
|
@ApiModel("字典类型业务对象")
|
||||||
@ -54,7 +54,6 @@ public class SysDictType extends BaseEntity {
|
|||||||
@ExcelProperty(value = "字典类型")
|
@ExcelProperty(value = "字典类型")
|
||||||
@NotBlank(message = "字典类型不能为空")
|
@NotBlank(message = "字典类型不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||||
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
|
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package com.ruoyi.common.core.domain.entity;
|
package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
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.ruoyi.common.core.domain.TreeEntity;
|
import com.ruoyi.common.core.domain.TreeEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
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.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,9 +21,10 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("sys_menu")
|
@TableName("sys_menu")
|
||||||
@ApiModel("菜单权限业务对象")
|
@ApiModel("菜单权限业务对象")
|
||||||
public class SysMenu extends TreeEntity<SysMenu> {
|
public class SysMenu extends TreeEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单ID
|
* 菜单ID
|
||||||
@ -44,8 +45,8 @@ public class SysMenu extends TreeEntity<SysMenu> {
|
|||||||
* 显示顺序
|
* 显示顺序
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "显示顺序")
|
@ApiModelProperty(value = "显示顺序")
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
private Integer orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由地址
|
* 路由地址
|
||||||
@ -65,7 +66,8 @@ public class SysMenu extends TreeEntity<SysMenu> {
|
|||||||
* 路由参数
|
* 路由参数
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "路由参数")
|
@ApiModelProperty(value = "路由参数")
|
||||||
private String queryParam;
|
@TableField("`query`")
|
||||||
|
private String query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为外链(0是 1否)
|
* 是否为外链(0是 1否)
|
||||||
@ -102,7 +104,6 @@ public class SysMenu extends TreeEntity<SysMenu> {
|
|||||||
* 权限字符串
|
* 权限字符串
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "权限字符串")
|
@ApiModelProperty(value = "权限字符串")
|
||||||
@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;
|
||||||
|
|
||||||
|
@ -7,16 +7,15 @@ 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.annotation.ExcelDictFormat;
|
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||||
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 io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +27,7 @@ import javax.validation.constraints.Size;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("sys_role")
|
@TableName("sys_role")
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class SysRole extends BaseEntity {
|
public class SysRole extends BaseEntity {
|
||||||
@ -63,8 +63,8 @@ public class SysRole extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "角色排序")
|
@ApiModelProperty(value = "角色排序")
|
||||||
@ExcelProperty(value = "角色排序")
|
@ExcelProperty(value = "角色排序")
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
private Integer roleSort;
|
private String roleSort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
||||||
@ -78,13 +78,13 @@ public class SysRole extends BaseEntity {
|
|||||||
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)")
|
@ApiModelProperty(value = "菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)")
|
||||||
private Boolean menuCheckStrictly;
|
private boolean menuCheckStrictly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )")
|
@ApiModelProperty(value = "部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )")
|
||||||
private Boolean deptCheckStrictly;
|
private boolean deptCheckStrictly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色状态(0正常 1停用)
|
* 角色状态(0正常 1停用)
|
||||||
@ -134,6 +134,11 @@ public class SysRole extends BaseEntity {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "是否管理员")
|
@ApiModelProperty(value = "是否管理员")
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
return UserConstants.ADMIN_ID.equals(this.roleId);
|
return isAdmin(this.roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAdmin(Long roleId) {
|
||||||
|
return roleId != null && 1L == roleId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,14 @@ 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.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.ruoyi.common.annotation.Sensitive;
|
|
||||||
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.xss.Xss;
|
import com.ruoyi.common.xss.Xss;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
@ -29,6 +27,7 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("sys_user")
|
@TableName("sys_user")
|
||||||
@ApiModel("用户信息业务对象")
|
@ApiModel("用户信息业务对象")
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
@ -63,16 +62,9 @@ public class SysUser extends BaseEntity {
|
|||||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(sys_user系统用户)
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户类型")
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户邮箱
|
* 用户邮箱
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.EMAIL)
|
|
||||||
@ApiModelProperty(value = "用户邮箱")
|
@ApiModelProperty(value = "用户邮箱")
|
||||||
@Email(message = "邮箱格式不正确")
|
@Email(message = "邮箱格式不正确")
|
||||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||||
@ -81,7 +73,6 @@ public class SysUser extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.PHONE)
|
|
||||||
@ApiModelProperty(value = "手机号码")
|
@ApiModelProperty(value = "手机号码")
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
@ -108,6 +99,12 @@ public class SysUser extends BaseEntity {
|
|||||||
)
|
)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@JsonProperty
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 帐号状态(0正常 1停用)
|
* 帐号状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@ -180,7 +177,11 @@ public class SysUser extends BaseEntity {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "是否管理员")
|
@ApiModelProperty(value = "是否管理员")
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
return UserConstants.ADMIN_ID.equals(this.userId);
|
return isAdmin(this.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAdmin(Long userId) {
|
||||||
|
return userId != null && 1L == userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录对象
|
* 用户登录对象
|
||||||
@ -15,22 +12,19 @@ import javax.validation.constraints.NotBlank;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
@ApiModel("用户登录对象")
|
@ApiModel("用户登录对象")
|
||||||
public class LoginBody {
|
public class LoginBody {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.username.not.blank}")
|
|
||||||
@Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "{user.username.length.valid}")
|
|
||||||
@ApiModelProperty(value = "用户名")
|
@ApiModelProperty(value = "用户名")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户密码
|
* 用户密码
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.password.not.blank}")
|
|
||||||
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
|
||||||
@ApiModelProperty(value = "用户密码")
|
@ApiModelProperty(value = "用户密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@ -44,6 +38,6 @@ public class LoginBody {
|
|||||||
* 唯一标识
|
* 唯一标识
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "唯一标识")
|
@ApiModelProperty(value = "唯一标识")
|
||||||
private String uuid;
|
private String uuid = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.dto.RoleDTO;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +18,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LoginUser implements Serializable {
|
@Accessors(chain = true)
|
||||||
|
public class LoginUser implements UserDetails {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -31,21 +33,11 @@ public class LoginUser implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门名
|
|
||||||
*/
|
|
||||||
private String deptName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户唯一标识
|
* 用户唯一标识
|
||||||
*/
|
*/
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型
|
|
||||||
*/
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录时间
|
* 登录时间
|
||||||
*/
|
*/
|
||||||
@ -79,12 +71,12 @@ public class LoginUser implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 菜单权限
|
* 菜单权限
|
||||||
*/
|
*/
|
||||||
private Set<String> menuPermission;
|
private Set<String> menuPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
private Set<String> rolePermission;
|
private Set<String> rolePermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
@ -92,20 +84,59 @@ public class LoginUser implements Serializable {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色对象
|
* 密码
|
||||||
*/
|
*/
|
||||||
private List<RoleDTO> roles;
|
private String password;
|
||||||
|
|
||||||
/**
|
@JsonIgnore
|
||||||
* 数据权限 当前角色ID
|
@Override
|
||||||
*/
|
public String getPassword() {
|
||||||
private Long roleId;
|
return password;
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录id
|
|
||||||
*/
|
|
||||||
public String getLoginId() {
|
|
||||||
return userType + LoginHelper.JOIN_CODE + userId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账户是否未过期,过期无法验证
|
||||||
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public boolean isAccountNonExpired() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定用户是否解锁,锁定的用户无法进行身份验证
|
||||||
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public boolean isAccountNonLocked() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
|
||||||
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public boolean isCredentialsNonExpired() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否可用 ,禁用的用户不能身份验证
|
||||||
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户注册对象
|
* 用户注册对象
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ApiModel("用户注册对象")
|
@ApiModel("用户注册对象")
|
||||||
public class RegisterBody extends LoginBody {
|
public class RegisterBody extends LoginBody {
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户类型")
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信登录对象
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@ApiModel("短信登录对象")
|
|
||||||
public class SmsLoginBody {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
|
||||||
@ApiModelProperty(value = "用户手机号")
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户密码
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{sms.code.not.blank}")
|
|
||||||
@ApiModelProperty(value = "短信验证码")
|
|
||||||
private String smsCode;
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.ruoyi.common.core.domain.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序登录用户身份权限
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class XcxLoginUser extends LoginUser {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* openid
|
|
||||||
*/
|
|
||||||
private String openid;
|
|
||||||
|
|
||||||
}
|
|
@ -1,229 +0,0 @@
|
|||||||
package com.ruoyi.common.core.mapper;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.*;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
||||||
import com.ruoyi.common.utils.BeanCopyUtils;
|
|
||||||
import org.apache.ibatis.binding.MapperMethod;
|
|
||||||
import org.apache.ibatis.logging.Log;
|
|
||||||
import org.apache.ibatis.logging.LogFactory;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义 Mapper 接口, 实现 自定义扩展
|
|
||||||
*
|
|
||||||
* @param <M> mapper 泛型
|
|
||||||
* @param <T> table 泛型
|
|
||||||
* @param <V> vo 泛型
|
|
||||||
* @author Lion Li
|
|
||||||
* @since 2021-05-13
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
|
|
||||||
|
|
||||||
Log log = LogFactory.getLog(BaseMapperPlus.class);
|
|
||||||
|
|
||||||
int DEFAULT_BATCH_SIZE = 1000;
|
|
||||||
|
|
||||||
default Class<V> currentVoClass() {
|
|
||||||
return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
default Class<T> currentModelClass() {
|
|
||||||
return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
default Class<M> currentMapperClass() {
|
|
||||||
return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<T> selectList() {
|
|
||||||
return this.selectList(new QueryWrapper<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入
|
|
||||||
*/
|
|
||||||
default boolean insertBatch(Collection<T> entityList) {
|
|
||||||
return insertBatch(entityList, DEFAULT_BATCH_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量更新
|
|
||||||
*/
|
|
||||||
default boolean updateBatchById(Collection<T> entityList) {
|
|
||||||
return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入或更新
|
|
||||||
*/
|
|
||||||
default boolean insertOrUpdateBatch(Collection<T> entityList) {
|
|
||||||
return insertOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入(包含限制条数)
|
|
||||||
*/
|
|
||||||
default boolean insertBatch(Collection<T> entityList, int batchSize) {
|
|
||||||
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.INSERT_ONE);
|
|
||||||
return SqlHelper.executeBatch(this.currentModelClass(), log, entityList, batchSize,
|
|
||||||
(sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量更新(包含限制条数)
|
|
||||||
*/
|
|
||||||
default boolean updateBatchById(Collection<T> entityList, int batchSize) {
|
|
||||||
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.UPDATE_BY_ID);
|
|
||||||
return SqlHelper.executeBatch(this.currentModelClass(), log, entityList, batchSize,
|
|
||||||
(sqlSession, entity) -> {
|
|
||||||
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
|
||||||
param.put(Constants.ENTITY, entity);
|
|
||||||
sqlSession.update(sqlStatement, param);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入或更新(包含限制条数)
|
|
||||||
*/
|
|
||||||
default boolean insertOrUpdateBatch(Collection<T> entityList, int batchSize) {
|
|
||||||
TableInfo tableInfo = TableInfoHelper.getTableInfo(this.currentModelClass());
|
|
||||||
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
|
||||||
String keyProperty = tableInfo.getKeyProperty();
|
|
||||||
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
|
||||||
return SqlHelper.saveOrUpdateBatch(this.currentModelClass(), this.currentMapperClass(), log, entityList, batchSize, (sqlSession, entity) -> {
|
|
||||||
Object idVal = tableInfo.getPropertyValue(entity, keyProperty);
|
|
||||||
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.SELECT_BY_ID);
|
|
||||||
return StringUtils.checkValNull(idVal)
|
|
||||||
|| CollectionUtils.isEmpty(sqlSession.selectList(sqlStatement, entity));
|
|
||||||
}, (sqlSession, entity) -> {
|
|
||||||
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
|
||||||
param.put(Constants.ENTITY, entity);
|
|
||||||
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.UPDATE_BY_ID);
|
|
||||||
sqlSession.update(sqlStatement, param);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 插入或更新(包含限制条数)
|
|
||||||
*/
|
|
||||||
default boolean insertOrUpdate(T entity) {
|
|
||||||
if (null != entity) {
|
|
||||||
TableInfo tableInfo = TableInfoHelper.getTableInfo(this.currentModelClass());
|
|
||||||
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
|
||||||
String keyProperty = tableInfo.getKeyProperty();
|
|
||||||
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
|
||||||
Object idVal = tableInfo.getPropertyValue(entity, tableInfo.getKeyProperty());
|
|
||||||
return StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal)) ? insert(entity) > 0 : updateById(entity) > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default V selectVoById(Serializable id) {
|
|
||||||
return selectVoById(id, this.currentVoClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 ID 查询
|
|
||||||
*/
|
|
||||||
default <C> C selectVoById(Serializable id, Class<C> voClass) {
|
|
||||||
T obj = this.selectById(id);
|
|
||||||
if (ObjectUtil.isNull(obj)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copy(obj, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<V> selectVoById(Collection<? extends Serializable> idList) {
|
|
||||||
return selectVoBatchIds(idList, this.currentVoClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询(根据ID 批量查询)
|
|
||||||
*/
|
|
||||||
default <C> List<C> selectVoBatchIds(Collection<? extends Serializable> idList, Class<C> voClass) {
|
|
||||||
List<T> list = this.selectBatchIds(idList);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return CollUtil.newArrayList();
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copyList(list, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<V> selectVoByMap(Map<String, Object> map) {
|
|
||||||
return selectVoByMap(map, this.currentVoClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询(根据 columnMap 条件)
|
|
||||||
*/
|
|
||||||
default <C> List<C> selectVoByMap(Map<String, Object> map, Class<C> voClass) {
|
|
||||||
List<T> list = this.selectByMap(map);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return CollUtil.newArrayList();
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copyList(list, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
default V selectVoOne(Wrapper<T> wrapper) {
|
|
||||||
return selectVoOne(wrapper, this.currentVoClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 entity 条件,查询一条记录
|
|
||||||
*/
|
|
||||||
default <C> C selectVoOne(Wrapper<T> wrapper, Class<C> voClass) {
|
|
||||||
T obj = this.selectOne(wrapper);
|
|
||||||
if (ObjectUtil.isNull(obj)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copy(obj, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<V> selectVoList(Wrapper<T> wrapper) {
|
|
||||||
return selectVoList(wrapper, this.currentVoClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 entity 条件,查询全部记录
|
|
||||||
*/
|
|
||||||
default <C> List<C> selectVoList(Wrapper<T> wrapper, Class<C> voClass) {
|
|
||||||
List<T> list = this.selectList(wrapper);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return CollUtil.newArrayList();
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copyList(list, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
default <P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper) {
|
|
||||||
return selectVoPage(page, wrapper, this.currentVoClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询VO
|
|
||||||
*/
|
|
||||||
default <C, P extends IPage<C>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<C> voClass) {
|
|
||||||
IPage<T> pageData = this.selectPage(page, wrapper);
|
|
||||||
IPage<C> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal());
|
|
||||||
if (CollUtil.isEmpty(pageData.getRecords())) {
|
|
||||||
return (P) voPage;
|
|
||||||
}
|
|
||||||
voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass));
|
|
||||||
return (P) voPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,98 @@
|
|||||||
|
package com.ruoyi.common.core.mybatisplus.core;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 Mapper 接口, 实现 自定义扩展
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
* @since 2021-05-13
|
||||||
|
*/
|
||||||
|
public interface BaseMapperPlus<T> extends BaseMapper<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单sql批量插入( 全量填充 )
|
||||||
|
*/
|
||||||
|
int insertAll(@Param("list") Collection<T> batchList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ID 查询
|
||||||
|
*/
|
||||||
|
default <V> V selectVoById(Serializable id, Class<V> voClass){
|
||||||
|
T obj = this.selectById(id);
|
||||||
|
if (ObjectUtil.isNull(obj)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copy(obj, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据ID 批量查询)
|
||||||
|
*/
|
||||||
|
default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass){
|
||||||
|
List<T> list = this.selectBatchIds(idList);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copyList(list, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据 columnMap 条件)
|
||||||
|
*/
|
||||||
|
default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass){
|
||||||
|
List<T> list = this.selectByMap(map);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copyList(list, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 entity 条件,查询一条记录
|
||||||
|
*/
|
||||||
|
default <V> V selectVoOne(Wrapper<T> wrapper, Class<V> voClass) {
|
||||||
|
T obj = this.selectOne(wrapper);
|
||||||
|
if (ObjectUtil.isNull(obj)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copy(obj, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 entity 条件,查询全部记录
|
||||||
|
*/
|
||||||
|
default <V> List<V> selectVoList(Wrapper<T> wrapper, Class<V> voClass) {
|
||||||
|
List<T> list = this.selectList(wrapper);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copyList(list, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询VO
|
||||||
|
*/
|
||||||
|
default <V, P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<V> voClass) {
|
||||||
|
IPage<T> pageData = this.selectPage(page, wrapper);
|
||||||
|
IPage<V> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal());
|
||||||
|
if (CollUtil.isEmpty(pageData.getRecords())) {
|
||||||
|
return (P) voPage;
|
||||||
|
}
|
||||||
|
voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass));
|
||||||
|
return (P) voPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
package com.ruoyi.common.core.mybatisplus.core;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.common.core.page.PagePlus;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 Service 接口, 实现 数据库实体与 vo 对象转换返回
|
||||||
|
*
|
||||||
|
* @param <T> 数据实体类
|
||||||
|
* @param <V> vo类
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface IServicePlus<T, V> extends IService<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id 主键id
|
||||||
|
* @return V对象
|
||||||
|
*/
|
||||||
|
V getVoById(Serializable id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
*/
|
||||||
|
default V getVoById(Serializable id, Function<T, V> convertor) {
|
||||||
|
return convertor.apply(getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param idList id列表
|
||||||
|
* @return V对象
|
||||||
|
*/
|
||||||
|
List<V> listVoByIds(Collection<? extends Serializable> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
*/
|
||||||
|
default List<V> listVoByIds(Collection<? extends Serializable> idList,
|
||||||
|
Function<Collection<T>, List<V>> convertor) {
|
||||||
|
List<T> list = getBaseMapper().selectBatchIds(idList);
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertor.apply(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param columnMap 表字段 map 对象
|
||||||
|
* @return V对象
|
||||||
|
*/
|
||||||
|
List<V> listVoByMap(Map<String, Object> columnMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
*/
|
||||||
|
default List<V> listVoByMap(Map<String, Object> columnMap,
|
||||||
|
Function<Collection<T>, List<V>> convertor) {
|
||||||
|
List<T> list = getBaseMapper().selectByMap(columnMap);
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertor.apply(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param queryWrapper 查询条件
|
||||||
|
* @return V对象
|
||||||
|
*/
|
||||||
|
V getVoOne(Wrapper<T> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
*/
|
||||||
|
default V getVoOne(Wrapper<T> queryWrapper, Function<T, V> convertor) {
|
||||||
|
return convertor.apply(getOne(queryWrapper, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param queryWrapper 查询条件
|
||||||
|
* @return V对象
|
||||||
|
*/
|
||||||
|
List<V> listVo(Wrapper<T> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
*/
|
||||||
|
default List<V> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<V>> convertor) {
|
||||||
|
List<T> list = getBaseMapper().selectList(queryWrapper);
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertor.apply(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<V> listVo() {
|
||||||
|
return listVo(Wrappers.emptyWrapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
*/
|
||||||
|
default List<V> listVo(Function<Collection<T>, List<V>> convertor) {
|
||||||
|
return listVo(Wrappers.emptyWrapper(), convertor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param page 分页对象
|
||||||
|
* @param queryWrapper 查询条件
|
||||||
|
* @return V对象
|
||||||
|
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper,
|
||||||
|
Function<Collection<T>, List<V>> convertor) {
|
||||||
|
PagePlus<T, V> result = getBaseMapper().selectPage(page, queryWrapper);
|
||||||
|
return result.setRecordsVo(convertor.apply(result.getRecords()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default PagePlus<T, V> pageVo(PagePlus<T, V> page) {
|
||||||
|
return pageVo(page, Wrappers.emptyWrapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param convertor 自定义转换器
|
||||||
|
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default PagePlus<T, V> pageVo(PagePlus<T, V> page, Function<Collection<T>, List<V>> convertor) {
|
||||||
|
return pageVo(page, Wrappers.emptyWrapper(), convertor);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean saveAll(Collection<T> entityList);
|
||||||
|
|
||||||
|
boolean saveOrUpdateAll(Collection<T> entityList);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,226 @@
|
|||||||
|
package com.ruoyi.common.core.mybatisplus.core;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.page.PagePlus;
|
||||||
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
||||||
|
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IServicePlus 实现类
|
||||||
|
*
|
||||||
|
* @param <M> Mapper类
|
||||||
|
* @param <T> 数据实体类
|
||||||
|
* @param <V> vo类
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceImpl<M, T> implements IServicePlus<T, V> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected M baseMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public M getBaseMapper() {
|
||||||
|
return baseMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected Class<T> entityClass = currentModelClass();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<T> getEntityClass() {
|
||||||
|
return entityClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Class<M> mapperClass = currentMapperClass();
|
||||||
|
|
||||||
|
protected Class<V> voClass = currentVoClass();
|
||||||
|
|
||||||
|
public Class<V> getVoClass() {
|
||||||
|
return voClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<M> currentMapperClass() {
|
||||||
|
return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<T> currentModelClass() {
|
||||||
|
return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Class<V> currentVoClass() {
|
||||||
|
return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条执行性能差 适用于列表对象内容不确定
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveBatch(Collection<T> entityList, int batchSize) {
|
||||||
|
return super.saveBatch(entityList, batchSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveOrUpdate(T entity) {
|
||||||
|
return super.saveOrUpdate(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条执行性能差 适用于列表对象内容不确定
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {
|
||||||
|
return super.saveOrUpdateBatch(entityList, batchSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateBatchById(Collection<T> entityList, int batchSize) {
|
||||||
|
return super.updateBatchById(entityList, batchSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单sql批量插入( 全量填充 无视数据库默认值 )
|
||||||
|
* 适用于无脑插入
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveBatch(Collection<T> entityList) {
|
||||||
|
return saveBatch(entityList, DEFAULT_BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveOrUpdateBatch(Collection<T> entityList) {
|
||||||
|
return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateBatchById(Collection<T> entityList) {
|
||||||
|
return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单sql批量插入( 全量填充 )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveAll(Collection<T> entityList) {
|
||||||
|
if (CollUtil.isEmpty(entityList)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return baseMapper.insertAll(entityList) == entityList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全量保存或更新 ( 按主键区分 )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveOrUpdateAll(Collection<T> entityList) {
|
||||||
|
if (CollUtil.isEmpty(entityList)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
|
||||||
|
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
||||||
|
String keyProperty = tableInfo.getKeyProperty();
|
||||||
|
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
||||||
|
List<T> addList = new ArrayList<>();
|
||||||
|
List<T> updateList = new ArrayList<>();
|
||||||
|
int row = 0;
|
||||||
|
for (T entity : entityList) {
|
||||||
|
Object id = ReflectUtils.invokeGetter(entity, keyProperty);
|
||||||
|
if (ObjectUtil.isNull(id)) {
|
||||||
|
addList.add(entity);
|
||||||
|
} else {
|
||||||
|
updateList.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) {
|
||||||
|
row += updateList.size();
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(addList)) {
|
||||||
|
row += baseMapper.insertAll(addList);
|
||||||
|
}
|
||||||
|
return row == entityList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ID 查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public V getVoById(Serializable id) {
|
||||||
|
return getBaseMapper().selectVoById(id, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据ID 批量查询)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<V> listVoByIds(Collection<? extends Serializable> idList) {
|
||||||
|
return getBaseMapper().selectVoBatchIds(idList, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据 columnMap 条件)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<V> listVoByMap(Map<String, Object> columnMap) {
|
||||||
|
return getBaseMapper().selectVoByMap(columnMap, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 Wrapper,查询一条记录 <br/>
|
||||||
|
* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public V getVoOne(Wrapper<T> queryWrapper) {
|
||||||
|
return getBaseMapper().selectVoOne(queryWrapper, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<V> listVo(Wrapper<T> queryWrapper) {
|
||||||
|
return getBaseMapper().selectVoList(queryWrapper, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻页查询
|
||||||
|
* @deprecated 3.6.0 移除 请使用 {@link #pageVo(IPage, Wrapper)}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper) {
|
||||||
|
PagePlus<T, V> result = getBaseMapper().selectPage(page, queryWrapper);
|
||||||
|
List<V> volist = BeanCopyUtils.copyList(result.getRecords(), voClass);
|
||||||
|
result.setRecordsVo(volist);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻页查询
|
||||||
|
*
|
||||||
|
* @param page 翻页对象
|
||||||
|
* @param queryWrapper 实体对象封装操作类
|
||||||
|
*/
|
||||||
|
public <P extends IPage<V>> P pageVo(IPage<T> page, Wrapper<T> queryWrapper) {
|
||||||
|
return getBaseMapper().selectVoPage(page, queryWrapper, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.ruoyi.common.core.mybatisplus.methods;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
|
||||||
|
import org.apache.ibatis.executor.keygen.KeyGenerator;
|
||||||
|
import org.apache.ibatis.executor.keygen.NoKeyGenerator;
|
||||||
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
|
import org.apache.ibatis.mapping.SqlSource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单sql批量插入( 全量填充 )
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public class InsertAll extends AbstractMethod {
|
||||||
|
|
||||||
|
private final static String[] FILL_PROPERTY = {"createTime", "createBy", "updateTime", "updateBy"};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
||||||
|
final String sql = "<script>insert into %s %s values %s</script>";
|
||||||
|
final String fieldSql = prepareFieldSql(tableInfo);
|
||||||
|
final String valueSql = prepareValuesSqlForMysqlBatch(tableInfo);
|
||||||
|
KeyGenerator keyGenerator = new NoKeyGenerator();
|
||||||
|
String sqlMethod = "insertAll";
|
||||||
|
String keyProperty = null;
|
||||||
|
String keyColumn = null;
|
||||||
|
// 表包含主键处理逻辑,如果不包含主键当普通字段处理
|
||||||
|
if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) {
|
||||||
|
if (tableInfo.getIdType() == IdType.AUTO) {
|
||||||
|
/** 自增主键 */
|
||||||
|
keyGenerator = new Jdbc3KeyGenerator();
|
||||||
|
keyProperty = tableInfo.getKeyProperty();
|
||||||
|
keyColumn = tableInfo.getKeyColumn();
|
||||||
|
} else {
|
||||||
|
if (null != tableInfo.getKeySequence()) {
|
||||||
|
keyGenerator = TableInfoHelper.genKeyGenerator(sqlMethod, tableInfo, builderAssistant);
|
||||||
|
keyProperty = tableInfo.getKeyProperty();
|
||||||
|
keyColumn = tableInfo.getKeyColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final String sqlResult = String.format(sql, tableInfo.getTableName(), fieldSql, valueSql);
|
||||||
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass);
|
||||||
|
return this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod, sqlSource, keyGenerator, keyProperty, keyColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String prepareFieldSql(TableInfo tableInfo) {
|
||||||
|
StringBuilder fieldSql = new StringBuilder();
|
||||||
|
if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) {
|
||||||
|
fieldSql.append(tableInfo.getKeyColumn()).append(",");
|
||||||
|
}
|
||||||
|
tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(","));
|
||||||
|
fieldSql.delete(fieldSql.length() - 1, fieldSql.length());
|
||||||
|
fieldSql.insert(0, "(");
|
||||||
|
fieldSql.append(")");
|
||||||
|
return fieldSql.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String prepareValuesSqlForMysqlBatch(TableInfo tableInfo) {
|
||||||
|
final StringBuilder valueSql = new StringBuilder();
|
||||||
|
valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">");
|
||||||
|
if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) {
|
||||||
|
valueSql.append("\n#{item.").append(tableInfo.getKeyProperty()).append("},\n");
|
||||||
|
}
|
||||||
|
List<TableFieldInfo> fieldList = tableInfo.getFieldList();
|
||||||
|
int last = fieldList.size() - 1;
|
||||||
|
for (int i = 0; i < fieldList.size(); i++) {
|
||||||
|
String property = fieldList.get(i).getProperty();
|
||||||
|
if (!StringUtils.equalsAny(property, FILL_PROPERTY)) {
|
||||||
|
valueSql.append("<if test=\"item.").append(property).append(" != null\">");
|
||||||
|
valueSql.append("#{item.").append(property).append("}");
|
||||||
|
if (i != last) {
|
||||||
|
valueSql.append(",");
|
||||||
|
}
|
||||||
|
valueSql.append("</if>");
|
||||||
|
valueSql.append("<if test=\"item.").append(property).append(" == null\">");
|
||||||
|
valueSql.append("DEFAULT");
|
||||||
|
if (i != last) {
|
||||||
|
valueSql.append(",");
|
||||||
|
}
|
||||||
|
valueSql.append("</if>");
|
||||||
|
} else {
|
||||||
|
valueSql.append("#{item.").append(property).append("}");
|
||||||
|
if (i != last) {
|
||||||
|
valueSql.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valueSql.append("</foreach>");
|
||||||
|
return valueSql.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,158 @@
|
|||||||
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页 Page 增强对象
|
||||||
|
*
|
||||||
|
* @param <T> 数据库实体
|
||||||
|
* @param <K> vo实体
|
||||||
|
* @author Lion Li
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link com.ruoyi.common.core.domain.PageQuery#build()}
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Deprecated
|
||||||
|
public class PagePlus<T,K> implements IPage<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* domain实体列表
|
||||||
|
*/
|
||||||
|
private List<T> records = Collections.emptyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vo实体列表
|
||||||
|
*/
|
||||||
|
private List<K> recordsVo = Collections.emptyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总数
|
||||||
|
*/
|
||||||
|
private long total = 0L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页长度
|
||||||
|
*/
|
||||||
|
private long size = 10L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前页
|
||||||
|
*/
|
||||||
|
private long current = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序字段信息
|
||||||
|
*/
|
||||||
|
private List<OrderItem> orders = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动优化 COUNT SQL
|
||||||
|
*/
|
||||||
|
private boolean optimizeCountSql = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否进行 count 查询
|
||||||
|
*/
|
||||||
|
private boolean isSearchCount = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否命中count缓存
|
||||||
|
*/
|
||||||
|
private boolean hitCount = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* countId
|
||||||
|
*/
|
||||||
|
private String countId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大limit
|
||||||
|
*/
|
||||||
|
private Long maxLimit;
|
||||||
|
|
||||||
|
public PagePlus() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagePlus(long current, long size) {
|
||||||
|
this(current, size, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagePlus(long current, long size, long total) {
|
||||||
|
this(current, size, total, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagePlus(long current, long size, boolean isSearchCount) {
|
||||||
|
this(current, size, 0L, isSearchCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagePlus(long current, long size, long total, boolean isSearchCount) {
|
||||||
|
if (current > 1L) {
|
||||||
|
this.current = current;
|
||||||
|
}
|
||||||
|
this.size = size;
|
||||||
|
this.total = total;
|
||||||
|
this.isSearchCount = isSearchCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String countId() {
|
||||||
|
return this.getCountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long maxLimit() {
|
||||||
|
return this.getMaxLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagePlus<T, K> addOrder(OrderItem... items) {
|
||||||
|
this.orders.addAll(Arrays.asList(items));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagePlus<T, K> addOrder(List<OrderItem> items) {
|
||||||
|
this.orders.addAll(items);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderItem> orders() {
|
||||||
|
return this.getOrders();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean optimizeCountSql() {
|
||||||
|
return this.optimizeCountSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getPages() {
|
||||||
|
// 解决 github issues/3208
|
||||||
|
return IPage.super.getPages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T,K> PagePlus<T,K> of(long current, long size) {
|
||||||
|
return of(current, size, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T,K> PagePlus<T,K> of(long current, long size, long total) {
|
||||||
|
return of(current, size, total, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T,K> PagePlus<T,K> of(long current, long size, boolean searchCount) {
|
||||||
|
return of(current, size, 0, searchCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T,K> PagePlus<T,K> of(long current, long size, long total, boolean searchCount) {
|
||||||
|
return new PagePlus<>(current, size, total, searchCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
@ApiModel("分页响应对象")
|
@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;
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.ruoyi.common.core.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏服务
|
|
||||||
* 默认管理员不过滤
|
|
||||||
* 需自行根据业务重写实现
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
* @version 3.6.0
|
|
||||||
*/
|
|
||||||
public interface SensitiveService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否脱敏
|
|
||||||
*/
|
|
||||||
boolean isSensitive();
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.ruoyi.common.core.service;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token验证处理
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface TokenService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户身份信息
|
||||||
|
*
|
||||||
|
* @return 用户信息
|
||||||
|
*/
|
||||||
|
LoginUser getLoginUser(HttpServletRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置用户身份信息
|
||||||
|
*/
|
||||||
|
void setLoginUser(LoginUser loginUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户身份信息
|
||||||
|
*/
|
||||||
|
void delLoginUser(String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建令牌
|
||||||
|
*
|
||||||
|
* @param loginUser 用户信息
|
||||||
|
* @return 令牌
|
||||||
|
*/
|
||||||
|
String createToken(LoginUser loginUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证令牌有效期,相差不足20分钟,自动刷新缓存
|
||||||
|
*
|
||||||
|
* @param loginUser
|
||||||
|
* @return 令牌
|
||||||
|
*/
|
||||||
|
void verifyToken(LoginUser loginUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新令牌有效期
|
||||||
|
*
|
||||||
|
* @param loginUser 登录信息
|
||||||
|
*/
|
||||||
|
void refreshToken(LoginUser loginUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置用户代理信息
|
||||||
|
*
|
||||||
|
* @param loginUser 登录信息
|
||||||
|
*/
|
||||||
|
void setUserAgent(LoginUser loginUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从令牌中获取用户名
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @return 用户名
|
||||||
|
*/
|
||||||
|
String getUsernameFromToken(String token);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.ruoyi.common.core.service;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用 用户业务
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface UserService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
SysUser selectUserByUserName(String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户ID查询用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
SysUser selectUserById(Long userId);
|
||||||
|
|
||||||
|
}
|
@ -1,49 +0,0 @@
|
|||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库类型
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum DataBaseType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MySQL
|
|
||||||
*/
|
|
||||||
MY_SQL("MySQL"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Oracle
|
|
||||||
*/
|
|
||||||
ORACLE("Oracle"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PostgreSQL
|
|
||||||
*/
|
|
||||||
POSTGRE_SQL("PostgreSQL"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL Server
|
|
||||||
*/
|
|
||||||
SQL_SERVER("Microsoft SQL Server");
|
|
||||||
|
|
||||||
private final String type;
|
|
||||||
|
|
||||||
public static DataBaseType find(String databaseProductName) {
|
|
||||||
if (StringUtils.isBlank(databaseProductName)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (DataBaseType type : values()) {
|
|
||||||
if (type.getType().equals(databaseProductName)) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,10 +6,10 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限类型
|
* 数据权限类型
|
||||||
* <p>
|
*
|
||||||
* 语法支持 spel 模板表达式
|
* 语法支持 spel 模板表达式
|
||||||
* <p>
|
*
|
||||||
* 内置数据 user 当前用户 内容参考 LoginUser
|
* 内置数据 user 当前用户 内容参考 SysUser
|
||||||
* 如需扩展数据 可使用 {@link com.ruoyi.common.helper.DataPermissionHelper} 操作
|
* 如需扩展数据 可使用 {@link com.ruoyi.common.helper.DataPermissionHelper} 操作
|
||||||
* 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService
|
* 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService
|
||||||
* 如需扩展更多自定义服务 可以参考 sdss 自行编写
|
* 如需扩展更多自定义服务 可以参考 sdss 自行编写
|
||||||
@ -44,7 +44,7 @@ public enum DataScopeType {
|
|||||||
/**
|
/**
|
||||||
* 仅本人数据权限
|
* 仅本人数据权限
|
||||||
*/
|
*/
|
||||||
SELF("5", " #{#userName} = #{#user.userId} ", " 1 = 0 ");
|
SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 ");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
* @deprecated 3.6.0 移除
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Deprecated
|
||||||
|
public enum DataSourceType {
|
||||||
|
/**
|
||||||
|
* 主库
|
||||||
|
*/
|
||||||
|
MASTER("master"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从库
|
||||||
|
*/
|
||||||
|
SLAVE("slave");
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final String source;
|
||||||
|
}
|
@ -1,32 +0,0 @@
|
|||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备类型
|
|
||||||
* 针对一套 用户体系
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum DeviceType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pc端
|
|
||||||
*/
|
|
||||||
PC("pc"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* app端
|
|
||||||
*/
|
|
||||||
APP("app"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序端
|
|
||||||
*/
|
|
||||||
XCX("xcx");
|
|
||||||
|
|
||||||
private final String device;
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录类型
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum LoginType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码登录
|
|
||||||
*/
|
|
||||||
PASSWORD("user.password.retry.limit.exceed", "user.password.retry.limit.count"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信登录
|
|
||||||
*/
|
|
||||||
SMS("sms.code.retry.limit.exceed", "sms.code.retry.limit.count"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序登录
|
|
||||||
*/
|
|
||||||
XCX("", "");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录重试超出限制提示
|
|
||||||
*/
|
|
||||||
final String retryLimitExceed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录重试限制计数提示
|
|
||||||
*/
|
|
||||||
final String retryLimitCount;
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.DesensitizedUtil;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏策略
|
|
||||||
*
|
|
||||||
* @author Yjoioooo
|
|
||||||
* @version 3.6.0
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum SensitiveStrategy {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 身份证脱敏
|
|
||||||
*/
|
|
||||||
ID_CARD(s -> DesensitizedUtil.idCardNum(s, 3, 4)),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号脱敏
|
|
||||||
*/
|
|
||||||
PHONE(DesensitizedUtil::mobilePhone),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 地址脱敏
|
|
||||||
*/
|
|
||||||
ADDRESS(s -> DesensitizedUtil.address(s, 8)),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱脱敏
|
|
||||||
*/
|
|
||||||
EMAIL(DesensitizedUtil::email),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 银行卡
|
|
||||||
*/
|
|
||||||
BANK_CARD(DesensitizedUtil::bankCard);
|
|
||||||
|
|
||||||
//可自行添加其他脱敏策略
|
|
||||||
|
|
||||||
private final Function<String, String> desensitizer;
|
|
||||||
|
|
||||||
public Function<String, String> desensitizer() {
|
|
||||||
return desensitizer;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.concurrent.RejectedExecutionHandler;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程池 拒绝策略 泛型
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum ThreadPoolRejectedPolicy {
|
||||||
|
|
||||||
|
CALLER_RUNS_POLICY("调用方执行", ThreadPoolExecutor.CallerRunsPolicy.class),
|
||||||
|
DISCARD_OLDEST_POLICY("放弃最旧的", ThreadPoolExecutor.DiscardOldestPolicy.class),
|
||||||
|
DISCARD_POLICY("丢弃", ThreadPoolExecutor.DiscardPolicy.class),
|
||||||
|
ABORT_POLICY("中止", ThreadPoolExecutor.AbortPolicy.class);
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final Class<? extends RejectedExecutionHandler> clazz;
|
||||||
|
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备类型
|
|
||||||
* 针对多套 用户体系
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum UserType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pc端
|
|
||||||
*/
|
|
||||||
SYS_USER("sys_user"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* app端
|
|
||||||
*/
|
|
||||||
APP_USER("app_user");
|
|
||||||
|
|
||||||
private final String userType;
|
|
||||||
|
|
||||||
public static UserType getUserType(String str) {
|
|
||||||
for (UserType value : values()) {
|
|
||||||
if (StringUtils.contains(str, value.getUserType())) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new RuntimeException("'UserType' not found By " + str);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package com.ruoyi.common.excel;
|
|
||||||
|
|
||||||
import com.alibaba.excel.metadata.Head;
|
|
||||||
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
|
||||||
import com.ruoyi.common.annotation.CellMerge;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列值重复合并策略
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class CellMergeStrategy extends AbstractMergeStrategy {
|
|
||||||
|
|
||||||
private List<?> list;
|
|
||||||
private boolean hasTitle;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
|
|
||||||
List<CellRangeAddress> cellList = handle(list, hasTitle);
|
|
||||||
// judge the list is not null
|
|
||||||
if (CollectionUtils.isNotEmpty(cellList)) {
|
|
||||||
// the judge is necessary
|
|
||||||
if (cell.getRowIndex() == 1 && cell.getColumnIndex() == 0) {
|
|
||||||
for (CellRangeAddress item : cellList) {
|
|
||||||
sheet.addMergedRegion(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
private static List<CellRangeAddress> handle(List<?> list, boolean hasTitle) {
|
|
||||||
List<CellRangeAddress> cellList = new ArrayList<>();
|
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
|
||||||
return cellList;
|
|
||||||
}
|
|
||||||
Class<?> clazz = list.get(0).getClass();
|
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
|
||||||
// 有注解的字段
|
|
||||||
List<Field> mergeFields = new ArrayList<>();
|
|
||||||
List<Integer> mergeFieldsIndex = new ArrayList<>();
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
Field field = fields[i];
|
|
||||||
if (field.isAnnotationPresent(CellMerge.class)) {
|
|
||||||
CellMerge cm = field.getAnnotation(CellMerge.class);
|
|
||||||
mergeFields.add(field);
|
|
||||||
mergeFieldsIndex.add(cm.index() == -1 ? i : cm.index());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 行合并开始下标
|
|
||||||
int rowIndex = hasTitle ? 1 : 0;
|
|
||||||
Map<Field, RepeatCell> map = new HashMap<>();
|
|
||||||
// 生成两两合并单元格
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
for (int j = 0; j < mergeFields.size(); j++) {
|
|
||||||
Field field = mergeFields.get(j);
|
|
||||||
String name = field.getName();
|
|
||||||
String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
|
|
||||||
Method readMethod = clazz.getMethod(methodName);
|
|
||||||
Object val = readMethod.invoke(list.get(i));
|
|
||||||
|
|
||||||
int colNum = mergeFieldsIndex.get(j);
|
|
||||||
if (!map.containsKey(field)) {
|
|
||||||
map.put(field, new RepeatCell(val, i));
|
|
||||||
} else {
|
|
||||||
RepeatCell repeatCell = map.get(field);
|
|
||||||
Object cellValue = repeatCell.getValue();
|
|
||||||
if (cellValue == null || "".equals(cellValue)) {
|
|
||||||
// 空值跳过不合并
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (cellValue != val) {
|
|
||||||
if (i - repeatCell.getCurrent() > 1) {
|
|
||||||
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
|
|
||||||
}
|
|
||||||
map.put(field, new RepeatCell(val, i));
|
|
||||||
} else if (i == list.size() - 1) {
|
|
||||||
if (i > repeatCell.getCurrent()) {
|
|
||||||
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cellList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
static class RepeatCell {
|
|
||||||
|
|
||||||
private Object value;
|
|
||||||
|
|
||||||
private int current;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,9 +2,7 @@ package com.ruoyi.common.exception.base;
|
|||||||
|
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础异常
|
* 基础异常
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
package com.ruoyi.common.helper;
|
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
|
||||||
import com.ruoyi.common.enums.DataBaseType;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DatabaseMetaData;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库助手
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class DataBaseHelper {
|
|
||||||
|
|
||||||
private static final DynamicRoutingDataSource DS = SpringUtils.getBean(DynamicRoutingDataSource.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前数据库类型
|
|
||||||
*/
|
|
||||||
public static DataBaseType getDataBaseType() {
|
|
||||||
DataSource dataSource = DS.determineDataSource();
|
|
||||||
try (Connection conn = dataSource.getConnection()) {
|
|
||||||
DatabaseMetaData metaData = conn.getMetaData();
|
|
||||||
String databaseProductName = metaData.getDatabaseProductName();
|
|
||||||
return DataBaseType.find(databaseProductName);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new ServiceException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isMySql() {
|
|
||||||
return DataBaseType.MY_SQL == getDataBaseType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isOracle() {
|
|
||||||
return DataBaseType.ORACLE == getDataBaseType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPostgerSql() {
|
|
||||||
return DataBaseType.POSTGRE_SQL == getDataBaseType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSqlServer() {
|
|
||||||
return DataBaseType.SQL_SERVER == getDataBaseType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String findInSet(Object var1, String var2) {
|
|
||||||
DataBaseType dataBasyType = getDataBaseType();
|
|
||||||
String var = Convert.toStr(var1);
|
|
||||||
if (dataBasyType == DataBaseType.SQL_SERVER) {
|
|
||||||
// charindex(',100,' , ',0,100,101,') <> 0
|
|
||||||
return "charindex('," + var + ",' , ','+" + var2 + "+',') <> 0";
|
|
||||||
} else if (dataBasyType == DataBaseType.POSTGRE_SQL) {
|
|
||||||
// (select position(',100,' in ',0,100,101,')) <> 0
|
|
||||||
return "(select position('," + var + ",' in ','||" + var2 + "||',')) <> 0";
|
|
||||||
} else if (dataBasyType == DataBaseType.ORACLE) {
|
|
||||||
// instr(',0,100,101,' , ',100,') <> 0
|
|
||||||
return "instr(','||" + var2 + "||',' , '," + var + ",') <> 0";
|
|
||||||
}
|
|
||||||
// find_in_set(100 , '0,100,101')
|
|
||||||
return "find_in_set(" + var + " , " + var2 + ") <> 0";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,9 @@
|
|||||||
package com.ruoyi.common.helper;
|
package com.ruoyi.common.helper;
|
||||||
|
|
||||||
import cn.dev33.satoken.context.SaHolder;
|
|
||||||
import cn.dev33.satoken.context.model.SaStorage;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.AccessLevel;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -15,7 +13,6 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @version 3.5.0
|
* @version 3.5.0
|
||||||
*/
|
*/
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
@SuppressWarnings("unchecked cast")
|
@SuppressWarnings("unchecked cast")
|
||||||
public class DataPermissionHelper {
|
public class DataPermissionHelper {
|
||||||
|
|
||||||
@ -27,17 +24,18 @@ public class DataPermissionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void setVariable(String key, Object value) {
|
public static void setVariable(String key, Object value) {
|
||||||
Map<String, Object> context = getContext();
|
Map<String, Object> context = getContext();
|
||||||
context.put(key, value);
|
context.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> getContext() {
|
public static Map<String, Object> getContext() {
|
||||||
SaStorage saStorage = SaHolder.getStorage();
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
Object attribute = saStorage.get(DATA_PERMISSION_KEY);
|
Object attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
||||||
if (ObjectUtil.isNull(attribute)) {
|
if (ObjectUtil.isNull(attribute)) {
|
||||||
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
|
request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>());
|
||||||
attribute = saStorage.get(DATA_PERMISSION_KEY);
|
attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
||||||
}
|
}
|
||||||
if (attribute instanceof Map) {
|
if (attribute instanceof Map) {
|
||||||
return (Map<String, Object>) attribute;
|
return (Map<String, Object>) attribute;
|
||||||
|
@ -1,135 +0,0 @@
|
|||||||
package com.ruoyi.common.helper;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.context.SaHolder;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.enums.DeviceType;
|
|
||||||
import com.ruoyi.common.enums.UserType;
|
|
||||||
import com.ruoyi.common.exception.UtilException;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录鉴权助手
|
|
||||||
*
|
|
||||||
* user_type 为 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app
|
|
||||||
* deivce 为 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios
|
|
||||||
* 可以组成 用户类型与设备类型多对多的 权限灵活控制
|
|
||||||
*
|
|
||||||
* 多用户体系 针对 多种用户类型 但权限控制不一致
|
|
||||||
* 可以组成 多用户类型表与多设备类型 分别控制权限
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class LoginHelper {
|
|
||||||
|
|
||||||
public static final String JOIN_CODE = ":";
|
|
||||||
public static final String LOGIN_USER_KEY = "loginUser";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录系统
|
|
||||||
*
|
|
||||||
* @param loginUser 登录用户信息
|
|
||||||
*/
|
|
||||||
public static void login(LoginUser loginUser) {
|
|
||||||
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
|
|
||||||
StpUtil.login(loginUser.getLoginId());
|
|
||||||
setLoginUser(loginUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录系统 基于 设备类型
|
|
||||||
* 针对相同用户体系不同设备
|
|
||||||
*
|
|
||||||
* @param loginUser 登录用户信息
|
|
||||||
*/
|
|
||||||
public static void loginByDevice(LoginUser loginUser, DeviceType deviceType) {
|
|
||||||
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
|
|
||||||
StpUtil.login(loginUser.getLoginId(), deviceType.getDevice());
|
|
||||||
setLoginUser(loginUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置用户数据(多级缓存)
|
|
||||||
*/
|
|
||||||
public static void setLoginUser(LoginUser loginUser) {
|
|
||||||
StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户(多级缓存)
|
|
||||||
*/
|
|
||||||
public static LoginUser getLoginUser() {
|
|
||||||
LoginUser loginUser = (LoginUser) SaHolder.getStorage().get(LOGIN_USER_KEY);
|
|
||||||
if (loginUser != null) {
|
|
||||||
return loginUser;
|
|
||||||
}
|
|
||||||
loginUser = (LoginUser) StpUtil.getTokenSession().get(LOGIN_USER_KEY);
|
|
||||||
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
|
|
||||||
return loginUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户id
|
|
||||||
*/
|
|
||||||
public static Long getUserId() {
|
|
||||||
LoginUser loginUser = getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
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);
|
|
||||||
// 用户id在总是在最后
|
|
||||||
userId = strs[strs.length - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isBlank(userId)) {
|
|
||||||
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
|
||||||
}
|
|
||||||
return Long.parseLong(userId);
|
|
||||||
}
|
|
||||||
return loginUser.getUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门ID
|
|
||||||
*/
|
|
||||||
public static Long getDeptId() {
|
|
||||||
return getLoginUser().getDeptId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户账户
|
|
||||||
*/
|
|
||||||
public static String getUsername() {
|
|
||||||
return getLoginUser().getUsername();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户类型
|
|
||||||
*/
|
|
||||||
public static UserType getUserType() {
|
|
||||||
String loginId = StpUtil.getLoginIdAsString();
|
|
||||||
return UserType.getUserType(loginId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为管理员
|
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public static boolean isAdmin(Long userId) {
|
|
||||||
return UserConstants.ADMIN_ID.equals(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAdmin() {
|
|
||||||
return isAdmin(getUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.ruoyi.common.jackson;
|
|
||||||
|
|
||||||
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.Sensitive;
|
|
||||||
import com.ruoyi.common.core.service.SensitiveService;
|
|
||||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据脱敏json序列化工具
|
|
||||||
*
|
|
||||||
* @author Yjoioooo
|
|
||||||
*/
|
|
||||||
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
|
|
||||||
|
|
||||||
private SensitiveStrategy strategy;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
|
||||||
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
|
||||||
if (sensitiveService.isSensitive()) {
|
|
||||||
gen.writeString(strategy.desensitizer().apply(value));
|
|
||||||
} else {
|
|
||||||
gen.writeString(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
|
|
||||||
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
|
||||||
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass())) {
|
|
||||||
this.strategy = annotation.strategy();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return prov.findValueSerializer(property.getType(), property);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.ruoyi.common.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token 配置属性
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "token")
|
||||||
|
public class TokenProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌自定义标识
|
||||||
|
*/
|
||||||
|
private String header;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌秘钥
|
||||||
|
*/
|
||||||
|
private String secret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌有效期(默认30分钟)
|
||||||
|
*/
|
||||||
|
private int expireTime;
|
||||||
|
}
|
@ -1,27 +1,18 @@
|
|||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.SimpleCache;
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.extra.cglib.CglibUtil;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.cglib.beans.BeanCopier;
|
|
||||||
import org.springframework.cglib.beans.BeanMap;
|
|
||||||
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 性能优异)
|
||||||
* <p>
|
|
||||||
* 重点 cglib 不支持 拷贝到链式对象
|
|
||||||
* 例如: 源对象 拷贝到 目标(链式对象)
|
|
||||||
* 请区分好`浅拷贝`和`深拷贝`再做使用
|
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@ -42,8 +33,7 @@ public class BeanCopyUtils {
|
|||||||
if (ObjectUtil.isNull(desc)) {
|
if (ObjectUtil.isNull(desc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final V target = ReflectUtil.newInstanceIfPossible(desc);
|
return CglibUtil.copy(source, desc);
|
||||||
return copy(source, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,8 +50,7 @@ public class BeanCopyUtils {
|
|||||||
if (ObjectUtil.isNull(desc)) {
|
if (ObjectUtil.isNull(desc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BeanCopier beanCopier = BeanCopierCache.INSTANCE.get(source.getClass(), desc.getClass(), null);
|
CglibUtil.copy(source, desc);
|
||||||
beanCopier.copy(source, desc, null);
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +68,7 @@ public class BeanCopyUtils {
|
|||||||
if (CollUtil.isEmpty(sourceList)) {
|
if (CollUtil.isEmpty(sourceList)) {
|
||||||
return CollUtil.newArrayList();
|
return CollUtil.newArrayList();
|
||||||
}
|
}
|
||||||
return sourceList.stream().map(source -> {
|
return CglibUtil.copyList(sourceList, () -> ReflectUtil.newInstanceIfPossible(desc));
|
||||||
V target = ReflectUtil.newInstanceIfPossible(desc);
|
|
||||||
copy(source, target);
|
|
||||||
return target;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,12 +77,11 @@ public class BeanCopyUtils {
|
|||||||
* @param bean 数据来源实体
|
* @param bean 数据来源实体
|
||||||
* @return map对象
|
* @return map对象
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> Map<String, Object> copyToMap(T bean) {
|
public static <T> Map<String, Object> copyToMap(T bean) {
|
||||||
if (ObjectUtil.isNull(bean)) {
|
if (ObjectUtil.isNull(bean)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return BeanMap.create(bean);
|
return CglibUtil.toMap(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,8 +98,7 @@ public class BeanCopyUtils {
|
|||||||
if (ObjectUtil.isNull(beanClass)) {
|
if (ObjectUtil.isNull(beanClass)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
T bean = ReflectUtil.newInstanceIfPossible(beanClass);
|
return CglibUtil.toBean(map, beanClass);
|
||||||
return mapToBean(map, bean);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,54 +115,6 @@ public class BeanCopyUtils {
|
|||||||
if (ObjectUtil.isNull(bean)) {
|
if (ObjectUtil.isNull(bean)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BeanMap.create(bean).putAll(map);
|
return CglibUtil.fillBean(map, bean);
|
||||||
return bean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* BeanCopier属性缓存<br>
|
|
||||||
* 缓存用于防止多次反射造成的性能问题
|
|
||||||
*
|
|
||||||
* @author Looly
|
|
||||||
* @since 5.4.1
|
|
||||||
*/
|
|
||||||
public enum BeanCopierCache {
|
|
||||||
/**
|
|
||||||
* BeanCopier属性缓存单例
|
|
||||||
*/
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
private final SimpleCache<String, BeanCopier> cache = new SimpleCache<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得类与转换器生成的key在{@link BeanCopier}的Map中对应的元素
|
|
||||||
*
|
|
||||||
* @param srcClass 源Bean的类
|
|
||||||
* @param targetClass 目标Bean的类
|
|
||||||
* @param converter 转换器
|
|
||||||
* @return Map中对应的BeanCopier
|
|
||||||
*/
|
|
||||||
public BeanCopier get(Class<?> srcClass, Class<?> targetClass, Converter converter) {
|
|
||||||
final String key = genKey(srcClass, targetClass, converter);
|
|
||||||
return cache.get(key, () -> BeanCopier.create(srcClass, targetClass, converter != null));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得类与转换器生成的key
|
|
||||||
*
|
|
||||||
* @param srcClass 源Bean的类
|
|
||||||
* @param targetClass 目标Bean的类
|
|
||||||
* @param converter 转换器
|
|
||||||
* @return 属性名和Map映射的key
|
|
||||||
*/
|
|
||||||
private String genKey(Class<?> srcClass, Class<?> targetClass, Converter converter) {
|
|
||||||
final StringBuilder key = StrUtil.builder()
|
|
||||||
.append(srcClass.getName()).append('#').append(targetClass.getName());
|
|
||||||
if(null != converter){
|
|
||||||
key.append('#').append(converter.getClass().getName());
|
|
||||||
}
|
|
||||||
return key.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,6 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
|||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,17 +17,17 @@ import java.util.Date;
|
|||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||||
|
|
||||||
public static final String YYYY = "yyyy";
|
public static String YYYY = "yyyy";
|
||||||
|
|
||||||
public static final String YYYY_MM = "yyyy-MM";
|
public static String YYYY_MM = "yyyy-MM";
|
||||||
|
|
||||||
public static final String YYYY_MM_DD = "yyyy-MM-dd";
|
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||||
|
|
||||||
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||||
|
|
||||||
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
private static final String[] PARSE_PATTERNS = {
|
private static String[] parsePatterns = {
|
||||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||||
@ -55,27 +50,27 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
return dateTimeNow(YYYY_MM_DD);
|
return dateTimeNow(YYYY_MM_DD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTime() {
|
public static final String getTime() {
|
||||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String dateTimeNow() {
|
public static final String dateTimeNow() {
|
||||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String dateTimeNow(final String format) {
|
public static final String dateTimeNow(final String format) {
|
||||||
return parseDateToStr(format, new Date());
|
return parseDateToStr(format, new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String dateTime(final Date date) {
|
public static final String dateTime(final Date date) {
|
||||||
return parseDateToStr(YYYY_MM_DD, date);
|
return parseDateToStr(YYYY_MM_DD, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String parseDateToStr(final String format, final Date date) {
|
public static final String parseDateToStr(final String format, final Date date) {
|
||||||
return new SimpleDateFormat(format).format(date);
|
return new SimpleDateFormat(format).format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date dateTime(final String format, final String ts) {
|
public static final Date dateTime(final String format, final String ts) {
|
||||||
try {
|
try {
|
||||||
return new SimpleDateFormat(format).parse(ts);
|
return new SimpleDateFormat(format).parse(ts);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
@ -86,7 +81,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
/**
|
/**
|
||||||
* 日期路径 即年/月/日 如2018/08/08
|
* 日期路径 即年/月/日 如2018/08/08
|
||||||
*/
|
*/
|
||||||
public static String datePath() {
|
public static final String datePath() {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||||
}
|
}
|
||||||
@ -94,7 +89,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
/**
|
/**
|
||||||
* 日期路径 即年/月/日 如20180808
|
* 日期路径 即年/月/日 如20180808
|
||||||
*/
|
*/
|
||||||
public static String dateTime() {
|
public static final String dateTime() {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||||
}
|
}
|
||||||
@ -107,7 +102,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return parseDate(str.toString(), PARSE_PATTERNS);
|
return parseDate(str.toString(), parsePatterns);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -121,13 +116,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算相差天数
|
|
||||||
*/
|
|
||||||
public static int differentDaysByMillisecond(Date date1, Date date2) {
|
|
||||||
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个时间差
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
@ -148,21 +136,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
// long sec = diff % nd % nh % nm / ns;
|
// long sec = diff % nd % nh % nm / ns;
|
||||||
return day + "天" + hour + "小时" + min + "分钟";
|
return day + "天" + hour + "小时" + min + "分钟";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加 LocalDateTime ==> Date
|
|
||||||
*/
|
|
||||||
public static Date toDate(LocalDateTime temporalAccessor) {
|
|
||||||
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
|
||||||
return Date.from(zdt.toInstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加 LocalDate ==> Date
|
|
||||||
*/
|
|
||||||
public static Date toDate(LocalDate temporalAccessor) {
|
|
||||||
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
|
||||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
|
||||||
return Date.from(zdt.toInstant());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Dict;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
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;
|
||||||
@ -13,6 +11,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON 工具类
|
* JSON 工具类
|
||||||
@ -29,7 +28,7 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String toJsonString(Object object) {
|
public static String toJsonString(Object object) {
|
||||||
if (ObjectUtil.isNull(object)) {
|
if (StringUtils.isNull(object)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -72,23 +71,13 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dict parseMap(String text) {
|
public static <T> Map<String, T> parseMap(String text) {
|
||||||
if (StringUtils.isBlank(text)) {
|
if (StringUtils.isBlank(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructType(Dict.class));
|
return OBJECT_MAPPER.readValue(text, new TypeReference<Map<String, T>>() {
|
||||||
} catch (IOException e) {
|
});
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Dict> parseArrayMap(String text) {
|
|
||||||
if (StringUtils.isBlank(text)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Dict.class));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
193
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
Normal file
193
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.page.PagePlus;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页工具
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link PageQuery} 与 {@link TableDataInfo}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class PageUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前记录起始索引
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final String PAGE_NUM = "pageNum";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示记录数
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final String PAGE_SIZE = "pageSize";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序列
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序的方向 "desc" 或者 "asc".
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final String IS_ASC = "isAsc";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前记录起始索引 默认值
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final int DEFAULT_PAGE_NUM = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示记录数 默认值 默认查全部
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 plus 分页对象
|
||||||
|
*
|
||||||
|
* @param <T> domain 实体
|
||||||
|
* @param <K> vo 实体
|
||||||
|
* @return 分页对象
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link PageQuery#build()}
|
||||||
|
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T, K> PagePlus<T, K> buildPagePlus() {
|
||||||
|
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
|
||||||
|
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
||||||
|
String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN);
|
||||||
|
String isAsc = ServletUtils.getParameter(IS_ASC);
|
||||||
|
if (pageNum <= 0) {
|
||||||
|
pageNum = DEFAULT_PAGE_NUM;
|
||||||
|
}
|
||||||
|
PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize);
|
||||||
|
OrderItem orderItem = buildOrderItem(orderByColumn, isAsc);
|
||||||
|
if (ObjectUtil.isNotNull(orderItem)) {
|
||||||
|
page.addOrder(orderItem);
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Page<T> buildPage() {
|
||||||
|
return buildPage(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 MP 普通分页对象
|
||||||
|
*
|
||||||
|
* @param <T> domain 实体
|
||||||
|
* @return 分页对象
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link PageQuery#build()}
|
||||||
|
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Page<T> buildPage(String defaultOrderByColumn, String defaultIsAsc) {
|
||||||
|
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
|
||||||
|
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
||||||
|
String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN, defaultOrderByColumn);
|
||||||
|
String isAsc = ServletUtils.getParameter(IS_ASC, defaultIsAsc);
|
||||||
|
if (pageNum <= 0) {
|
||||||
|
pageNum = DEFAULT_PAGE_NUM;
|
||||||
|
}
|
||||||
|
Page<T> page = new Page<>(pageNum, pageSize);
|
||||||
|
OrderItem orderItem = buildOrderItem(orderByColumn, isAsc);
|
||||||
|
if (ObjectUtil.isNotNull(orderItem)) {
|
||||||
|
page.addOrder(orderItem);
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OrderItem buildOrderItem(String orderByColumn, String isAsc) {
|
||||||
|
// 兼容前端排序类型
|
||||||
|
if ("ascending".equals(isAsc)) {
|
||||||
|
isAsc = "asc";
|
||||||
|
} else if ("descending".equals(isAsc)) {
|
||||||
|
isAsc = "desc";
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(orderByColumn)) {
|
||||||
|
String orderBy = SqlUtil.escapeOrderBySql(orderByColumn);
|
||||||
|
orderBy = StringUtils.toUnderScoreCase(orderBy);
|
||||||
|
if ("asc".equals(isAsc)) {
|
||||||
|
return OrderItem.asc(orderBy);
|
||||||
|
} else if ("desc".equals(isAsc)) {
|
||||||
|
return OrderItem.desc(orderBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 MP 普通分页对象
|
||||||
|
*
|
||||||
|
* @param <T> domain 实体
|
||||||
|
* @return 分页对象
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link PageQuery#build()}
|
||||||
|
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T, K> TableDataInfo<K> buildDataInfo(PagePlus<T, K> page) {
|
||||||
|
TableDataInfo<K> rspData = new TableDataInfo<>();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(page.getRecordsVo());
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link TableDataInfo#build(IPage)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> TableDataInfo<T> buildDataInfo(Page<T> page) {
|
||||||
|
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(page.getRecords());
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link TableDataInfo#build(List)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> TableDataInfo<T> buildDataInfo(List<T> list) {
|
||||||
|
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(list);
|
||||||
|
rspData.setTotal(list.size());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 3.6.0 删除 请使用 {@link TableDataInfo#build()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> TableDataInfo<T> buildDataInfo() {
|
||||||
|
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ruoyi.common.utils.redis;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import cn.hutool.core.collection.IterUtil;
|
import cn.hutool.core.collection.IterUtil;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
@ -6,11 +6,11 @@ import lombok.AccessLevel;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.redisson.api.*;
|
import org.redisson.api.*;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ public class RedisUtils {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
long timeToLive = bucket.remainTimeToLive();
|
long timeToLive = bucket.remainTimeToLive();
|
||||||
bucket.set(value);
|
bucket.set(value);
|
||||||
bucket.expire(Duration.ofMillis(timeToLive));
|
bucket.expire(timeToLive, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bucket.set(value);
|
bucket.set(value);
|
||||||
@ -119,17 +119,18 @@ public class RedisUtils {
|
|||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @param value 缓存的值
|
* @param value 缓存的值
|
||||||
* @param duration 时间
|
* @param timeout 时间
|
||||||
|
* @param timeUnit 时间颗粒度
|
||||||
*/
|
*/
|
||||||
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 long timeout, final TimeUnit timeUnit) {
|
||||||
RBucket<T> result = CLIENT.getBucket(key);
|
RBucket<T> result = CLIENT.getBucket(key);
|
||||||
result.set(value);
|
result.set(value);
|
||||||
result.expire(duration);
|
result.expire(timeout, timeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册对象监听器
|
* 注册对象监听器
|
||||||
* <p>
|
*
|
||||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
@ -148,19 +149,20 @@ public class RedisUtils {
|
|||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public static boolean expire(final String key, final long timeout) {
|
public static boolean expire(final String key, final long timeout) {
|
||||||
return expire(key, Duration.ofSeconds(timeout));
|
return expire(key, timeout, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置有效时间
|
* 设置有效时间
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param duration 超时时间
|
* @param timeout 超时时间
|
||||||
|
* @param unit 时间单位
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public static boolean expire(final String key, final Duration duration) {
|
public static boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||||
RBucket rBucket = CLIENT.getBucket(key);
|
RBucket rBucket = CLIENT.getBucket(key);
|
||||||
return rBucket.expire(duration);
|
return rBucket.expire(timeout, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,7 +223,7 @@ public class RedisUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册List监听器
|
* 注册List监听器
|
||||||
* <p>
|
*
|
||||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
@ -257,7 +259,7 @@ public class RedisUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册Set监听器
|
* 注册Set监听器
|
||||||
* <p>
|
*
|
||||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
@ -294,7 +296,7 @@ public class RedisUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册Map监听器
|
* 注册Map监听器
|
||||||
* <p>
|
*
|
||||||
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
|
||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
@ -364,50 +366,6 @@ public class RedisUtils {
|
|||||||
return rMap.getAll(hKeys);
|
return rMap.getAll(hKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置原子值
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @param value 值
|
|
||||||
*/
|
|
||||||
public static void setAtomicValue(String key, long value) {
|
|
||||||
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
|
||||||
atomic.set(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取原子值
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @return 当前值
|
|
||||||
*/
|
|
||||||
public static long getAtomicValue(String key) {
|
|
||||||
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
|
||||||
return atomic.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递增原子值
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @return 当前值
|
|
||||||
*/
|
|
||||||
public static long incrAtomicValue(String key) {
|
|
||||||
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
|
||||||
return atomic.incrementAndGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递减原子值
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @return 当前值
|
|
||||||
*/
|
|
||||||
public static long decrAtomicValue(String key) {
|
|
||||||
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
|
||||||
return atomic.decrementAndGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的基本对象列表
|
* 获得缓存的基本对象列表
|
||||||
*
|
*
|
||||||
@ -418,14 +376,4 @@ public class RedisUtils {
|
|||||||
Iterable<String> iterable = CLIENT.getKeys().getKeysByPattern(pattern);
|
Iterable<String> iterable = CLIENT.getKeys().getKeysByPattern(pattern);
|
||||||
return IterUtil.toList(iterable);
|
return IterUtil.toList(iterable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查redis中是否存在key
|
|
||||||
*
|
|
||||||
* @param key 键
|
|
||||||
*/
|
|
||||||
public static Boolean hasKey(String key) {
|
|
||||||
RKeys rKeys = CLIENT.getKeys();
|
|
||||||
return rKeys.countExists(key) > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全服务工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class SecurityUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
**/
|
||||||
|
public static Long getUserId() {
|
||||||
|
try {
|
||||||
|
return getLoginUser().getUserId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("获取用户ID异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门ID
|
||||||
|
**/
|
||||||
|
public static Long getDeptId() {
|
||||||
|
try {
|
||||||
|
return getLoginUser().getDeptId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("获取部门ID异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户账户
|
||||||
|
**/
|
||||||
|
public static String getUsername() {
|
||||||
|
try {
|
||||||
|
return getLoginUser().getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("获取用户账户异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户
|
||||||
|
**/
|
||||||
|
public static LoginUser getLoginUser() {
|
||||||
|
try {
|
||||||
|
return (LoginUser) getAuthentication().getPrincipal();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("获取用户信息异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Authentication
|
||||||
|
*/
|
||||||
|
public static Authentication getAuthentication() {
|
||||||
|
return SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成BCryptPasswordEncoder密码
|
||||||
|
*
|
||||||
|
* @param password 密码
|
||||||
|
* @return 加密字符串
|
||||||
|
*/
|
||||||
|
public static String encryptPassword(String password) {
|
||||||
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
return passwordEncoder.encode(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断密码是否相同
|
||||||
|
*
|
||||||
|
* @param rawPassword 真实密码
|
||||||
|
* @param encodedPassword 加密后字符
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static boolean matchesPassword(String rawPassword, String encodedPassword) {
|
||||||
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
return passwordEncoder.matches(rawPassword, encodedPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为管理员
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static boolean isAdmin(Long userId) {
|
||||||
|
return userId != null && 1L == userId;
|
||||||
|
}
|
||||||
|
}
|
@ -97,8 +97,9 @@ public class ServletUtils extends ServletUtil {
|
|||||||
*
|
*
|
||||||
* @param response 渲染对象
|
* @param response 渲染对象
|
||||||
* @param string 待渲染的字符串
|
* @param string 待渲染的字符串
|
||||||
|
* @return null
|
||||||
*/
|
*/
|
||||||
public static void renderString(HttpServletResponse response, String string) {
|
public static String renderString(HttpServletResponse response, String string) {
|
||||||
try {
|
try {
|
||||||
response.setStatus(HttpStatus.HTTP_OK);
|
response.setStatus(HttpStatus.HTTP_OK);
|
||||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||||
@ -107,6 +108,7 @@ public class ServletUtils extends ServletUtil {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,12 +119,12 @@ 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.indexOf("application/json") != -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||||
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) {
|
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +134,10 @@ public class ServletUtils extends ServletUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
String ajax = request.getParameter("__ajax");
|
||||||
return StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml");
|
if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getClientIP() {
|
public static String getClientIP() {
|
||||||
|
@ -2,15 +2,15 @@ package com.ruoyi.common.utils;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.ReUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.util.AntPathMatcher;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类
|
* 字符串工具类
|
||||||
@ -20,6 +20,16 @@ import java.util.Set;
|
|||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取参数不为空值
|
||||||
|
*
|
||||||
|
* @param value defaultValue 要判断的value
|
||||||
|
* @return value 返回值
|
||||||
|
*/
|
||||||
|
public static <T> T nvl(T value, T defaultValue) {
|
||||||
|
return ObjectUtil.defaultIfNull(value, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取参数不为空值
|
* 获取参数不为空值
|
||||||
*
|
*
|
||||||
@ -30,6 +40,86 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return StrUtil.blankToDefault(str, defaultValue);
|
return StrUtil.blankToDefault(str, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||||
|
*
|
||||||
|
* @param coll 要判断的Collection
|
||||||
|
* @return true:为空 false:非空
|
||||||
|
*/
|
||||||
|
public static boolean isEmpty(Collection<?> coll) {
|
||||||
|
return CollUtil.isEmpty(coll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个Collection是否非空,包含List,Set,Queue
|
||||||
|
*
|
||||||
|
* @param coll 要判断的Collection
|
||||||
|
* @return true:非空 false:空
|
||||||
|
*/
|
||||||
|
public static boolean isNotEmpty(Collection<?> coll) {
|
||||||
|
return !isEmpty(coll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象数组是否为空
|
||||||
|
*
|
||||||
|
* @param objects 要判断的对象数组
|
||||||
|
* * @return true:为空 false:非空
|
||||||
|
*/
|
||||||
|
public static boolean isEmpty(Object[] objects) {
|
||||||
|
return ArrayUtil.isEmpty(objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象数组是否非空
|
||||||
|
*
|
||||||
|
* @param objects 要判断的对象数组
|
||||||
|
* @return true:非空 false:空
|
||||||
|
*/
|
||||||
|
public static boolean isNotEmpty(Object[] objects) {
|
||||||
|
return !isEmpty(objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象是否为空
|
||||||
|
*
|
||||||
|
* @param object 要判断的对象数组
|
||||||
|
* * @return true:为空 false:非空
|
||||||
|
*/
|
||||||
|
public static boolean isEmpty(Object object) {
|
||||||
|
return ObjectUtil.isEmpty(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象是否非空
|
||||||
|
*
|
||||||
|
* @param object 要判断的对象数组
|
||||||
|
* @return true:非空 false:空
|
||||||
|
*/
|
||||||
|
public static boolean isNotEmpty(Object object) {
|
||||||
|
return !isEmpty(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个Map是否为空
|
||||||
|
*
|
||||||
|
* @param map 要判断的Map
|
||||||
|
* @return true:为空 false:非空
|
||||||
|
*/
|
||||||
|
public static boolean isEmpty(Map<?, ?> map) {
|
||||||
|
return MapUtil.isEmpty(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个Map是否为空
|
||||||
|
*
|
||||||
|
* @param map 要判断的Map
|
||||||
|
* @return true:非空 false:空
|
||||||
|
*/
|
||||||
|
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||||
|
return !isEmpty(map);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个字符串是否为空串
|
* * 判断一个字符串是否为空串
|
||||||
*
|
*
|
||||||
@ -50,6 +140,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return !isEmpty(str);
|
return !isEmpty(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象是否为空
|
||||||
|
*
|
||||||
|
* @param object Object
|
||||||
|
* @return true:为空 false:非空
|
||||||
|
*/
|
||||||
|
public static boolean isNull(Object object) {
|
||||||
|
return ObjectUtil.isNull(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象是否非空
|
||||||
|
*
|
||||||
|
* @param object Object
|
||||||
|
* @return true:非空 false:空
|
||||||
|
*/
|
||||||
|
public static boolean isNotNull(Object object) {
|
||||||
|
return !isNull(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||||
|
*
|
||||||
|
* @param object 对象
|
||||||
|
* @return true:是数组 false:不是数组
|
||||||
|
*/
|
||||||
|
public static boolean isArray(Object object) {
|
||||||
|
return ArrayUtil.isArray(object);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去空格
|
* 去空格
|
||||||
*/
|
*/
|
||||||
@ -86,7 +206,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||||
* 例:<br>
|
* 例:<br>
|
||||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is {} for a<br>
|
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||||
*
|
*
|
||||||
* @param template 文本模板,被替换的部分用 {} 表示
|
* @param template 文本模板,被替换的部分用 {} 表示
|
||||||
@ -205,7 +325,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* @return 是否匹配
|
* @return 是否匹配
|
||||||
*/
|
*/
|
||||||
public static boolean matches(String str, List<String> strs) {
|
public static boolean matches(String str, List<String> strs) {
|
||||||
if (isEmpty(str) || CollUtil.isEmpty(strs)) {
|
if (isEmpty(str) || isEmpty(strs)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String pattern : strs) {
|
for (String pattern : strs) {
|
||||||
@ -227,47 +347,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isMatch(String pattern, String url) {
|
public static boolean isMatch(String pattern, String url) {
|
||||||
AntPathMatcher matcher = new AntPathMatcher();
|
return ReUtil.isMatch(pattern, url);
|
||||||
return matcher.match(pattern, url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@SuppressWarnings("unchecked")
|
||||||
* 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
|
public static <T> T cast(Object obj) {
|
||||||
*
|
return (T) obj;
|
||||||
* @param num 数字对象
|
|
||||||
* @param size 字符串指定长度
|
|
||||||
* @return 返回数字的字符串格式,该字符串为指定长度。
|
|
||||||
*/
|
|
||||||
public static final String padl(final Number num, final int size) {
|
|
||||||
return padl(num.toString(), size, '0');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
|
|
||||||
*
|
|
||||||
* @param s 原始字符串
|
|
||||||
* @param size 字符串指定长度
|
|
||||||
* @param c 用于补齐的字符
|
|
||||||
* @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
|
|
||||||
*/
|
|
||||||
public static final String padl(final String s, final int size, final char c) {
|
|
||||||
final StringBuilder sb = new StringBuilder(size);
|
|
||||||
if (s != null) {
|
|
||||||
final int len = s.length();
|
|
||||||
if (s.length() <= size) {
|
|
||||||
for (int i = size - len; i > 0; i--) {
|
|
||||||
sb.append(c);
|
|
||||||
}
|
|
||||||
sb.append(s);
|
|
||||||
} else {
|
|
||||||
return s.substring(len - size, len);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i = size; i > 0; i--) {
|
|
||||||
sb.append(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user