Compare commits
No commits in common. "master" and "V4.1.7" have entirely different histories.
36
README.en.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Ruoyi-Flex
|
||||||
|
|
||||||
|
#### Description
|
||||||
|
Ruoyi-Flex是基于RuoYi-Vue v3.8.6进行的扩展,集成MyBatis-Flex、JDK17、lombok、Sa-Token、PowerJob、Hutool、OSS、ureport-keep、Flowable、vue3、TypeScript等优秀开源软件,准备作为未来5年软件开发的底座。
|
||||||
|
|
||||||
|
#### Software Architecture
|
||||||
|
Software architecture description
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
|
1. xxxx
|
||||||
|
2. xxxx
|
||||||
|
3. xxxx
|
||||||
|
|
||||||
|
#### Instructions
|
||||||
|
|
||||||
|
1. xxxx
|
||||||
|
2. xxxx
|
||||||
|
3. xxxx
|
||||||
|
|
||||||
|
#### Contribution
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create Feat_xxx branch
|
||||||
|
3. Commit your code
|
||||||
|
4. Create Pull Request
|
||||||
|
|
||||||
|
|
||||||
|
#### Gitee Feature
|
||||||
|
|
||||||
|
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||||
|
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||||
|
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||||
|
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||||
|
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||||
|
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
177
README.md
@ -1,147 +1,90 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="logo" src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/ruoyi-flex-logo.png">
|
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
|
||||||
</p>
|
</p>
|
||||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">Ruoyi-Flex V5.2.0-SNAPSHOT</h1>
|
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">Ruoyi-Flex V4.1.7</h1>
|
||||||
<h4 align="center">Ruoyi-Flex是基于JDK21、Spring Boot V3.2.X+平台 前后端分离的未来8年更快的Java开发框架</h4>
|
<h4 align="center">Ruoyi-Flex是基于Spring Boot V3平台 前后端分离的Java快速开发框架</h4>
|
||||||
|
|
||||||
|
|
||||||
## 1、平台简介
|
## 平台简介
|
||||||
|
|
||||||
Ruoyi-Flex是一套全部开源的快速开发平台,针对”分布式集群与多租户“场景全方位升级,使用MIT开源许可协议,毫无保留给个人及企业免费使用。基于RuoYi-Vue、RuoYi-Vue-Plus,集成MyBatis-Flex、JDK21、SpringBootV3.2.X+、Lombok、Sa-Token、SpringDoc、Hutool、SpringBoot Admin、EasyRetry、PowerJob、Vue3、Element-Plus、AntDesign-Vben、MinIO、Flowable等优秀开源软件,支持PostgreSQL、MySQL开源数据库及其衍生分布式数据库。
|
Ruoyi-Flex是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。基于RuoYi-Vue、RuoYi-Vue-Plus,集成MyBatis-Flex、JDK17、SpringBootV3、Lombok、Sa-Token、Hutool、SpringBoot Admin、PowerJob、Vue3、Element-Plus等优秀开源软件,
|
||||||
|
|
||||||
## 2、系统特色
|
* 前端采用Vue3、Element-Plus。
|
||||||
Ruoyi-Flex秉承“写的更少、性能更好、出错更低、交流通畅、快速入门” 的理念,为您带来全方位的赋能与提升:
|
* 后端采用Spring Boot V3、Sa-Token、Redis & Jwt、MyBatis-Flex、PowerJob。
|
||||||
|
* 权限认证使用Jwt,支持多终端认证系统。
|
||||||
|
* 支持加载动态权限菜单,多方式轻松权限控制。
|
||||||
|
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
||||||
|
|
||||||
### (1)写的更少
|
|
||||||
借助MyBatis-Flex,Ruoyi-Flex显著降低了代码输入工作量,最高降低了25.85%,参考“演示模块”中的同一功能演示程序源码对比分析(排除相同代码量的控制器、前端代码):
|
|
||||||
<p align="center">
|
|
||||||
<img alt="工作量" src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/workload.JPG">
|
|
||||||
</p>
|
|
||||||
除了那些复杂的遗留项目中的统计报表,在绝大部分情况下 Ruoyi-Flex 不需要手写 SQL 语句。
|
|
||||||
|
|
||||||
### (2)性能更好
|
## 内置功能
|
||||||
除了集成的JDK21、SpringBootV3.2、MyBatis-Flex的性能提升,系统“代码生成”模块生成的代码,凡是涉及到后台数据库的多表查询,没有采用数据库的LeftJoin、InnerJoin等SQL方式,而是使用WithRelation编程装配来取代数据库LeftJoin SQL关联查询,数据库不用维护表间外键关系,将多表关联SQL语句拆分为对各个单表的主键查询,关联无 SQL,性能提高10倍。
|
|
||||||
|
|
||||||
### (3)出错更低
|
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
||||||
原来用mybatis开发需要手写SQL语句,开发后期需要增加字段,修改xml文件是一种灾难,一不留神就犯错了;而Ruoyi-Flex借助MyBatis-Flex则很好地规避了此问题,如果字段输入错误,开发环境IDEA就会自动标红报警,避免犯错。
|
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
||||||
|
3. 岗位管理:配置系统用户所属担任职务。
|
||||||
|
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
|
||||||
|
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
||||||
|
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
||||||
|
7. 参数管理:对系统动态配置常用参数。
|
||||||
|
8. 通知公告:系统通知公告信息发布维护。
|
||||||
|
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
||||||
|
10. 登录日志:系统登录日志记录查询包含登录异常。
|
||||||
|
11. 在线用户:当前系统中活跃用户状态监控。
|
||||||
|
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
|
||||||
|
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
||||||
|
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
||||||
|
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
||||||
|
16. 缓存监控:对系统的缓存信息查询,命令统计等。
|
||||||
|
17. 在线构建器:拖动表单元素生成相应的HTML代码。
|
||||||
|
18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
||||||
|
|
||||||
### (4)交流通畅
|
|
||||||
“非我族类,其心必异”。Ruoyi-Flex集成了一大波国产开源软件:MyBatis-Flex、Sa-Token、Hutool、PowerJob、Element-Plus等,同根同源,交流自然顺畅,开发中遇到问题可联系作者快速得到解决。例如,同一个领域的安全框架,一个中国人只需半天就可学会Sa-Token干活,如果是学Spring Security的话,七天也不一定能学会。
|
|
||||||
|
|
||||||
### (5)多端同步
|
|
||||||
Ruoyi-Flex提供“1+3”端,1个后台端、3个前台端,熟悉js的可使用flex-elementplus-ui前端,熟悉ts的可使用ruoyiflex-elementplus-ts前端,既熟悉ts又熟悉antdesign的请使用ruoyiflex-antdesign-vben前端,总有一款适合您的前端供您选择!
|
|
||||||
|
|
||||||
### (6)入门快速
|
## 演示图
|
||||||
Ruoyi-Flex已集成各种开源开发框架,扫平了技术障碍,可直接上手干活。使用者只需要设计好数据库表结构,系统能可视化生成前后端本地代码,单表、树表、主子表任你选,10分钟就能开发一个模块,快速入门,开发高效。
|
|
||||||
|
|
||||||
## 3、前端项目
|
|
||||||
Ruoyi-Flex实行前后端分离仓库,本项目是java后端部分,目前有3个前端项目:
|
|
||||||
|
|
||||||
### (1)ruoyiflex-elementplus-ts
|
|
||||||
使用elementplus、typescript构建,项目地址: [ruoyiflex-elementplus-ts](https://gitee.com/dataprince/ruoyiflex-elementplus-ts)
|
|
||||||
|
|
||||||
### (2)ruoyiflex-antdesign-vben
|
|
||||||
使用antdesign、vben、typescript构建,项目地址: [ruoyiflex-antdesign-vben](https://gitee.com/dataprince/ruoyiflex-antdesign-vben)
|
|
||||||
|
|
||||||
### (3)flex-elementplus-ui
|
|
||||||
使用elementplus、js构建,项目地址: [flex-elementplus-ui](https://gitee.com/dataprince/flex-elementplus-ui)
|
|
||||||
|
|
||||||
## 4、内置功能
|
|
||||||
|
|
||||||
1. 租户管理:系统内租户的管理 如:租户套餐、过期时间、用户数量、企业信息等。
|
|
||||||
2. 租户套餐管理:系统内租户所能使用的套餐管理 如:套餐内所包含的菜单等。
|
|
||||||
3. 客户端管理:系统内对接的所有客户端管理 如: pc端、小程序端等支持动态授权登录方式 如: 短信登录、密码登录等 支持动态控制token时效。
|
|
||||||
4. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
|
||||||
5. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
|
||||||
6. 岗位管理:配置系统用户所属担任职务。
|
|
||||||
7. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
|
|
||||||
8. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
|
||||||
9. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
|
||||||
10. 参数管理:对系统动态配置常用参数。
|
|
||||||
11. 通知公告:系统通知公告信息发布维护。
|
|
||||||
12. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
|
||||||
13. 登录日志:系统登录日志记录查询包含登录异常。
|
|
||||||
14. 文件管理:引入云存储服务,将文件存储到MinIO、七牛、阿里、腾讯等OSS服务器上,支持上传、下载。
|
|
||||||
15. 在线用户:当前系统中活跃用户状态监控。
|
|
||||||
16. 调度中心:集成PowerJob全新一代分布式任务调度与计算框架。
|
|
||||||
17. 代码生成:前后端代码的生成(java、html、vue、js),支持单表、树表、主子表,减少70%以上的开发工作量。
|
|
||||||
18. 系统接口:集成springdoc,根据文档注释自动生成相关的api接口文档。
|
|
||||||
19. 监控中心:集成Spring Boot Admin,监视集群系统CPU、内存、磁盘、堆栈、在线日志、Spring相关配置等。
|
|
||||||
20. 缓存监控:对系统的缓存信息查询,命令统计等。
|
|
||||||
21. 后台数据库:支持PostgreSQL、MySQL开源数据库及其衍生分布式数据库。
|
|
||||||
22. 演示模块:mybatis、mybatis-flex两种格式代码的单表、树表、主子表三种类型的演示程序。
|
|
||||||
23. 实现多租户功能。
|
|
||||||
24. 实现乐观锁功能。
|
|
||||||
25. 实现逻辑删除功能。
|
|
||||||
26. 启用JAVA21虚拟线程、分代ZGC功能。
|
|
||||||
27. 实现API接口加密功能,密码使用密文传输。
|
|
||||||
|
|
||||||
## 5、演示图
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/main.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/cd1f90be5f2684f4560c9519c0f2a232ee8.jpg"/></td>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/manul.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/1cbcf0e6f257c7d3a063c0e3f2ff989e4b3.jpg"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/user.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-8074972883b5ba0622e13246738ebba237a.png"/></td>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/role.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-9f88719cdfca9af2e58b352a20e23d43b12.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/powerjob.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-39bf2584ec3a529b0d5a3b70d15c9b37646.png"/></td>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/springbootadmin.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-936ec82d1f4872e1bc980927654b6007307.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/oss.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-b2d62ceb95d2dd9b3fbe157bb70d26001e9.png"/></td>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/gen.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-d67451d308b7a79ad6819723396f7c3d77a.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/master.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/5e8c387724954459291aafd5eb52b456f53.jpg"/></td>
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/preview.JPG"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/644e78da53c2e92a95dfda4f76e6d117c4b.jpg"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://oscimg.oschina.net/oscnet/up-8370a0d02977eebf6dbf854c8450293c937.png"/></td>
|
||||||
|
<td><img src="https://oscimg.oschina.net/oscnet/up-49003ed83f60f633e7153609a53a2b644f7.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
## 6、开发文档
|
## 特别鸣谢
|
||||||
|
|
||||||
本项目提供保姆级开发文档,零基础手把手入门教程,位于/doc文件夹下面,
|
|
||||||
入门必读,请下载到本地查看:《[Ruoyi-Flex开发编译手册.docx](https://gitee.com/dataprince/ruoyi-flex/raw/master/doc/Ruoyi-Flex-Guide.docx)》。
|
|
||||||
|
|
||||||
## 7、Ruoyi-Flex交流群
|
|
||||||
|
|
||||||
本软件完全开源,作者很忙,如果您在使用过程中遇到问题,请付点小费(扫码微信支付99元)后申请加入微信群寻求帮助:
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>1、免费QQ交流群:</td>
|
|
||||||
<td>762217712[交流1群]</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>2、付费微信VIP群(微信扫码支付99元加好友入群):</td>
|
|
||||||
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/dataprince.jpg"/></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
## 8、开源协议
|
|
||||||
|
|
||||||
**为什么推荐使用本项目?**
|
|
||||||
|
|
||||||
① 本项目采用比 Apache 2.0 更宽松的 [MIT License](https://gitee.com/dataprince/ruoyi-flex/blob/master/LICENSE) 开源协议,个人与企业可 100% 免费使用,不用保留类作者、Copyright 信息。
|
|
||||||
|
|
||||||
② 代码全部开源,不会像其它项目一样,只开源部分代码,让你无法了解整个项目的架构设计。
|
|
||||||
|
|
||||||
如果这个项目让您有所收获,记得 Star 关注哦,这对我是非常不错的鼓励与支持。
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 9、参与贡献
|
|
||||||
|
|
||||||
1. Fork 本仓库
|
|
||||||
2. 新建 Feat_xxx 分支
|
|
||||||
3. 提交代码
|
|
||||||
4. 新建 Pull Request
|
|
||||||
|
|
||||||
|
|
||||||
## 10、特别鸣谢
|
|
||||||
- [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue)
|
- [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue)
|
||||||
- [RuoYi-Vue-Plus](https://gitee.com/dromara/RuoYi-Vue-Plus)
|
- [RuoYi-Vue-Plus](https://gitee.com/dromara/RuoYi-Vue-Plus)
|
||||||
- [MyBatis-Flex](https://gitee.com/mybatis-flex/mybatis-flex)
|
- [MyBatis-Flex](https://gitee.com/mybatis-flex/mybatis-flex)
|
||||||
|
|
||||||
|
|
||||||
|
## Ruoyi-Flex交流群
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>1、普通QQ群: 100956531</td>
|
||||||
|
<td>[Ruoyi-Flex交流一群]</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>2、付费微信VIP交流群(需加好友捐助99元):</td>
|
||||||
|
<td><img src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/dataprince-wxcode.jpg"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
。
|
||||||
|
|
||||||
|
BIN
doc/若依环境使用手册.docx
Normal file
BIN
image/dataprince-wxcode.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 94 KiB |
BIN
image/gen.JPG
Before Width: | Height: | Size: 76 KiB |
BIN
image/login.JPG
Before Width: | Height: | Size: 142 KiB |
BIN
image/main.JPG
Before Width: | Height: | Size: 93 KiB |
BIN
image/manul.JPG
Before Width: | Height: | Size: 217 KiB |
BIN
image/master.JPG
Before Width: | Height: | Size: 67 KiB |
BIN
image/oss.JPG
Before Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 97 KiB |
Before Width: | Height: | Size: 90 KiB |
BIN
image/role.JPG
Before Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 96 KiB |
Before Width: | Height: | Size: 156 KiB |
BIN
image/user.JPG
Before Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 70 KiB |
@ -1,2 +0,0 @@
|
|||||||
processor.mapper.generateEnable=false
|
|
||||||
processor.tableDef.propertiesNameStyle=upperCase
|
|
195
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-flex</artifactId>
|
<artifactId>ruoyi-flex</artifactId>
|
||||||
@ -13,64 +13,50 @@
|
|||||||
<description>Ruoyi-Flex管理系统</description>
|
<description>Ruoyi-Flex管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>5.2.0-SNAPSHOT</revision>
|
<revision>4.1.7</revision>
|
||||||
<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>21</java.version>
|
<java.version>17</java.version>
|
||||||
<spring-boot.version>3.2.5</spring-boot.version>
|
<spring-boot.version>3.1.3</spring-boot.version>
|
||||||
<mybatis-flex.version>1.9.4</mybatis-flex.version>
|
<mybatis-flex.version>1.6.0</mybatis-flex.version>
|
||||||
<satoken.version>1.38.0</satoken.version>
|
<satoken.version>1.35.0.RC</satoken.version>
|
||||||
<HikariCP.version>5.1.0</HikariCP.version>
|
<mysql.version>8.0.33</mysql.version>
|
||||||
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
|
<HikariCP.version>5.0.1</HikariCP.version>
|
||||||
<bitwalker.version>1.21</bitwalker.version>
|
<bitwalker.version>1.21</bitwalker.version>
|
||||||
<caffeine.version>3.1.8</caffeine.version>
|
|
||||||
<kaptcha.version>2.3.3</kaptcha.version>
|
<kaptcha.version>2.3.3</kaptcha.version>
|
||||||
<pagehelper.version>6.1.0</pagehelper.version>
|
<pagehelper.version>5.3.3</pagehelper.version>
|
||||||
<fastjson.version>2.0.43</fastjson.version>
|
<fastjson.version>2.0.34</fastjson.version>
|
||||||
<oshi.version>6.4.8</oshi.version>
|
<oshi.version>6.4.4</oshi.version>
|
||||||
|
<commons.io.version>2.13.0</commons.io.version>
|
||||||
<commons.collections.version>3.2.2</commons.collections.version>
|
<commons.collections.version>3.2.2</commons.collections.version>
|
||||||
<poi.version>5.2.5</poi.version>
|
<poi.version>5.2.3</poi.version>
|
||||||
<easyexcel.version>3.3.3</easyexcel.version>
|
<easyexcel.version>3.3.2</easyexcel.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<jwt.version>0.9.1</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
<servlet-api.version>6.0.0</servlet-api.version>
|
<servlet-api.version>6.0.0</servlet-api.version>
|
||||||
<guava.version>32.1.1-jre</guava.version>
|
<guava.version>32.1.1-jre</guava.version>
|
||||||
<springdoc.version>2.4.0</springdoc.version>
|
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
|
||||||
<springdoc-openapi-starter-common.version>2.4.0</springdoc-openapi-starter-common.version>
|
<springdoc.version>2.2.0</springdoc.version>
|
||||||
|
<springdoc-openapi-starter-common.version>2.1.0</springdoc-openapi-starter-common.version>
|
||||||
<therapi-runtime-javadoc.version>0.15.0</therapi-runtime-javadoc.version>
|
<therapi-runtime-javadoc.version>0.15.0</therapi-runtime-javadoc.version>
|
||||||
<snakeyaml.version>2.2</snakeyaml.version>
|
<snakeyaml.version>1.33</snakeyaml.version>
|
||||||
<lombok.version>1.18.30</lombok.version>
|
<lombok.version>1.18.28</lombok.version>
|
||||||
<mapstruct-plus.version>1.3.6</mapstruct-plus.version>
|
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
|
||||||
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
||||||
<hutool.version>5.8.27</hutool.version>
|
<hutool.version>5.8.21</hutool.version>
|
||||||
<redisson.version>3.27.2</redisson.version>
|
<redisson.version>3.23.3</redisson.version>
|
||||||
<lock4j.version>2.2.7</lock4j.version>
|
<lock4j.version>2.2.4</lock4j.version>
|
||||||
<alibaba-ttl.version>2.14.4</alibaba-ttl.version>
|
<alibaba-ttl.version>2.14.3</alibaba-ttl.version>
|
||||||
<spring-boot-admin.version>3.2.3</spring-boot-admin.version>
|
<spring-boot-admin.version>3.1.5</spring-boot-admin.version>
|
||||||
<powerjob.version>4.3.6</powerjob.version>
|
<powerjob.version>4.3.5</powerjob.version>
|
||||||
<easyretry.version>3.2.0</easyretry.version>
|
|
||||||
<!-- 离线IP地址定位库 -->
|
|
||||||
<ip2region.version>2.7.0</ip2region.version>
|
|
||||||
<!-- OSS 配置 -->
|
|
||||||
<aws.sdk.version>2.25.15</aws.sdk.version>
|
|
||||||
<aws.crt.version>0.29.13</aws.crt.version>
|
|
||||||
<!-- 加解密依赖库 -->
|
|
||||||
<bcprov-jdk.version>1.77</bcprov-jdk.version>
|
|
||||||
<!-- SMS 配置 -->
|
|
||||||
<sms4j.version>3.2.0</sms4j.version>
|
|
||||||
<!-- findbugs消除打包警告 -->
|
|
||||||
<jsr305.version>3.0.2</jsr305.version>
|
|
||||||
<!-- 三方授权认证 -->
|
|
||||||
<justauth.version>1.16.6</justauth.version>
|
|
||||||
|
|
||||||
<!-- 插件版本 -->
|
<!-- 插件版本 -->
|
||||||
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
||||||
<maven-war-plugin.version>3.2.2</maven-war-plugin.version>
|
<maven-war-plugin.version>3.2.2</maven-war-plugin.version>
|
||||||
<maven-compiler-plugin.verison>3.11.0</maven-compiler-plugin.verison>
|
<maven-compiler-plugin.verison>3.11.0</maven-compiler-plugin.verison>
|
||||||
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
|
||||||
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
|
<flatten-maven-plugin.version>1.3.0</flatten-maven-plugin.version>
|
||||||
|
|
||||||
<!--工作流配置-->
|
|
||||||
<flowable.version>7.0.0</flowable.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
@ -79,7 +65,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||||
<profiles.active>dev</profiles.active>
|
<profiles.active>dev</profiles.active>
|
||||||
<logging.level>info</logging.level>
|
<logging.level>debug</logging.level>
|
||||||
</properties>
|
</properties>
|
||||||
<activation>
|
<activation>
|
||||||
<!-- 默认环境 -->
|
<!-- 默认环境 -->
|
||||||
@ -107,13 +93,6 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- validation检验-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- hutool 的依赖配置-->
|
<!-- hutool 的依赖配置-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
@ -123,15 +102,6 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- flowable 的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.flowable</groupId>
|
|
||||||
<artifactId>flowable-bom</artifactId>
|
|
||||||
<version>${flowable.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- common 的依赖配置-->
|
<!-- common 的依赖配置-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -141,12 +111,9 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--测试框架-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 数据库连接池-->
|
<!-- 数据库连接池-->
|
||||||
@ -159,7 +126,7 @@
|
|||||||
<!-- mybatis-flex -->
|
<!-- mybatis-flex -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>${mybatis-flex.version}</version>
|
<version>${mybatis-flex.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -187,11 +154,11 @@
|
|||||||
<version>${satoken.version}</version>
|
<version>${satoken.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- caffeine缓存 -->
|
<!-- Mysql驱动包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>caffeine</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>${caffeine.version}</version>
|
<version>${mysql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- servlet包 -->
|
<!-- servlet包 -->
|
||||||
@ -222,6 +189,13 @@
|
|||||||
<version>${oshi.version}</version>
|
<version>${oshi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- io常用工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>${commons.io.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<!-- excel工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
@ -347,53 +321,6 @@
|
|||||||
<version>${lock4j.version}</version>
|
<version>${lock4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 离线IP地址定位库 ip2region -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
<version>${ip2region.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- AWS SDK for Java 2.x -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>s3</artifactId>
|
|
||||||
<version>${aws.sdk.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 使用AWS基于 CRT 的 S3 客户端 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk.crt</groupId>
|
|
||||||
<artifactId>aws-crt</artifactId>
|
|
||||||
<version>${aws.crt.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 基于 AWS CRT 的 S3 客户端的性能增强的 S3 传输管理器 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
|
||||||
<artifactId>s3-transfer-manager</artifactId>
|
|
||||||
<version>${aws.sdk.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 加解密依赖库 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk18on</artifactId>
|
|
||||||
<version>${bcprov-jdk.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- findbugs消除打包警告 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
|
||||||
<artifactId>jsr305</artifactId>
|
|
||||||
<version>${jsr305.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- JustAuth 的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.zhyd.oauth</groupId>
|
|
||||||
<artifactId>JustAuth</artifactId>
|
|
||||||
<version>${justauth.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--Annotation Processor-->
|
<!--Annotation Processor-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -407,13 +334,6 @@
|
|||||||
<version>${alibaba-ttl.version}</version>
|
<version>${alibaba-ttl.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--短信sms4j-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara.sms4j</groupId>
|
|
||||||
<artifactId>sms4j-spring-boot-starter</artifactId>
|
|
||||||
<version>${sms4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- spring-boot-admin监控-->
|
<!-- spring-boot-admin监控-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.codecentric</groupId>
|
<groupId>de.codecentric</groupId>
|
||||||
@ -438,6 +358,13 @@
|
|||||||
<version>${powerjob.version}</version>
|
<version>${powerjob.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 定时任务-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.ruoyi</groupId>-->
|
||||||
|
<!-- <artifactId>ruoyi-quartz</artifactId>-->
|
||||||
|
<!-- <version>${revision}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!-- PowerJob定时任务处理器-->
|
<!-- PowerJob定时任务处理器-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -445,23 +372,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- EasyRetry Client -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aizuda</groupId>
|
|
||||||
<artifactId>easy-retry-client-starter</artifactId>
|
|
||||||
<version>${easyretry.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aizuda</groupId>
|
|
||||||
<artifactId>easy-retry-client-core</artifactId>
|
|
||||||
<version>${easyretry.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aizuda</groupId>
|
|
||||||
<artifactId>easy-retry-client-job-core</artifactId>
|
|
||||||
<version>${easyretry.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 代码生成-->
|
<!-- 代码生成-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -483,13 +393,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 工作流模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-workflow</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
# 使用官方的 Java 运行时作为父镜像
|
|
||||||
FROM registry.cn-qingdao.aliyuncs.com/yuzl1/jdk:21
|
|
||||||
|
|
||||||
# 将本地文件复制到容器中
|
|
||||||
COPY target/ruoyi-admin.jar /ruoyi-admin.jar
|
|
||||||
|
|
||||||
# 运行应用
|
|
||||||
ENTRYPOINT ["java","-jar","/ruoyi-admin.jar"]
|
|
@ -27,14 +27,8 @@
|
|||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
<!-- Mysql驱动包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 三方授权认证 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-social</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- PostgreSql -->
|
<!-- PostgreSql -->
|
||||||
@ -43,11 +37,6 @@
|
|||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-tenant</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- system模块-->
|
<!-- system模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -78,18 +67,11 @@
|
|||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- powerjob 客户端 -->
|
||||||
<groupId>com.aizuda</groupId>
|
<!-- <dependency>-->
|
||||||
<artifactId>easy-retry-client-starter</artifactId>
|
<!-- <groupId>tech.powerjob</groupId>-->
|
||||||
</dependency>
|
<!-- <artifactId>powerjob-worker-spring-boot-starter</artifactId>-->
|
||||||
<dependency>
|
<!-- </dependency>-->
|
||||||
<groupId>com.aizuda</groupId>
|
|
||||||
<artifactId>easy-retry-client-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aizuda</groupId>
|
|
||||||
<artifactId>easy-retry-client-job-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -2,23 +2,20 @@ package com.ruoyi;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration;
|
|
||||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = SpringDataWebAutoConfiguration.class)
|
@SpringBootApplication
|
||||||
public class RuoYiApplication
|
public class RuoYiApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
SpringApplication application = new SpringApplication(RuoYiApplication.class);
|
System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
SpringApplication.run(RuoYiApplication.class, args);
|
||||||
application.run(args);
|
System.out.println("(♥◠‿◠)ノ゙ RuoYi-Flex启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||||
System.out.println("(♥◠‿◠)ノ゙ RuoYi-Flex-Boot启动成功 ლ(´ڡ`ლ)゙ \n" +
|
|
||||||
" ███████ ██ ██ ██ ████████ ██ \n" +
|
" ███████ ██ ██ ██ ████████ ██ \n" +
|
||||||
"░██░░░░██ ░░██ ██ ░░ ░██░░░░░ ░██ \n" +
|
"░██░░░░██ ░░██ ██ ░░ ░██░░░░░ ░██ \n" +
|
||||||
"░██ ░██ ██ ██ ██████ ░░████ ██ ░██ ░██ █████ ██ ██\n" +
|
"░██ ░██ ██ ██ ██████ ░░████ ██ ░██ ░██ █████ ██ ██\n" +
|
||||||
|
@ -1,48 +1,31 @@
|
|||||||
package com.ruoyi.web.controller;
|
package com.ruoyi.web.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.core.domain.model.SocialLoginBody;
|
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.utils.*;
|
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.encrypt.annotation.ApiEncrypt;
|
|
||||||
import com.ruoyi.common.json.utils.JsonUtils;
|
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
import com.ruoyi.common.security.utils.LoginHelper;
|
||||||
import com.ruoyi.common.social.config.properties.SocialLoginConfigProperties;
|
import com.ruoyi.system.domain.SysMenu;
|
||||||
import com.ruoyi.common.social.config.properties.SocialProperties;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.common.social.utils.SocialUtils;
|
|
||||||
import com.ruoyi.common.websocket.dto.WebSocketMessageDto;
|
|
||||||
import com.ruoyi.common.websocket.utils.WebSocketUtils;
|
|
||||||
import com.ruoyi.system.domain.bo.SysTenantBo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysTenantVo;
|
|
||||||
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.service.*;
|
||||||
import com.ruoyi.web.domain.vo.LoginTenantVo;
|
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
|
||||||
import com.ruoyi.web.domain.vo.TenantListVo;
|
|
||||||
import com.ruoyi.web.service.SysRegisterService;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.ruoyi.common.core.core.domain.R;
|
import com.ruoyi.common.core.core.domain.R;
|
||||||
import com.ruoyi.common.core.core.domain.model.LoginBody;
|
import com.ruoyi.common.core.core.domain.model.LoginBody;
|
||||||
import com.ruoyi.common.core.core.domain.model.RegisterBody;
|
import com.ruoyi.common.core.core.domain.model.RegisterBody;
|
||||||
|
import com.ruoyi.common.core.utils.MessageUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.system.domain.SysClient;
|
||||||
import com.ruoyi.web.service.IAuthStrategy;
|
import com.ruoyi.web.service.IAuthStrategy;
|
||||||
import com.ruoyi.web.service.SysLoginService;
|
import com.ruoyi.web.service.SysLoginService;
|
||||||
import me.zhyd.oauth.model.AuthResponse;
|
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
|
||||||
import me.zhyd.oauth.request.AuthRequest;
|
|
||||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static com.ruoyi.system.domain.table.SysClientTableDef.SYS_CLIENT;
|
import static com.ruoyi.system.domain.table.SysClientTableDef.SYS_CLIENT;
|
||||||
|
|
||||||
@ -54,165 +37,114 @@ import static com.ruoyi.system.domain.table.SysClientTableDef.SYS_CLIENT;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
|
@Validated
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/auth")
|
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysLoginService loginService;
|
private final SysLoginService loginService;
|
||||||
@Resource
|
@Resource
|
||||||
private ISysClientService clientService;
|
private final ISysClientService clientService;
|
||||||
@Resource
|
@Resource
|
||||||
private SysRegisterService registerService;
|
private final ISysUserService sysUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private final ISysPermissionService permissionService;
|
||||||
@Resource
|
@Resource
|
||||||
private ISysTenantService tenantService;
|
private ISysMenuService menuService;
|
||||||
@Resource
|
|
||||||
private ISysSocialService socialService;
|
|
||||||
|
|
||||||
private final ScheduledExecutorService scheduledExecutorService;
|
|
||||||
private final SocialProperties socialProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录方法
|
* 登录方法
|
||||||
*
|
*
|
||||||
* @param body 登录信息
|
* @param loginBody 登录信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ApiEncrypt
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public R<LoginVo> login(@RequestBody String body) {
|
public AjaxResult login(@Validated @RequestBody LoginBody loginBody) {
|
||||||
LoginBody loginBody = JsonUtils.parseObject(body, LoginBody.class);
|
|
||||||
ValidatorUtils.validate(loginBody);
|
AjaxResult ajax = AjaxResult.success();
|
||||||
// 授权类型和客户端id
|
// 授权类型和客户端id
|
||||||
String clientId = loginBody.getClientId();
|
String clientId = loginBody.getClientId();
|
||||||
String grantType = loginBody.getGrantType();
|
String grantType = loginBody.getGrantType();
|
||||||
QueryWrapper query=QueryWrapper.create().from(SYS_CLIENT).where(SYS_CLIENT.CLIENT_ID.eq(clientId));
|
QueryWrapper query=QueryWrapper.create().from(SYS_CLIENT).where(SYS_CLIENT.CLIENT_ID.eq(clientId));
|
||||||
SysClientVo client = clientService.getOneAs(query,SysClientVo.class);
|
SysClient client = clientService.getOne(query);
|
||||||
// 查询不到 client 或 client 内不包含 grantType
|
// 查询不到 client 或 client 内不包含 grantType
|
||||||
if (ObjectUtil.isNull(client) || !StringUtils.contains(client.getGrantType(), grantType)) {
|
if (ObjectUtil.isNull(client) || !StringUtils.contains(client.getGrantType(), grantType)) {
|
||||||
log.info("客户端id: {} 认证类型:{} 异常!.", clientId, grantType);
|
log.info("客户端id: {} 认证类型:{} 异常!.", clientId, grantType);
|
||||||
return R.fail(MessageUtils.message("auth.grant.type.error"));
|
return AjaxResult.error(MessageUtils.message("auth.grant.type.error"));
|
||||||
} else if (!UserConstants.NORMAL.equals(client.getStatus())) {
|
|
||||||
return R.fail(MessageUtils.message("auth.grant.type.blocked"));
|
|
||||||
}
|
}
|
||||||
// 校验租户
|
|
||||||
loginService.checkTenant(loginBody.getTenantId());
|
// TODO:校验租户
|
||||||
|
//loginService.checkTenant(loginBody.getTenantId());
|
||||||
|
|
||||||
|
// 生成令牌
|
||||||
|
String token =IAuthStrategy.login(loginBody, client);
|
||||||
|
ajax.put(Constants.TOKEN, token);
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
LoginVo loginVo =IAuthStrategy.login(body, client, grantType);
|
return ajax;
|
||||||
|
|
||||||
Long userId = LoginHelper.getUserId();
|
|
||||||
scheduledExecutorService.schedule(() -> {
|
|
||||||
WebSocketMessageDto dto = new WebSocketMessageDto();
|
|
||||||
dto.setMessage("欢迎登录RuoYi-Flex多租户管理系统");
|
|
||||||
dto.setSessionKeys(List.of(userId));
|
|
||||||
WebSocketUtils.publishMessage(dto);
|
|
||||||
}, 3, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
return R.ok(loginVo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方登录请求
|
* 获取用户信息
|
||||||
*
|
*
|
||||||
* @param source 登录来源
|
* @return 用户信息
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
@GetMapping("/binding/{source}")
|
@GetMapping("/getInfo")
|
||||||
public R<String> authBinding(@PathVariable("source") String source) {
|
public AjaxResult getInfo() {
|
||||||
SocialLoginConfigProperties obj = socialProperties.getType().get(source);
|
|
||||||
if (ObjectUtil.isNull(obj)) {
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
return R.fail(source + "平台账号暂不支持");
|
|
||||||
}
|
//TODO:多租户 超级管理员 如果重新加载用户信息需清除动态租户
|
||||||
AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties);
|
|
||||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
SysUser user = sysUserService.selectUserById(loginUser.getUserId());
|
||||||
return R.ok("操作成功", authorizeUrl);
|
// 角色集合
|
||||||
|
Set<String> roles = permissionService.getRolePermission(user.getUserId());
|
||||||
|
// 权限集合
|
||||||
|
Set<String> permissions = permissionService.getMenuPermission(user.getUserId());
|
||||||
|
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("user", user);
|
||||||
|
ajax.put("roles", roles);
|
||||||
|
ajax.put("permissions", permissions);
|
||||||
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方登录回调业务处理 绑定授权
|
* 获取路由信息
|
||||||
*
|
*
|
||||||
* @param loginBody 请求体
|
* @return 路由信息
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("/social/callback")
|
@GetMapping("/getRouters")
|
||||||
public R<Void> socialCallback(@RequestBody SocialLoginBody loginBody) {
|
public AjaxResult getRouters()
|
||||||
// 获取第三方登录信息
|
{
|
||||||
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
loginBody.getSource(), loginBody.getSocialCode(),
|
// 用户信息
|
||||||
loginBody.getSocialState(), socialProperties);
|
SysUser user = sysUserService.selectUserById(loginUser.getUserId());
|
||||||
AuthUser authUserData = response.getData();
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId());
|
||||||
// 判断授权响应是否成功
|
return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
if (!response.ok()) {
|
|
||||||
return R.fail(response.getMsg());
|
|
||||||
}
|
|
||||||
loginService.socialRegister(authUserData);
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消授权
|
|
||||||
*
|
|
||||||
* @param socialId socialId
|
|
||||||
*/
|
|
||||||
@DeleteMapping(value = "/unlock/{socialId}")
|
|
||||||
public R<Void> unlockSocial(@PathVariable Long socialId) {
|
|
||||||
Boolean rows = socialService.deleteWithValidById(socialId);
|
|
||||||
return rows ? R.ok() : R.fail("取消授权失败");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
*/
|
*/
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public R<Void> logout() {
|
public AjaxResult logout() {
|
||||||
loginService.logout();
|
loginService.logout();
|
||||||
return R.ok("退出成功!");
|
return AjaxResult.success("退出成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户注册
|
* 用户注册
|
||||||
*/
|
*/
|
||||||
@PostMapping("/register")
|
@PostMapping("LoginHelper.getUserId()")
|
||||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||||
if (!configService.selectRegisterEnabled(user.getTenantId()))
|
//if (!configService.selectRegisterEnabled(user.getTenantId())) // TODO:注册代码
|
||||||
{
|
{
|
||||||
return R.fail("当前系统没有开启注册功能!");
|
return R.fail("当前系统没有开启注册功能!");
|
||||||
}
|
}
|
||||||
registerService.register(user);
|
// registerService.register(user);
|
||||||
return R.ok();
|
// return R.ok();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录页面租户下拉框
|
|
||||||
*
|
|
||||||
* @return 租户列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/tenant/list")
|
|
||||||
public R<LoginTenantVo> tenantList(HttpServletRequest request) throws Exception {
|
|
||||||
List<SysTenantVo> tenantList = tenantService.selectList(new SysTenantBo());
|
|
||||||
List<TenantListVo> voList = MapstructUtils.convert(tenantList, TenantListVo.class);
|
|
||||||
// 获取域名
|
|
||||||
String host;
|
|
||||||
String referer = request.getHeader("referer");
|
|
||||||
if (StringUtils.isNotBlank(referer)) {
|
|
||||||
// 这里从referer中取值是为了本地使用hosts添加虚拟域名,方便本地环境调试
|
|
||||||
host = referer.split("//")[1].split("/")[0];
|
|
||||||
} else {
|
|
||||||
host = new URL(request.getRequestURL().toString()).getHost();
|
|
||||||
}
|
|
||||||
// 根据域名进行筛选
|
|
||||||
List<TenantListVo> list = StreamUtils.filter(voList, vo ->
|
|
||||||
StringUtils.equals(vo.getDomain(), host));
|
|
||||||
// 返回对象
|
|
||||||
LoginTenantVo vo = new LoginTenantVo();
|
|
||||||
vo.setTenantEnabled(true);
|
|
||||||
vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
|
|
||||||
return R.ok(vo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,35 +2,21 @@ package com.ruoyi.web.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import cn.hutool.captcha.AbstractCaptcha;
|
import cn.hutool.captcha.AbstractCaptcha;
|
||||||
import cn.hutool.captcha.generator.CodeGenerator;
|
import cn.hutool.captcha.generator.CodeGenerator;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
|
||||||
import com.ruoyi.common.core.annotation.RateLimiter;
|
|
||||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||||
import com.ruoyi.common.core.core.domain.AjaxResult;
|
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.enums.LimitType;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.core.domain.R;
|
import com.ruoyi.common.core.core.domain.R;
|
||||||
import com.ruoyi.common.encrypt.utils.RSAUtils;
|
|
||||||
import com.ruoyi.common.mail.config.properties.MailProperties;
|
|
||||||
import com.ruoyi.common.mail.utils.MailUtils;
|
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.common.web.enums.CaptchaType;
|
import com.ruoyi.common.web.enums.CaptchaType;
|
||||||
import com.ruoyi.web.domain.vo.CaptchaVo;
|
import com.ruoyi.web.domain.vo.CaptchaVo;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.sms4j.api.SmsBlend;
|
|
||||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
|
||||||
import org.dromara.sms4j.core.factory.SmsFactory;
|
|
||||||
import org.springframework.expression.Expression;
|
import org.springframework.expression.Expression;
|
||||||
import org.springframework.expression.ExpressionParser;
|
import org.springframework.expression.ExpressionParser;
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
@ -44,7 +30,6 @@ import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
|||||||
* 验证码操作处理
|
* 验证码操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @author 数据小王子
|
|
||||||
*/
|
*/
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -54,19 +39,17 @@ import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
|||||||
public class CaptchaController
|
public class CaptchaController
|
||||||
{
|
{
|
||||||
private final CaptchaProperties captchaProperties;
|
private final CaptchaProperties captchaProperties;
|
||||||
private final MailProperties mailProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@RateLimiter(time = 60, count = 10, limitType = LimitType.IP)
|
@GetMapping("/captchaImage")
|
||||||
@GetMapping("/auth/code")
|
public AjaxResult getCode() {
|
||||||
public R<CaptchaVo> getCode() {
|
|
||||||
CaptchaVo captchaVo = new CaptchaVo();
|
CaptchaVo captchaVo = new CaptchaVo();
|
||||||
boolean captchaEnabled = captchaProperties.getEnable();
|
boolean captchaEnabled = captchaProperties.getEnable();
|
||||||
if (!captchaEnabled) {
|
if (!captchaEnabled) {
|
||||||
captchaVo.setCaptchaEnabled(false);
|
captchaVo.setCaptchaEnabled(false);
|
||||||
return R.ok(captchaVo);
|
return AjaxResult.success(captchaVo);
|
||||||
}
|
}
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtil.simpleUUID();
|
String uuid = IdUtil.simpleUUID();
|
||||||
@ -79,7 +62,6 @@ public class CaptchaController
|
|||||||
AbstractCaptcha captcha = SpringUtils.getBean(captchaProperties.getCategory().getClazz());
|
AbstractCaptcha captcha = SpringUtils.getBean(captchaProperties.getCategory().getClazz());
|
||||||
captcha.setGenerator(codeGenerator);
|
captcha.setGenerator(codeGenerator);
|
||||||
captcha.createCode();
|
captcha.createCode();
|
||||||
// 如果是数学验证码,使用SpEL表达式处理验证码结果
|
|
||||||
String code = captcha.getCode();
|
String code = captcha.getCode();
|
||||||
if (isMath) {
|
if (isMath) {
|
||||||
ExpressionParser parser = new SpelExpressionParser();
|
ExpressionParser parser = new SpelExpressionParser();
|
||||||
@ -90,76 +72,8 @@ public class CaptchaController
|
|||||||
|
|
||||||
captchaVo.setUuid(uuid);
|
captchaVo.setUuid(uuid);
|
||||||
captchaVo.setImg(captcha.getImageBase64());
|
captchaVo.setImg(captcha.getImageBase64());
|
||||||
return R.ok(captchaVo);
|
return AjaxResult.success(captchaVo);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱验证码
|
|
||||||
*
|
|
||||||
* @param email 邮箱
|
|
||||||
*/
|
|
||||||
@RateLimiter(key = "#email", time = 60, count = 1)
|
|
||||||
@GetMapping("/resource/email/code")
|
|
||||||
public R<Void> emailCode(@NotBlank(message = "{user.email.not.blank}") String email) {
|
|
||||||
if (!mailProperties.getEnabled()) {
|
|
||||||
return R.fail("当前系统没有开启邮箱功能!");
|
|
||||||
}
|
|
||||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + email;
|
|
||||||
String code = RandomUtil.randomNumbers(4);
|
|
||||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
|
||||||
try {
|
|
||||||
MailUtils.sendText(email, "登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证码短信发送异常 => {}", e.getMessage());
|
|
||||||
return R.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信验证码
|
|
||||||
*
|
|
||||||
* @param phonenumber 用户手机号
|
|
||||||
*/
|
|
||||||
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
|
||||||
@GetMapping("/resource/sms/code")
|
|
||||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
|
||||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
|
||||||
String code = RandomUtil.randomNumbers(4);
|
|
||||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
|
||||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
|
||||||
String templateId = "";
|
|
||||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
|
||||||
map.put("code", code);
|
|
||||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
|
||||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
|
||||||
if (!smsResponse.isSuccess()) {
|
|
||||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
|
||||||
return R.fail(smsResponse.getData().toString());
|
|
||||||
}
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/genKeyPair")
|
|
||||||
public R genKeyPair() {
|
|
||||||
Map<String,String> map=new HashMap<>();
|
|
||||||
try {
|
|
||||||
log.info("开始生产rsa秘钥");
|
|
||||||
|
|
||||||
Map<String, Object> keyPair = RSAUtils.genKeyPair();
|
|
||||||
String publicKey = RSAUtils.getPublicKey(keyPair);
|
|
||||||
String privateKey = RSAUtils.getPrivateKey(keyPair);
|
|
||||||
log.info("privateKey:"+privateKey);
|
|
||||||
String uuid="ruoyi_"+ UUID.randomUUID().toString().replace("-","");
|
|
||||||
RedisUtils.setCacheMapValue("loginRsa",uuid,privateKey);
|
|
||||||
RedisUtils.expire("loginRsa",60*60);
|
|
||||||
log.info("写入redis完成");
|
|
||||||
|
|
||||||
map.put("uuidPrivateKey",uuid);
|
|
||||||
map.put("RSA_PUBLIC_KEY",publicKey);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return R.fail("生成RSA秘钥失败,"+e.getMessage());
|
|
||||||
}
|
|
||||||
return R.ok(map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package com.ruoyi.web.domain.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录租户对象
|
|
||||||
*
|
|
||||||
* @author Michelle.Chung
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class LoginTenantVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户开关
|
|
||||||
*/
|
|
||||||
private Boolean tenantEnabled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户对象列表
|
|
||||||
*/
|
|
||||||
private List<TenantListVo> voList;
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.ruoyi.web.domain.vo;
|
|
||||||
|
|
||||||
import com.ruoyi.system.domain.vo.SysTenantVo;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户列表
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AutoMapper(target = SysTenantVo.class)
|
|
||||||
public class TenantListVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户编号
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
private String companyName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 域名
|
|
||||||
*/
|
|
||||||
private String domain;
|
|
||||||
|
|
||||||
}
|
|
@ -6,8 +6,6 @@ import com.ruoyi.common.core.core.domain.model.LoginBody;
|
|||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.system.domain.SysClient;
|
import com.ruoyi.system.domain.SysClient;
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权策略
|
* 授权策略
|
||||||
@ -20,29 +18,28 @@ public interface IAuthStrategy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*
|
|
||||||
* @param body 登录对象
|
|
||||||
* @param client 授权管理视图对象
|
|
||||||
* @param grantType 授权类型
|
|
||||||
* @return 登录验证信息
|
|
||||||
*/
|
*/
|
||||||
static LoginVo login(String body, SysClientVo client, String grantType) {
|
static String login(LoginBody loginBody, SysClient client) {
|
||||||
// 授权类型和客户端id
|
// 授权类型和客户端id
|
||||||
|
String clientId = loginBody.getClientId();
|
||||||
|
String grantType = loginBody.getGrantType();
|
||||||
String beanName = grantType + BASE_NAME;
|
String beanName = grantType + BASE_NAME;
|
||||||
if (!SpringUtils.containsBean(beanName)) {
|
if (!SpringUtils.containsBean(beanName)) {
|
||||||
throw new ServiceException("授权类型不正确!");
|
throw new ServiceException("授权类型不正确!");
|
||||||
}
|
}
|
||||||
IAuthStrategy instance = SpringUtils.getBean(beanName);
|
IAuthStrategy instance = SpringUtils.getBean(beanName);
|
||||||
return instance.login(body,client);
|
instance.validate(loginBody);
|
||||||
|
return instance.login(clientId, loginBody, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 参数校验
|
||||||
*
|
|
||||||
* @param body 登录对象
|
|
||||||
* @param client 授权管理视图对象
|
|
||||||
* @return 登录验证信息
|
|
||||||
*/
|
*/
|
||||||
LoginVo login(String body, SysClientVo client);
|
void validate(LoginBody loginBody);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录
|
||||||
|
*/
|
||||||
|
String login(String clientId, LoginBody loginBody, SysClient client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,37 +3,31 @@ package com.ruoyi.web.service;
|
|||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.*;
|
import com.ruoyi.common.core.constant.*;
|
||||||
import com.ruoyi.common.core.core.domain.dto.RoleDTO;
|
import com.ruoyi.common.core.core.domain.dto.RoleDTO;
|
||||||
import com.ruoyi.common.core.enums.LoginType;
|
import com.ruoyi.common.core.enums.LoginType;
|
||||||
import com.ruoyi.common.core.enums.TenantStatus;
|
|
||||||
import com.ruoyi.common.core.exception.user.*;
|
import com.ruoyi.common.core.exception.user.*;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.log.event.LogininforEvent;
|
import com.ruoyi.common.log.event.LogininforEvent;
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
import com.ruoyi.common.security.utils.LoginHelper;
|
||||||
import com.ruoyi.common.tenant.exception.TenantException;
|
|
||||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
import com.ruoyi.common.tenant.helper.TenantHelper;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.bo.SysSocialBo;
|
import com.ruoyi.system.domain.vo.SysUserVo;
|
||||||
import com.ruoyi.system.domain.bo.SysUserBo;
|
import com.ruoyi.system.service.ISysPermissionService;
|
||||||
import com.ruoyi.system.domain.vo.*;
|
|
||||||
import com.ruoyi.system.service.*;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.MessageUtils;
|
import com.ruoyi.common.core.utils.MessageUtils;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -41,7 +35,6 @@ import java.util.function.Supplier;
|
|||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @author 数据小王子
|
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -54,75 +47,11 @@ public class SysLoginService {
|
|||||||
@Value("${user.password.lockTime}")
|
@Value("${user.password.lockTime}")
|
||||||
private Integer lockTime;
|
private Integer lockTime;
|
||||||
|
|
||||||
@Resource
|
private final ISysPermissionService permissionService;
|
||||||
private ISysPermissionService permissionService;
|
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private ISysSocialService sysSocialService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ISysDeptService deptService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ISysRoleService roleService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ISysTenantService tenantService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绑定第三方用户
|
|
||||||
*
|
|
||||||
* @param authUserData 授权响应实体
|
|
||||||
* @return 统一响应实体
|
|
||||||
*/
|
|
||||||
public void socialRegister(AuthUser authUserData) {
|
|
||||||
String authId = authUserData.getSource() + authUserData.getUuid();
|
|
||||||
// 第三方用户信息
|
|
||||||
SysSocialBo bo = BeanUtil.toBean(authUserData, SysSocialBo.class);
|
|
||||||
BeanUtil.copyProperties(authUserData.getToken(), bo);
|
|
||||||
bo.setUserId(LoginHelper.getUserId());
|
|
||||||
bo.setAuthId(authId);
|
|
||||||
bo.setOpenId(authUserData.getUuid());
|
|
||||||
bo.setUserName(authUserData.getUsername());
|
|
||||||
bo.setNickName(authUserData.getNickname());
|
|
||||||
// 查询是否已经绑定用户
|
|
||||||
List<SysSocialVo> list = sysSocialService.selectListByAuthId(authId);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
// 没有绑定用户, 新增用户信息
|
|
||||||
sysSocialService.insertByBo(bo);
|
|
||||||
} else {
|
|
||||||
// 更新用户信息
|
|
||||||
bo.setSocialId(list.get(0).getSocialId());
|
|
||||||
sysSocialService.updateByBo(bo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退出登录
|
|
||||||
*/
|
|
||||||
public void logout() {
|
|
||||||
try {
|
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
||||||
if (ObjectUtil.isNull(loginUser)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (LoginHelper.isSuperAdmin()) {
|
|
||||||
// 超级管理员 登出清除动态租户
|
|
||||||
TenantHelper.clearDynamic();
|
|
||||||
}
|
|
||||||
recordLogininfor(loginUser.getTenantId(), loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
|
||||||
} catch (NotLoginException ignored) {
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
StpUtil.logout();
|
|
||||||
} catch (NotLoginException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验
|
* 登录校验
|
||||||
*/
|
*/
|
||||||
@ -160,34 +89,23 @@ public class SysLoginService {
|
|||||||
/**
|
/**
|
||||||
* 校验租户
|
* 校验租户
|
||||||
*
|
*
|
||||||
* @param tenantId 租户编号
|
* @param tenantId 租户ID
|
||||||
*/
|
*/
|
||||||
public void checkTenant(Long tenantId) {
|
public void checkTenant(String tenantId) {
|
||||||
|
if (!TenantHelper.isEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNull(tenantId)) {
|
|
||||||
throw new TenantException("tenant.number.not.blank");
|
|
||||||
}
|
|
||||||
SysTenantVo tenant = tenantService.selectById(tenantId);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNull(tenant)) {
|
//TODO:完善heckTenant功能
|
||||||
log.info("登录租户:{} 不存在.", tenantId);
|
|
||||||
throw new TenantException("tenant.not.exists");
|
|
||||||
} else if (TenantStatus.DISABLE.getCode().equals(tenant.getStatus())) {
|
|
||||||
log.info("登录租户:{} 已被停用.", tenantId);
|
|
||||||
throw new TenantException("tenant.blocked");
|
|
||||||
} else if (ObjectUtil.isNotNull(tenant.getExpireTime())
|
|
||||||
&& new Date().after(tenant.getExpireTime())) {
|
|
||||||
log.info("登录租户:{} 已超过有效期.", tenantId);
|
|
||||||
throw new TenantException("tenant.expired");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建登录用户
|
* 构建登录用户
|
||||||
*/
|
*/
|
||||||
public LoginUser buildLoginUser(SysUserVo user) {
|
public LoginUser buildLoginUser(SysUser user) {
|
||||||
LoginUser loginUser = new LoginUser();
|
LoginUser loginUser = new LoginUser();
|
||||||
loginUser.setTenantId(user.getTenantId());
|
loginUser.setTenantId(user.getTenantId());
|
||||||
loginUser.setUserId(user.getUserId());
|
loginUser.setUserId(user.getUserId());
|
||||||
@ -207,15 +125,13 @@ public class SysLoginService {
|
|||||||
* 记录登录信息
|
* 记录登录信息
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param version 乐观锁
|
|
||||||
*/
|
*/
|
||||||
public void recordLoginInfo(Long userId,Integer version) {
|
public void recordLoginInfo(Long userId) {
|
||||||
SysUserBo sysUser = new SysUserBo();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserId(userId);
|
sysUser.setUserId(userId);
|
||||||
sysUser.setLoginIp(ServletUtils.getClientIP());
|
sysUser.setLoginIp(ServletUtils.getClientIP());
|
||||||
sysUser.setLoginDate(DateUtils.getNowDate());
|
sysUser.setLoginDate(DateUtils.getNowDate());
|
||||||
sysUser.setUpdateBy(userId);
|
sysUser.setUpdateBy(userId);
|
||||||
sysUser.setVersion(version);
|
|
||||||
userService.updateUserProfile(sysUser);
|
userService.updateUserProfile(sysUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,24 +154,22 @@ public class SysLoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录登录信息
|
* 退出登录
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
*/
|
*/
|
||||||
public void recordLoginInfo(Long userId, String ip) {
|
public void logout() {
|
||||||
SysUserVo sysUserVo = userService.selectUserById(userId);
|
try {
|
||||||
if (ObjectUtil.isNull(sysUserVo)) {
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
return;
|
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
|
||||||
|
// 超级管理员 登出清除动态租户
|
||||||
|
TenantHelper.clearDynamic();
|
||||||
|
}
|
||||||
|
recordLogininfor(loginUser.getTenantId(), loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||||
|
} catch (NotLoginException ignored) {
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
StpUtil.logout();
|
||||||
|
} catch (NotLoginException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SysUser sysUser = new SysUser();
|
|
||||||
sysUser.setUserId(userId);
|
|
||||||
sysUser.setLoginIp(ip);
|
|
||||||
sysUser.setLoginDate(DateUtils.getNowDate());
|
|
||||||
sysUser.setUpdateBy(userId);
|
|
||||||
sysUser.setVersion(sysUserVo.getVersion());
|
|
||||||
userService.updateById(sysUser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.ruoyi.common.core.utils.ServletUtils;
|
|||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.log.event.LogininforEvent;
|
import com.ruoyi.common.log.event.LogininforEvent;
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
|
||||||
import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.bo.SysUserBo;
|
import com.ruoyi.system.domain.bo.SysUserBo;
|
||||||
@ -31,7 +30,8 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysRegisterService {
|
public class SysRegisterService
|
||||||
|
{
|
||||||
@Resource
|
@Resource
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@ -43,36 +43,33 @@ public class SysRegisterService {
|
|||||||
/**
|
/**
|
||||||
* 注册
|
* 注册
|
||||||
*/
|
*/
|
||||||
public void register(RegisterBody registerBody) {
|
public void register(RegisterBody registerBody)
|
||||||
|
{
|
||||||
Long tenantId = registerBody.getTenantId();
|
Long tenantId = registerBody.getTenantId();
|
||||||
TenantHelper.dynamic(tenantId, () -> {
|
String username = registerBody.getUsername();
|
||||||
String username = registerBody.getUsername();
|
String password = registerBody.getPassword();
|
||||||
String password = registerBody.getPassword();
|
// 校验用户类型是否存在
|
||||||
// 校验用户类型是否存在
|
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
||||||
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
|
||||||
|
|
||||||
boolean captchaEnabled = captchaProperties.getEnable();
|
boolean captchaEnabled = captchaProperties.getEnable();
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
if (captchaEnabled) {
|
if (captchaEnabled) {
|
||||||
validateCaptcha(tenantId, username, registerBody.getCode(), registerBody.getUuid());
|
validateCaptcha(tenantId, username, registerBody.getCode(), registerBody.getUuid());
|
||||||
}
|
}
|
||||||
SysUserBo sysUser = new SysUserBo();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserName(username);
|
sysUser.setUserName(username);
|
||||||
sysUser.setNickName(username);
|
sysUser.setNickName(username);
|
||||||
sysUser.setPassword(BCrypt.hashpw(password));
|
sysUser.setPassword(BCrypt.hashpw(password));
|
||||||
sysUser.setUserType(userType);
|
sysUser.setUserType(userType);
|
||||||
|
|
||||||
boolean unique = userService.checkUserNameUnique(sysUser);
|
if (!userService.checkUserNameUnique(sysUser)) {
|
||||||
|
throw new UserException("user.register.save.error", username);
|
||||||
if (!unique) {
|
}
|
||||||
throw new UserException("user.register.save.error", username);
|
boolean regFlag = userService.registerUser(sysUser, tenantId);
|
||||||
}
|
if (!regFlag) {
|
||||||
boolean regFlag = userService.registerUser(sysUser, tenantId);
|
throw new UserException("user.register.error");
|
||||||
if (!regFlag) {
|
}
|
||||||
throw new UserException("user.register.error");
|
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||||
}
|
|
||||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +81,7 @@ public class SysRegisterService {
|
|||||||
* @param uuid 唯一标识
|
* @param uuid 唯一标识
|
||||||
*/
|
*/
|
||||||
public void validateCaptcha(Long tenantId, String username, String code, String uuid) {
|
public void validateCaptcha(Long tenantId, String username, String code, String uuid) {
|
||||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
|
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
|
||||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||||
RedisUtils.deleteObject(verifyKey);
|
RedisUtils.deleteObject(verifyKey);
|
||||||
if (captcha == null) {
|
if (captcha == null) {
|
||||||
|
@ -3,17 +3,12 @@ package com.ruoyi.web.service.impl;
|
|||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
import cn.dev33.satoken.stp.SaLoginModel;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.core.domain.model.EmailLoginBody;
|
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.json.utils.JsonUtils;
|
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||||
|
import com.ruoyi.common.core.core.domain.model.LoginBody;
|
||||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.enums.LoginType;
|
import com.ruoyi.common.core.enums.LoginType;
|
||||||
import com.ruoyi.common.core.enums.UserStatus;
|
import com.ruoyi.common.core.enums.UserStatus;
|
||||||
@ -22,8 +17,12 @@ import com.ruoyi.common.core.exception.user.UserException;
|
|||||||
import com.ruoyi.common.core.utils.MessageUtils;
|
import com.ruoyi.common.core.utils.MessageUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ValidatorUtils;
|
import com.ruoyi.common.core.utils.ValidatorUtils;
|
||||||
|
import com.ruoyi.common.core.validate.auth.EmailGroup;
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
import com.ruoyi.common.security.utils.LoginHelper;
|
||||||
|
import com.ruoyi.system.domain.SysClient;
|
||||||
|
import com.ruoyi.system.domain.SysUser;
|
||||||
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import com.ruoyi.web.service.IAuthStrategy;
|
import com.ruoyi.web.service.IAuthStrategy;
|
||||||
import com.ruoyi.web.service.SysLoginService;
|
import com.ruoyi.web.service.SysLoginService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -38,42 +37,45 @@ import org.springframework.stereotype.Service;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class EmailAuthStrategy implements IAuthStrategy {
|
public class EmailAuthStrategy implements IAuthStrategy {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private final SysLoginService loginService;
|
private final SysLoginService loginService;
|
||||||
@Resource
|
private final SysUserMapper userMapper;
|
||||||
private ISysUserService userService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String body, SysClientVo client) {
|
public void validate(LoginBody loginBody) {
|
||||||
EmailLoginBody loginBody = JsonUtils.parseObject(body, EmailLoginBody.class);
|
ValidatorUtils.validate(loginBody, EmailGroup.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String login(String clientId, LoginBody loginBody, SysClient client) {
|
||||||
Long tenantId = loginBody.getTenantId();
|
Long tenantId = loginBody.getTenantId();
|
||||||
String email = loginBody.getEmail();
|
String email = loginBody.getEmail();
|
||||||
String emailCode = loginBody.getEmailCode();
|
String emailCode = loginBody.getEmailCode();
|
||||||
|
|
||||||
// 通过邮箱查找用户
|
// 通过邮箱查找用户
|
||||||
SysUserVo user = loadUserByEmail(tenantId, email);
|
SysUser user = loadUserByEmail(tenantId, email);
|
||||||
|
|
||||||
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), () -> !validateEmailCode(tenantId, email, emailCode));
|
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), () -> !validateEmailCode(tenantId, email, emailCode));
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
loginUser.setClientKey(client.getClientKey());
|
|
||||||
loginUser.setDeviceType(client.getDeviceType());
|
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
model.setDevice(client.getDeviceType());
|
model.setDevice(client.getDeviceType());
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
loginService.recordLogininfor(loginUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginService.recordLoginInfo(user.getUserId());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
|
||||||
loginVo.setClientId(client.getClientId());
|
// LoginVo loginVo = new LoginVo();
|
||||||
return loginVo;
|
// loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
|
// loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
|
// loginVo.setClientId(clientId);
|
||||||
|
// return loginVo;
|
||||||
|
return StpUtil.getTokenValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,8 +90,12 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
|||||||
return code.equals(emailCode);
|
return code.equals(emailCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SysUserVo loadUserByEmail(Long tenantId, String email) {
|
private SysUser loadUserByEmail(Long tenantId, String email) {
|
||||||
SysUserVo user = userService.selectTenantUserByEmail(tenantId, email);
|
// SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||||
|
// .select(SysUser::getEmail, SysUser::getStatus)
|
||||||
|
// .eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
||||||
|
// .eq(SysUser::getEmail, email));
|
||||||
|
SysUser user =userMapper.selectUserByEmail(email);
|
||||||
if (ObjectUtil.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
log.info("登录用户:{} 不存在.", email);
|
log.info("登录用户:{} 不存在.", email);
|
||||||
throw new UserException("user.not.exists", email);
|
throw new UserException("user.not.exists", email);
|
||||||
@ -97,8 +103,10 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
|||||||
log.info("登录用户:{} 已被停用.", email);
|
log.info("登录用户:{} 已被停用.", email);
|
||||||
throw new UserException("user.blocked", email);
|
throw new UserException("user.blocked", email);
|
||||||
}
|
}
|
||||||
|
// if (TenantHelper.isEnable()) {
|
||||||
|
// return userMapper.selectTenantUserByEmail(email, tenantId);
|
||||||
|
// }
|
||||||
return user;
|
return user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,14 @@ import cn.dev33.satoken.secure.BCrypt;
|
|||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
import cn.dev33.satoken.stp.SaLoginModel;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.core.domain.model.PasswordLoginBody;
|
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.json.utils.JsonUtils;
|
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||||
|
import com.ruoyi.common.core.core.domain.model.LoginBody;
|
||||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.enums.LoginType;
|
import com.ruoyi.common.core.enums.LoginType;
|
||||||
import com.ruoyi.common.core.enums.UserStatus;
|
import com.ruoyi.common.core.enums.UserStatus;
|
||||||
@ -22,10 +21,14 @@ import com.ruoyi.common.core.exception.user.UserException;
|
|||||||
import com.ruoyi.common.core.utils.MessageUtils;
|
import com.ruoyi.common.core.utils.MessageUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ValidatorUtils;
|
import com.ruoyi.common.core.utils.ValidatorUtils;
|
||||||
|
import com.ruoyi.common.core.validate.auth.PasswordGroup;
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
import com.ruoyi.common.security.utils.LoginHelper;
|
||||||
import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
||||||
|
import com.ruoyi.system.domain.SysClient;
|
||||||
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
import com.ruoyi.system.domain.vo.SysUserVo;
|
||||||
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
import com.ruoyi.web.domain.vo.LoginVo;
|
||||||
import com.ruoyi.web.service.IAuthStrategy;
|
import com.ruoyi.web.service.IAuthStrategy;
|
||||||
import com.ruoyi.web.service.SysLoginService;
|
import com.ruoyi.web.service.SysLoginService;
|
||||||
@ -42,15 +45,19 @@ import org.springframework.stereotype.Service;
|
|||||||
public class PasswordAuthStrategy implements IAuthStrategy {
|
public class PasswordAuthStrategy implements IAuthStrategy {
|
||||||
|
|
||||||
private final CaptchaProperties captchaProperties;
|
private final CaptchaProperties captchaProperties;
|
||||||
@Resource
|
private final SysLoginService loginService;
|
||||||
private SysLoginService loginService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
//private final SysUserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String body, SysClientVo client) {
|
public void validate(LoginBody loginBody) {
|
||||||
PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
|
ValidatorUtils.validate(loginBody, PasswordGroup.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String login(String clientId, LoginBody loginBody, SysClient client) {
|
||||||
Long tenantId = loginBody.getTenantId();
|
Long tenantId = loginBody.getTenantId();
|
||||||
String username = loginBody.getUsername();
|
String username = loginBody.getUsername();
|
||||||
String password = loginBody.getPassword();
|
String password = loginBody.getPassword();
|
||||||
@ -63,28 +70,31 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||||||
validateCaptcha(tenantId, username, code, uuid);
|
validateCaptcha(tenantId, username, code, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
SysUserVo user = loadUserByUsername(tenantId, username);
|
SysUser user = loadUserByUsername(tenantId, username);
|
||||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
loginUser.setClientKey(client.getClientKey());
|
|
||||||
loginUser.setDeviceType(client.getDeviceType());
|
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
model.setDevice(client.getDeviceType());
|
model.setDevice(client.getDeviceType());
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
loginService.recordLogininfor(loginUser.getTenantId(), username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginService.recordLoginInfo(user.getUserId());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
|
||||||
loginVo.setClientId(client.getClientId());
|
// LoginVo loginVo = new LoginVo();
|
||||||
|
// loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
|
// loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
|
// loginVo.setClientId(clientId);
|
||||||
|
// return loginVo;
|
||||||
|
|
||||||
|
return StpUtil.getTokenValue();
|
||||||
|
|
||||||
return loginVo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,16 +118,20 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SysUserVo loadUserByUsername(Long tenantId, String username) {
|
private SysUser loadUserByUsername(Long tenantId, String username) {
|
||||||
SysUserVo user = userService.selectTenantUserByUserName(tenantId,username);
|
//TODO:以后根据tenantId条件过滤查询:
|
||||||
if (ObjectUtil.isNull(user)) {
|
SysUser user = userService.selectUserByUserName(username);
|
||||||
log.info("登录用户:{} 不存在.", username);
|
if (ObjectUtil.isNull(user)) {
|
||||||
throw new UserException("user.not.exists", username);
|
log.info("登录用户:{} 不存在.", username);
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
throw new UserException("user.not.exists", username);
|
||||||
log.info("登录用户:{} 已被停用.", username);
|
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
throw new UserException("user.blocked", username);
|
log.info("登录用户:{} 已被停用.", username);
|
||||||
}
|
throw new UserException("user.blocked", username);
|
||||||
return user;
|
}
|
||||||
|
// if (TenantHelper.isEnable()) {
|
||||||
|
// return userMapper.selectTenantUserByUserName(username, tenantId);
|
||||||
|
// }
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
package com.ruoyi.web.service.impl;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.core.core.domain.model.SmsLoginBody;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
|
||||||
import com.ruoyi.common.core.enums.LoginType;
|
|
||||||
import com.ruoyi.common.core.enums.UserStatus;
|
|
||||||
import com.ruoyi.common.core.exception.user.CaptchaExpireException;
|
|
||||||
import com.ruoyi.common.core.exception.user.UserException;
|
|
||||||
import com.ruoyi.common.core.utils.MessageUtils;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.core.utils.ValidatorUtils;
|
|
||||||
import com.ruoyi.common.json.utils.JsonUtils;
|
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
|
||||||
import com.ruoyi.web.service.IAuthStrategy;
|
|
||||||
import com.ruoyi.web.service.SysLoginService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信认证策略
|
|
||||||
*
|
|
||||||
* @author Michelle.Chung
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sms" + IAuthStrategy.BASE_NAME)
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class SmsAuthStrategy implements IAuthStrategy {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SysLoginService loginService;
|
|
||||||
@Resource
|
|
||||||
private ISysUserService userService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoginVo login(String body, SysClientVo client) {
|
|
||||||
SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
|
||||||
ValidatorUtils.validate(loginBody);
|
|
||||||
Long tenantId = loginBody.getTenantId();
|
|
||||||
String phonenumber = loginBody.getPhonenumber();
|
|
||||||
String smsCode = loginBody.getSmsCode();
|
|
||||||
|
|
||||||
// 通过手机号查找用户
|
|
||||||
SysUserVo user = loadUserByPhonenumber(tenantId, phonenumber);
|
|
||||||
|
|
||||||
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
|
||||||
loginUser.setClientKey(client.getClientKey());
|
|
||||||
loginUser.setDeviceType(client.getDeviceType());
|
|
||||||
SaLoginModel model = new SaLoginModel();
|
|
||||||
model.setDevice(client.getDeviceType());
|
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
|
||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
|
||||||
model.setTimeout(client.getTimeout());
|
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
|
||||||
// 生成token
|
|
||||||
LoginHelper.login(loginUser, model);
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
|
||||||
loginVo.setClientId(client.getClientId());
|
|
||||||
return loginVo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验短信验证码
|
|
||||||
*/
|
|
||||||
private boolean validateSmsCode(Long tenantId, String phonenumber, String smsCode) {
|
|
||||||
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phonenumber);
|
|
||||||
if (StringUtils.isBlank(code)) {
|
|
||||||
loginService.recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
|
||||||
throw new CaptchaExpireException();
|
|
||||||
}
|
|
||||||
return code.equals(smsCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SysUserVo loadUserByPhonenumber(Long tenantId, String phonenumber) {
|
|
||||||
SysUserVo user = userService.selectTenantUserByPhonenumber(tenantId, phonenumber);
|
|
||||||
if (ObjectUtil.isNull(user)) {
|
|
||||||
log.info("登录用户:{} 不存在.", phonenumber);
|
|
||||||
throw new UserException("user.not.exists", phonenumber);
|
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
|
||||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
|
||||||
throw new UserException("user.blocked", phonenumber);
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
package com.ruoyi.web.service.impl;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import me.zhyd.oauth.model.AuthResponse;
|
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
|
||||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.core.core.domain.model.SocialLoginBody;
|
|
||||||
import com.ruoyi.common.core.enums.UserStatus;
|
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.core.exception.user.UserException;
|
|
||||||
import com.ruoyi.common.core.utils.ValidatorUtils;
|
|
||||||
import com.ruoyi.common.json.utils.JsonUtils;
|
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
|
||||||
import com.ruoyi.common.social.config.properties.SocialProperties;
|
|
||||||
import com.ruoyi.common.social.utils.SocialUtils;
|
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysSocialVo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
|
||||||
import com.ruoyi.system.service.ISysSocialService;
|
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
|
||||||
import com.ruoyi.web.service.IAuthStrategy;
|
|
||||||
import com.ruoyi.web.service.SysLoginService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第三方授权策略
|
|
||||||
*
|
|
||||||
* @author thiszhc is 三三
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("social" + IAuthStrategy.BASE_NAME)
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class SocialAuthStrategy implements IAuthStrategy {
|
|
||||||
|
|
||||||
private final SocialProperties socialProperties;
|
|
||||||
@Resource
|
|
||||||
private ISysSocialService sysSocialService;
|
|
||||||
@Resource
|
|
||||||
private ISysUserService userService;
|
|
||||||
@Resource
|
|
||||||
private SysLoginService loginService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录-第三方授权登录
|
|
||||||
*
|
|
||||||
* @param body 登录信息
|
|
||||||
* @param client 客户端信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public LoginVo login(String body, SysClientVo client) {
|
|
||||||
SocialLoginBody loginBody = JsonUtils.parseObject(body, SocialLoginBody.class);
|
|
||||||
ValidatorUtils.validate(loginBody);
|
|
||||||
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
|
||||||
loginBody.getSource(), loginBody.getSocialCode(),
|
|
||||||
loginBody.getSocialState(), socialProperties);
|
|
||||||
if (!response.ok()) {
|
|
||||||
throw new ServiceException(response.getMsg());
|
|
||||||
}
|
|
||||||
AuthUser authUserData = response.getData();
|
|
||||||
|
|
||||||
List<SysSocialVo> list = sysSocialService.selectListByAuthId(authUserData.getSource() + authUserData.getUuid());
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
|
||||||
}
|
|
||||||
Optional<SysSocialVo> opt = list.stream().filter(x -> x.getTenantId().equals(loginBody.getTenantId())).findAny();
|
|
||||||
if (opt.isEmpty()) {
|
|
||||||
throw new ServiceException("对不起,你没有权限登录当前租户!");
|
|
||||||
}
|
|
||||||
SysSocialVo social = opt.get();
|
|
||||||
|
|
||||||
// 查找用户
|
|
||||||
SysUserVo user = loadUser(social.getTenantId(), social.getUserId());
|
|
||||||
|
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
|
||||||
loginUser.setClientKey(client.getClientKey());
|
|
||||||
loginUser.setDeviceType(client.getDeviceType());
|
|
||||||
SaLoginModel model = new SaLoginModel();
|
|
||||||
model.setDevice(client.getDeviceType());
|
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
|
||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
|
||||||
model.setTimeout(client.getTimeout());
|
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
|
||||||
// 生成token
|
|
||||||
LoginHelper.login(loginUser, model);
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
|
||||||
loginVo.setClientId(client.getClientId());
|
|
||||||
return loginVo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SysUserVo loadUser(Long tenantId, Long userId) {
|
|
||||||
SysUserVo user = userService.selectTenantUserById(tenantId, userId);
|
|
||||||
if (ObjectUtil.isNull(user)) {
|
|
||||||
log.info("登录用户:{} 不存在.", "");
|
|
||||||
throw new UserException("user.not.exists", "");
|
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
|
||||||
log.info("登录用户:{} 已被停用.", "");
|
|
||||||
throw new UserException("user.blocked", "");
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
package com.ruoyi.web.service.impl;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.ruoyi.common.core.core.domain.model.XcxLoginBody;
|
|
||||||
import com.ruoyi.common.core.core.domain.model.XcxLoginUser;
|
|
||||||
import com.ruoyi.common.core.enums.UserStatus;
|
|
||||||
import com.ruoyi.common.core.utils.ValidatorUtils;
|
|
||||||
import com.ruoyi.common.json.utils.JsonUtils;
|
|
||||||
import com.ruoyi.common.security.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.domain.vo.SysClientVo;
|
|
||||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
|
||||||
import com.ruoyi.web.domain.vo.LoginVo;
|
|
||||||
import com.ruoyi.web.service.IAuthStrategy;
|
|
||||||
import com.ruoyi.web.service.SysLoginService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序认证策略
|
|
||||||
*
|
|
||||||
* @author Michelle.Chung
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("xcx" + IAuthStrategy.BASE_NAME)
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class XcxAuthStrategy implements IAuthStrategy {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SysLoginService loginService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoginVo login(String body, SysClientVo client) {
|
|
||||||
XcxLoginBody loginBody = JsonUtils.parseObject(body, XcxLoginBody.class);
|
|
||||||
ValidatorUtils.validate(loginBody);
|
|
||||||
// xcxCode 为 小程序调用 wx.login 授权后获取
|
|
||||||
String xcxCode = loginBody.getXcxCode();
|
|
||||||
// 多个小程序识别使用
|
|
||||||
String appid = loginBody.getAppid();
|
|
||||||
|
|
||||||
// todo 以下自行实现
|
|
||||||
// 校验 appid + appsrcret + xcxCode 调用登录凭证校验接口 获取 session_key 与 openid
|
|
||||||
String openid = "";
|
|
||||||
// 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可
|
|
||||||
SysUserVo user = loadUserByOpenid(openid);
|
|
||||||
|
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
|
||||||
XcxLoginUser loginUser = new XcxLoginUser();
|
|
||||||
loginUser.setTenantId(user.getTenantId());
|
|
||||||
loginUser.setUserId(user.getUserId());
|
|
||||||
loginUser.setUsername(user.getUserName());
|
|
||||||
loginUser.setNickname(user.getNickName());
|
|
||||||
loginUser.setUserType(user.getUserType());
|
|
||||||
loginUser.setClientKey(client.getClientKey());
|
|
||||||
loginUser.setDeviceType(client.getDeviceType());
|
|
||||||
loginUser.setOpenid(openid);
|
|
||||||
|
|
||||||
SaLoginModel model = new SaLoginModel();
|
|
||||||
model.setDevice(client.getDeviceType());
|
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
|
||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
|
||||||
model.setTimeout(client.getTimeout());
|
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
|
||||||
// 生成token
|
|
||||||
LoginHelper.login(loginUser, model);
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
|
||||||
loginVo.setClientId(client.getClientId());
|
|
||||||
loginVo.setOpenid(openid);
|
|
||||||
return loginVo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SysUserVo loadUserByOpenid(String openid) {
|
|
||||||
// 使用 openid 查询绑定用户 如未绑定用户 则根据业务自行处理 例如 创建默认用户
|
|
||||||
// todo 自行实现 userService.selectUserByOpenid(openid);
|
|
||||||
SysUserVo user = new SysUserVo();
|
|
||||||
if (ObjectUtil.isNull(user)) {
|
|
||||||
log.info("登录用户:{} 不存在.", openid);
|
|
||||||
// todo 用户不存在 业务逻辑自行实现
|
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
|
||||||
log.info("登录用户:{} 已被停用.", openid);
|
|
||||||
// todo 用户已被停用 业务逻辑自行实现
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
restart.include.json=/com.alibaba.fastjson2.*.jar
|
restart.include.json=/com.alibaba.fastjson.*.jar
|
||||||
restart.include.mapper=/mapper-[\\w-\\.].jar
|
restart.include.mapper=/mapper-[\\w-\\.].jar
|
||||||
restart.include.pagehelper=/pagehelper-[\\w-\\.].jar
|
restart.include.pagehelper=/pagehelper-[\\w-\\.].jar
|
||||||
restart.include.mybatis-flex=/mybatis-flex-[\\w-\\.]+jar
|
restart.include.mybatis-flex=/mybatis-flex-[\\w-\\.]+jar
|
||||||
|
@ -1,43 +1,70 @@
|
|||||||
--- # 数据源配置
|
# 数据源及mybatis、mybatis-flex配置
|
||||||
spring:
|
|
||||||
datasource:
|
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
|
||||||
hikari:
|
|
||||||
# 最大连接池数量
|
|
||||||
maximum-pool-size: 20
|
|
||||||
# 最小空闲线程数量
|
|
||||||
minimum-idle: 10
|
|
||||||
# 配置获取连接等待超时的时间
|
|
||||||
connectionTimeout: 30000
|
|
||||||
# 校验超时时间
|
|
||||||
validationTimeout: 5000
|
|
||||||
# 空闲连接存活最大时间,默认10分钟
|
|
||||||
idleTimeout: 600000
|
|
||||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
|
||||||
maxLifetime: 1800000
|
|
||||||
# 多久检查一次连接的活性
|
|
||||||
keepaliveTime: 30000
|
|
||||||
mybatis-flex:
|
mybatis-flex:
|
||||||
# sql审计
|
# 搜索指定包别名
|
||||||
audit_enable: true
|
typeAliasesPackage: com.ruoyi.**.domain
|
||||||
# sql打印
|
# 不支持多包, 如有需要可在注解配置 或 提升扫包等级:com.**.**.mapper
|
||||||
sql_print: true
|
mapperPackage: com.ruoyi.**.mapper
|
||||||
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
|
|
||||||
|
#本部分(Configuration)的配置都为 MyBatis 原生支持的配置,有关配置请参考:https://mybatis.org/mybatis-3/zh/configuration.html#%E8%AE%BE%E7%BD%AE%EF%BC%88settings%EF%BC%89
|
||||||
|
configuration:
|
||||||
|
# 自动驼峰命名规则(camel case)映射
|
||||||
|
mapUnderscoreToCamelCase: true
|
||||||
|
# MyBatis 自动映射策略
|
||||||
|
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||||
|
autoMappingBehavior: FULL
|
||||||
|
# MyBatis 自动映射时未知列或未知属性处理策
|
||||||
|
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||||
|
autoMappingUnknownColumnBehavior: NONE
|
||||||
|
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
|
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
cacheEnabled: true
|
||||||
|
useGeneratedKeys: true
|
||||||
|
defaultExecutorType: SIMPLE
|
||||||
|
|
||||||
|
# MyBatis-Flex全局配置
|
||||||
|
global-config:
|
||||||
|
# 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
|
||||||
|
print-banner: true
|
||||||
|
# 逻辑删除数据存在标记值
|
||||||
|
normal-value-of-logic-delete: 0
|
||||||
|
# 逻辑删除数据存在标记值
|
||||||
|
deleted-value-of-logic-delete: 1
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# 数据源-1
|
# 数据源-1
|
||||||
ds1:
|
PrimaryDS:
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# 指定为HikariDataSource
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
type: ${spring.datasource.type}
|
|
||||||
# mysql数据库
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
|
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
|
||||||
username: root
|
username: root123
|
||||||
password: Root@369
|
password: Root@369---0000
|
||||||
#postgresql数据库
|
|
||||||
# driver-class-name: org.postgresql.Driver
|
hikari:
|
||||||
# url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
#连接池名
|
||||||
# username: postgres
|
pool-name: HikariCP-PrimaryDS
|
||||||
# password: postgres@369
|
#最小空闲连接数
|
||||||
|
minimum-idle: 5
|
||||||
|
# 空闲连接存活最大时间,默认10分钟
|
||||||
|
idle-timeout: 600000
|
||||||
|
# 连接池最大连接数,默认是10
|
||||||
|
maximum-pool-size: 10
|
||||||
|
# 此属性控制从池返回的连接的默认自动提交行为,默认值:true
|
||||||
|
auto-commit: true
|
||||||
|
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||||
|
max-lifetime: 1800000
|
||||||
|
# 数据库连接超时时间,默认30秒
|
||||||
|
connection-timeout: 30000
|
||||||
|
# 校验超时时间
|
||||||
|
validationTimeout: 5000
|
||||||
|
# 多久检查一次连接的活性
|
||||||
|
keepaliveTime: 30000
|
||||||
|
# 连接测试query
|
||||||
|
connection-test-query: SELECT 1
|
||||||
|
|
||||||
# redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
# redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||||
spring.data:
|
spring.data:
|
||||||
@ -77,10 +104,22 @@ redisson:
|
|||||||
# 发布和订阅连接池大小
|
# 发布和订阅连接池大小
|
||||||
subscriptionConnectionPoolSize: 50
|
subscriptionConnectionPoolSize: 50
|
||||||
|
|
||||||
--- # 监控中心客户端配置
|
--- # Actuator 监控端点的配置项
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: '*'
|
||||||
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: ALWAYS
|
||||||
|
logfile:
|
||||||
|
external-file: ./logs/ruoyi-monitor.log
|
||||||
|
|
||||||
|
--- # 监控中心配置
|
||||||
spring.boot.admin.client:
|
spring.boot.admin.client:
|
||||||
# 增加客户端开关
|
# 增加客户端开关
|
||||||
enabled: false
|
enabled: true
|
||||||
url: http://localhost:9090/admin
|
url: http://localhost:9090/admin
|
||||||
instance:
|
instance:
|
||||||
service-host-type: IP
|
service-host-type: IP
|
||||||
@ -91,7 +130,7 @@ spring.boot.admin.client:
|
|||||||
powerjob:
|
powerjob:
|
||||||
worker:
|
worker:
|
||||||
# 如何开启调度中心请查看文档教程
|
# 如何开启调度中心请查看文档教程
|
||||||
enabled: false
|
enabled: true
|
||||||
# 需要先在 powerjob 登录页执行应用注册后才能使用
|
# 需要先在 powerjob 登录页执行应用注册后才能使用
|
||||||
app-name: ruoyi-worker
|
app-name: ruoyi-worker
|
||||||
# 28080 端口 随着主应用端口飘逸 避免集群冲突
|
# 28080 端口 随着主应用端口飘逸 避免集群冲突
|
||||||
@ -99,149 +138,8 @@ powerjob:
|
|||||||
protocol: http
|
protocol: http
|
||||||
server-address: 127.0.0.1:7700
|
server-address: 127.0.0.1:7700
|
||||||
store-strategy: disk
|
store-strategy: disk
|
||||||
allow-lazy-connect-server: false
|
enable-test-mode: false
|
||||||
max-appended-wf-context-length: 4096
|
max-appended-wf-context-length: 4096
|
||||||
max-result-length: 4096
|
max-result-length: 4096
|
||||||
|
|
||||||
--- # easy-retry 配置
|
|
||||||
easy-retry:
|
|
||||||
enabled: false
|
|
||||||
# 需要在EasyRetry后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
|
|
||||||
group-name: "ruoyi_group"
|
|
||||||
# EasyRetry接入验证令牌 详见 script/sql/easy_retry.sql `er_group_config` 表
|
|
||||||
token: "ER_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
|
|
||||||
server:
|
|
||||||
host: 127.0.0.1
|
|
||||||
port: 1788
|
|
||||||
# 详见 script/sql/easy_retry.sql `er_namespace` 表
|
|
||||||
namespace: ${spring.profiles.active}
|
|
||||||
|
|
||||||
--- # mail 邮件发送
|
|
||||||
mail:
|
|
||||||
enabled: false
|
|
||||||
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 短信 支持 阿里云 腾讯云 云片 等等各式各样的短信服务商
|
|
||||||
# https://sms4j.com/doc3/ 差异配置文档地址 支持单厂商多配置,可以配置多个同时使用
|
|
||||||
sms:
|
|
||||||
# 配置源类型用于标定配置来源(interface,yaml)
|
|
||||||
config-type: yaml
|
|
||||||
# 用于标定yml中的配置是否开启短信拦截,接口配置不受此限制
|
|
||||||
restricted: true
|
|
||||||
# 短信拦截限制单手机号每分钟最大发送,只对开启了拦截的配置有效
|
|
||||||
minute-max: 1
|
|
||||||
# 短信拦截限制单手机号每日最大发送量,只对开启了拦截的配置有效
|
|
||||||
account-max: 30
|
|
||||||
# 以下配置来自于 org.dromara.sms4j.provider.config.BaseConfig类中
|
|
||||||
blends:
|
|
||||||
# 唯一ID 用于发送短信寻找具体配置 随便定义别用中文即可
|
|
||||||
# 可以同时存在两个相同厂商 例如: ali1 ali2 两个不同的阿里短信账号 也可用于区分租户
|
|
||||||
config1:
|
|
||||||
# 框架定义的厂商名称标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
|
||||||
supplier: alibaba
|
|
||||||
# 有些称为accessKey有些称之为apiKey,也有称为sdkKey或者appId。
|
|
||||||
access-key-id: 您的accessKey
|
|
||||||
# 称为accessSecret有些称之为apiSecret
|
|
||||||
access-key-secret: 您的accessKeySecret
|
|
||||||
signature: 您的短信签名
|
|
||||||
sdk-app-id: 您的sdkAppId
|
|
||||||
config2:
|
|
||||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
|
||||||
supplier: tencent
|
|
||||||
access-key-id: 您的accessKey
|
|
||||||
access-key-secret: 您的accessKeySecret
|
|
||||||
signature: 您的短信签名
|
|
||||||
sdk-app-id: 您的sdkAppId
|
|
||||||
|
|
||||||
--- # 三方授权
|
|
||||||
justauth:
|
|
||||||
# 前端外网访问地址
|
|
||||||
address: http://localhost:80
|
|
||||||
type:
|
|
||||||
maxkey:
|
|
||||||
# maxkey 服务器地址
|
|
||||||
# 注意 如下均配置均不需要修改 maxkey 已经内置好了数据
|
|
||||||
server-url: http://sso.maxkey.top
|
|
||||||
client-id: 876892492581044224
|
|
||||||
client-secret: x1Y5MTMwNzIwMjMxNTM4NDc3Mzche8
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=maxkey
|
|
||||||
topiam:
|
|
||||||
# topiam 服务器地址
|
|
||||||
server-url: http://127.0.0.1:1989/api/v1/authorize/y0q************spq***********8ol
|
|
||||||
client-id: 449c4*********937************759
|
|
||||||
client-secret: ac7***********1e0************28d
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=topiam
|
|
||||||
scopes: [openid, email, phone, profile]
|
|
||||||
qq:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=qq
|
|
||||||
union-id: false
|
|
||||||
weibo:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=weibo
|
|
||||||
gitee:
|
|
||||||
client-id: 91436b7940090**********d67eea73acbf61b6b590751a98
|
|
||||||
client-secret: 02c6fcfd70342980cd8**********c754d7a264c4e125f9ba915ac
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=gitee
|
|
||||||
dingtalk:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=dingtalk
|
|
||||||
baidu:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=baidu
|
|
||||||
csdn:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=csdn
|
|
||||||
coding:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=coding
|
|
||||||
coding-group-name: xx
|
|
||||||
oschina:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=oschina
|
|
||||||
alipay_wallet:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=alipay_wallet
|
|
||||||
alipay-public-key: MIIB**************DAQAB
|
|
||||||
wechat_open:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_open
|
|
||||||
wechat_mp:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_mp
|
|
||||||
wechat_enterprise:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_enterprise
|
|
||||||
agent-id: 1000002
|
|
||||||
gitlab:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
--- # 数据源配置
|
# 临时文件存储位置 避免临时文件被系统清理报错
|
||||||
spring:
|
spring.servlet.multipart.location: /ruoyi/server/temp
|
||||||
datasource:
|
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
# 数据源及mybatis、mybatis-flex配置
|
||||||
hikari:
|
|
||||||
# 最大连接池数量
|
|
||||||
maximum-pool-size: 20
|
|
||||||
# 最小空闲线程数量
|
|
||||||
minimum-idle: 10
|
|
||||||
# 配置获取连接等待超时的时间
|
|
||||||
connectionTimeout: 30000
|
|
||||||
# 校验超时时间
|
|
||||||
validationTimeout: 5000
|
|
||||||
# 空闲连接存活最大时间,默认10分钟
|
|
||||||
idleTimeout: 600000
|
|
||||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
|
||||||
maxLifetime: 1800000
|
|
||||||
# 多久检查一次连接的活性
|
|
||||||
keepaliveTime: 30000
|
|
||||||
mybatis-flex:
|
mybatis-flex:
|
||||||
# sql审计
|
# 搜索指定包别名
|
||||||
audit_enable: false
|
typeAliasesPackage: com.ruoyi.**.domain
|
||||||
# sql打印
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
sql_print: false
|
mapper-locations: classpath*:mapper/**/*Mapper.xml
|
||||||
|
cacheEnabled: true
|
||||||
|
useGeneratedKeys: true
|
||||||
|
defaultExecutorType: SIMPLE
|
||||||
|
|
||||||
|
#本部分(Configuration)的配置都为 MyBatis 原生支持的配置,有关配置请参考:https://mybatis.org/mybatis-3/zh/configuration.html#%E8%AE%BE%E7%BD%AE%EF%BC%88settings%EF%BC%89
|
||||||
|
configuration:
|
||||||
|
# 自动驼峰命名规则(camel case)映射
|
||||||
|
mapUnderscoreToCamelCase: true
|
||||||
|
# MyBatis 自动映射策略
|
||||||
|
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||||
|
autoMappingBehavior: FULL
|
||||||
|
# MyBatis 自动映射时未知列或未知属性处理策
|
||||||
|
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||||
|
autoMappingUnknownColumnBehavior: NONE
|
||||||
|
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
|
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
|
||||||
|
|
||||||
|
# MyBatis-Flex全局配置
|
||||||
|
global-config:
|
||||||
|
# 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
|
||||||
|
print-banner: false
|
||||||
|
# 逻辑删除数据存在标记值
|
||||||
|
normal-value-of-logic-delete: 0
|
||||||
|
# 逻辑删除数据存在标记值
|
||||||
|
deleted-value-of-logic-delete: 1
|
||||||
|
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# 数据源-1
|
# 数据源-1
|
||||||
ds1:
|
PrimaryDS:
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# 指定为HikariDataSource
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
type: ${spring.datasource.type}
|
|
||||||
# mysql数据库
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
|
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
|
||||||
username: root
|
username: root123
|
||||||
password: Root@369
|
password: Root@369---0000
|
||||||
#postgresql数据库
|
|
||||||
# driver-class-name: org.postgresql.Driver
|
hikari:
|
||||||
# url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
#连接池名
|
||||||
# username: postgres
|
pool-name: HikariCP-PrimaryDS
|
||||||
# password: postgres@369
|
#最小空闲连接数
|
||||||
|
minimum-idle: 10
|
||||||
|
# 空闲连接存活最大时间,默认10分钟
|
||||||
|
idle-timeout: 600000
|
||||||
|
# 连接池最大连接数,默认是10
|
||||||
|
maximum-pool-size: 20
|
||||||
|
# 此属性控制从池返回的连接的默认自动提交行为,默认值:true
|
||||||
|
auto-commit: true
|
||||||
|
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||||
|
max-lifetime: 1800000
|
||||||
|
# 数据库连接超时时间,默认30秒
|
||||||
|
connection-timeout: 30000
|
||||||
|
# 校验超时时间
|
||||||
|
validationTimeout: 5000
|
||||||
|
# 多久检查一次连接的活性
|
||||||
|
keepaliveTime: 30000
|
||||||
|
# 连接测试query
|
||||||
|
connection-test-query: SELECT 1
|
||||||
|
|
||||||
# redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
# redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||||
spring.data:
|
spring.data:
|
||||||
@ -77,7 +107,19 @@ redisson:
|
|||||||
# 发布和订阅连接池大小
|
# 发布和订阅连接池大小
|
||||||
subscriptionConnectionPoolSize: 50
|
subscriptionConnectionPoolSize: 50
|
||||||
|
|
||||||
--- # 监控中心客户端配置
|
--- # Actuator 监控端点的配置项
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: '*'
|
||||||
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: ALWAYS
|
||||||
|
logfile:
|
||||||
|
external-file: ./logs/ruoyi-monitor.log
|
||||||
|
|
||||||
|
--- # 监控中心配置
|
||||||
spring.boot.admin.client:
|
spring.boot.admin.client:
|
||||||
# 增加客户端开关
|
# 增加客户端开关
|
||||||
enabled: true
|
enabled: true
|
||||||
@ -94,155 +136,12 @@ powerjob:
|
|||||||
enabled: true
|
enabled: true
|
||||||
# 需要先在 powerjob 登录页执行应用注册后才能使用
|
# 需要先在 powerjob 登录页执行应用注册后才能使用
|
||||||
app-name: ruoyi-worker
|
app-name: ruoyi-worker
|
||||||
|
enable-test-mode: false
|
||||||
|
max-appended-wf-context-length: 4096
|
||||||
|
max-result-length: 4096
|
||||||
# 28080 端口 随着主应用端口飘逸 避免集群冲突
|
# 28080 端口 随着主应用端口飘逸 避免集群冲突
|
||||||
port: 2${server.port}
|
port: 2${server.port}
|
||||||
protocol: http
|
protocol: http
|
||||||
server-address: 127.0.0.1:7700
|
server-address: 127.0.0.1:7700
|
||||||
store-strategy: disk
|
store-strategy: disk
|
||||||
allow-lazy-connect-server: false
|
|
||||||
max-appended-wf-context-length: 4096
|
|
||||||
max-result-length: 4096
|
|
||||||
|
|
||||||
--- # easy-retry 配置
|
|
||||||
easy-retry:
|
|
||||||
enabled: false
|
|
||||||
# 需要在EasyRetry后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
|
|
||||||
group-name: "ruoyi_group"
|
|
||||||
# EasyRetry接入验证令牌 详见 script/sql/easy_retry.sql `er_group_config` 表
|
|
||||||
token: "ER_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
|
|
||||||
server:
|
|
||||||
host: 127.0.0.1
|
|
||||||
port: 1788
|
|
||||||
# 详见 script/sql/easy_retry.sql `er_namespace` 表
|
|
||||||
namespace: ${spring.profiles.active}
|
|
||||||
|
|
||||||
--- # mail 邮件发送
|
|
||||||
mail:
|
|
||||||
enabled: false
|
|
||||||
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 短信 支持 阿里云 腾讯云 云片 等等各式各样的短信服务商
|
|
||||||
# https://sms4j.com/doc3/ 差异配置文档地址 支持单厂商多配置,可以配置多个同时使用
|
|
||||||
sms:
|
|
||||||
# 配置源类型用于标定配置来源(interface,yaml)
|
|
||||||
config-type: yaml
|
|
||||||
# 用于标定yml中的配置是否开启短信拦截,接口配置不受此限制
|
|
||||||
restricted: true
|
|
||||||
# 短信拦截限制单手机号每分钟最大发送,只对开启了拦截的配置有效
|
|
||||||
minute-max: 1
|
|
||||||
# 短信拦截限制单手机号每日最大发送量,只对开启了拦截的配置有效
|
|
||||||
account-max: 30
|
|
||||||
# 以下配置来自于 org.dromara.sms4j.provider.config.BaseConfig类中
|
|
||||||
blends:
|
|
||||||
# 唯一ID 用于发送短信寻找具体配置 随便定义别用中文即可
|
|
||||||
# 可以同时存在两个相同厂商 例如: ali1 ali2 两个不同的阿里短信账号 也可用于区分租户
|
|
||||||
config1:
|
|
||||||
# 框架定义的厂商名称标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
|
||||||
supplier: alibaba
|
|
||||||
# 有些称为accessKey有些称之为apiKey,也有称为sdkKey或者appId。
|
|
||||||
access-key-id: 您的accessKey
|
|
||||||
# 称为accessSecret有些称之为apiSecret
|
|
||||||
access-key-secret: 您的accessKeySecret
|
|
||||||
signature: 您的短信签名
|
|
||||||
sdk-app-id: 您的sdkAppId
|
|
||||||
config2:
|
|
||||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
|
||||||
supplier: tencent
|
|
||||||
access-key-id: 您的accessKey
|
|
||||||
access-key-secret: 您的accessKeySecret
|
|
||||||
signature: 您的短信签名
|
|
||||||
sdk-app-id: 您的sdkAppId
|
|
||||||
|
|
||||||
|
|
||||||
--- # 三方授权
|
|
||||||
justauth:
|
|
||||||
# 前端外网访问地址
|
|
||||||
address: http://localhost:80
|
|
||||||
type:
|
|
||||||
maxkey:
|
|
||||||
# maxkey 服务器地址
|
|
||||||
# 注意 如下均配置均不需要修改 maxkey 已经内置好了数据
|
|
||||||
server-url: http://sso.maxkey.top
|
|
||||||
client-id: 876892492581044224
|
|
||||||
client-secret: x1Y5MTMwNzIwMjMxNTM4NDc3Mzche8
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=maxkey
|
|
||||||
topiam:
|
|
||||||
# topiam 服务器地址
|
|
||||||
server-url: http://127.0.0.1:1989/api/v1/authorize/y0q************spq***********8ol
|
|
||||||
client-id: 449c4*********937************759
|
|
||||||
client-secret: ac7***********1e0************28d
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=topiam
|
|
||||||
scopes: [openid, email, phone, profile]
|
|
||||||
qq:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=qq
|
|
||||||
union-id: false
|
|
||||||
weibo:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=weibo
|
|
||||||
gitee:
|
|
||||||
client-id: 91436b7940090**********d67eea73acbf61b6b590751a98
|
|
||||||
client-secret: 02c6fcfd70342980cd8**********c754d7a264c4e125f9ba915ac
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=gitee
|
|
||||||
dingtalk:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=dingtalk
|
|
||||||
baidu:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=baidu
|
|
||||||
csdn:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=csdn
|
|
||||||
coding:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=coding
|
|
||||||
coding-group-name: xx
|
|
||||||
oschina:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=oschina
|
|
||||||
alipay_wallet:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=alipay_wallet
|
|
||||||
alipay-public-key: MIIB**************DAQAB
|
|
||||||
wechat_open:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_open
|
|
||||||
wechat_mp:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_mp
|
|
||||||
wechat_enterprise:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=wechat_enterprise
|
|
||||||
agent-id: 1000002
|
|
||||||
gitlab:
|
|
||||||
client-id: 10**********6
|
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
|
||||||
|
@ -3,13 +3,13 @@ ruoyi:
|
|||||||
# 名称
|
# 名称
|
||||||
name: Ruoyi-Flex
|
name: Ruoyi-Flex
|
||||||
# 版本
|
# 版本
|
||||||
version: ${revision}
|
version: 4.1.7
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2023 ~ 2024
|
copyrightYear: 2023
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: true
|
||||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||||
profile: /home/ruoyi/uploadPath
|
profile: D:/ruoyi/uploadPath
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
addressEnabled: false
|
addressEnabled: false
|
||||||
|
|
||||||
@ -33,35 +33,27 @@ server:
|
|||||||
# 应用的访问路径
|
# 应用的访问路径
|
||||||
context-path: /
|
context-path: /
|
||||||
|
|
||||||
# tomcat web容器配置
|
|
||||||
tomcat:
|
|
||||||
# tomcat的URI编码
|
|
||||||
uri-encoding: UTF-8
|
|
||||||
# 连接数满后的排队数,默认为100
|
|
||||||
accept-count: 1000
|
|
||||||
|
|
||||||
# undertow web容器配置
|
# undertow web容器配置
|
||||||
# undertow:
|
undertow:
|
||||||
# # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的
|
# HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的
|
||||||
# max-http-post-size: -1
|
max-http-post-size: -1
|
||||||
# # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
|
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
|
||||||
# # 每块buffer的空间大小,越小的空间被利用越充分
|
# 每块buffer的空间大小,越小的空间被利用越充分
|
||||||
# buffer-size: 512
|
buffer-size: 512
|
||||||
# # 是否分配的直接内存
|
# 是否分配的直接内存
|
||||||
# direct-buffers: true
|
direct-buffers: true
|
||||||
# threads:
|
threads:
|
||||||
# # 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
|
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
|
||||||
# io: 8
|
io: 8
|
||||||
# # 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载
|
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载
|
||||||
# worker: 256
|
worker: 256
|
||||||
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.ruoyi: @logging.level@
|
com.ruoyi: debug
|
||||||
org.springframework: warn
|
org.springframework: warn
|
||||||
tech.powerjob.worker.background: warn
|
tech.powerjob.worker.background: warn
|
||||||
org.mybatis.spring.mapper: error
|
|
||||||
config: classpath:logback.xml
|
config: classpath:logback.xml
|
||||||
|
|
||||||
# 用户配置
|
# 用户配置
|
||||||
@ -76,10 +68,6 @@ user:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: ${ruoyi.name}
|
name: ${ruoyi.name}
|
||||||
threads:
|
|
||||||
# 启用JAVA21虚拟线程
|
|
||||||
virtual:
|
|
||||||
enabled: true
|
|
||||||
# 资源信息
|
# 资源信息
|
||||||
messages:
|
messages:
|
||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
@ -113,90 +101,30 @@ spring:
|
|||||||
# 热部署开关
|
# 热部署开关
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
# token配置
|
||||||
|
token:
|
||||||
|
# 令牌自定义标识
|
||||||
|
header: Authorization
|
||||||
|
# 令牌密钥
|
||||||
|
secret: abcdefghijklmnopqrstuvwxyz
|
||||||
|
# 令牌有效期(默认30分钟)
|
||||||
|
expireTime: 30
|
||||||
|
|
||||||
# PageHelper分页插件
|
# PageHelper分页插件
|
||||||
pagehelper:
|
pagehelper:
|
||||||
#helperDialect: mysql、postgresql pagehelper分页插件会自动检测当前的数据库链接,自动选择合适的分页方式。
|
helperDialect: mysql
|
||||||
supportMethodsArguments: true
|
supportMethodsArguments: true
|
||||||
params: count=countSql
|
params: count=countSql
|
||||||
|
|
||||||
# MyBatisFlex公共配置
|
|
||||||
# https://mybatis-flex.com/zh/base/configuration.html
|
|
||||||
mybatis-flex:
|
|
||||||
# 搜索指定包别名
|
|
||||||
type-aliases-package: com.ruoyi.**.domain
|
|
||||||
# 多包名使用 例如 org.dromara.**.mapper,org.xxx.**.mapper
|
|
||||||
mapper-package: com.ruoyi.**.mapper
|
|
||||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
|
||||||
mapper-locations: classpath*:mapper/**/*Mapper.xml
|
|
||||||
configuration:
|
|
||||||
## 以下为mybatis原生配置 https://mybatis.org/mybatis-3/zh/configuration.html
|
|
||||||
# 自动驼峰命名规则(camel case)映射
|
|
||||||
map_underscore_to_camel_case: true
|
|
||||||
# MyBatis 自动映射策略
|
|
||||||
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
|
||||||
auto_mapping_behavior: FULL
|
|
||||||
# MyBatis 自动映射时未知列或未知属性处理策
|
|
||||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
|
||||||
auto_mapping_unknown_column_behavior: NONE
|
|
||||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
|
||||||
# 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
|
|
||||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
|
||||||
#log_impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
|
||||||
logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
|
||||||
cacheEnabled: true
|
|
||||||
global-config:
|
|
||||||
# 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
|
|
||||||
print-banner: true
|
|
||||||
# 全局的 ID 生成策略配置:雪花算法
|
|
||||||
key-config:
|
|
||||||
key-type: Generator
|
|
||||||
value: snowFlakeId
|
|
||||||
# 逻辑未删除值
|
|
||||||
normal-value-of-logic-delete: 0
|
|
||||||
# 逻辑已删除值(框架表均使用此值 禁止随意修改)
|
|
||||||
deleted-value-of-logic-delete: 1
|
|
||||||
# 默认的逻辑删除字段
|
|
||||||
logic-delete-column: del_flag
|
|
||||||
# 默认的多租户字段
|
|
||||||
tenant-column: tenant_id
|
|
||||||
# 默认的乐观锁字段
|
|
||||||
version-column: version
|
|
||||||
|
|
||||||
# 数据加密
|
|
||||||
mybatis-encryptor:
|
|
||||||
# 是否开启加密
|
|
||||||
enable: false
|
|
||||||
# 默认加密算法
|
|
||||||
algorithm: BASE64
|
|
||||||
# 编码方式 BASE64/HEX。默认BASE64
|
|
||||||
encode: BASE64
|
|
||||||
# 安全秘钥 对称算法的秘钥 如:AES,SM4
|
|
||||||
password:
|
|
||||||
# 公私钥 非对称算法的公私钥 如:SM2,RSA
|
|
||||||
publicKey:
|
|
||||||
privateKey:
|
|
||||||
|
|
||||||
# api接口加密
|
|
||||||
api-decrypt:
|
|
||||||
# 是否开启全局接口加密
|
|
||||||
enabled: true
|
|
||||||
# AES 加密头标识
|
|
||||||
headerFlag: encrypt-key
|
|
||||||
# 响应加密公钥 非对称算法的公私钥 如:SM2,RSA 使用者请自行更换
|
|
||||||
# 对应前端解密私钥 MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3CuPiGL/LcIIm7zryCEIbl1SPzBkr75E2VMtxegyZ1lYRD+7TZGAPkvIsBcaMs6Nsy0L78n2qh+lIZMpLH8wIDAQABAkEAk82Mhz0tlv6IVCyIcw/s3f0E+WLmtPFyR9/WtV3Y5aaejUkU60JpX4m5xNR2VaqOLTZAYjW8Wy0aXr3zYIhhQQIhAMfqR9oFdYw1J9SsNc+CrhugAvKTi0+BF6VoL6psWhvbAiEAxPPNTmrkmrXwdm/pQQu3UOQmc2vCZ5tiKpW10CgJi8kCIFGkL6utxw93Ncj4exE/gPLvKcT+1Emnoox+O9kRXss5AiAMtYLJDaLEzPrAWcZeeSgSIzbL+ecokmFKSDDcRske6QIgSMkHedwND1olF8vlKsJUGK3BcdtM8w4Xq7BpSBwsloE=
|
|
||||||
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJnNwrj4hi/y3CCJu868ghCG5dUj8wZK++RNlTLcXoMmdZWEQ/u02RgD5LyLAXGjLOjbMtC+/J9qofpSGTKSx/MCAwEAAQ==
|
|
||||||
# 请求解密私钥 非对称算法的公私钥 如:SM2,RSA 使用者请自行更换
|
|
||||||
# 对应前端加密公钥 MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==
|
|
||||||
privateKey: MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=
|
|
||||||
|
|
||||||
# SpringDoc配置
|
# SpringDoc配置
|
||||||
springdoc:
|
springdoc:
|
||||||
|
#需要扫描的包,可以配置多个,使用逗号分割
|
||||||
|
packages-to-scan: com.ruoyi
|
||||||
paths-to-exclude: #配置不包含在swagger文档中的api
|
paths-to-exclude: #配置不包含在swagger文档中的api
|
||||||
- /api/test/**
|
- /api/test/**
|
||||||
- /api/mockito/data
|
- /api/mockito/data
|
||||||
swagger-ui:
|
swagger-ui:
|
||||||
enabled: true #开启/禁止swagger,prod可以设置为false
|
enabled: true #开启/禁止swagger,prod可以设置为false
|
||||||
version: 5.11.8 #指定swagger-ui的版本号
|
|
||||||
disable-swagger-default-url: true #禁用default petstore url
|
disable-swagger-default-url: true #禁用default petstore url
|
||||||
path: /swagger-ui.html #swagger页面
|
path: /swagger-ui.html #swagger页面
|
||||||
persistAuthorization: true # 持久化认证数据,如果设置为 true,它会保留授权数据并且不会在浏览器关闭/刷新时丢失
|
persistAuthorization: true # 持久化认证数据,如果设置为 true,它会保留授权数据并且不会在浏览器关闭/刷新时丢失
|
||||||
@ -219,24 +147,20 @@ springdoc:
|
|||||||
email: 738981257@qq.com
|
email: 738981257@qq.com
|
||||||
url: https://gitee.com/dataprince/ruoyi-flex
|
url: https://gitee.com/dataprince/ruoyi-flex
|
||||||
components:
|
components:
|
||||||
# 鉴权方式配置
|
# 鉴权方式配置
|
||||||
security-schemes:
|
security-schemes:
|
||||||
apiKey:
|
apiKey:
|
||||||
type: APIKEY
|
type: APIKEY
|
||||||
in: HEADER
|
in: HEADER
|
||||||
name: ${sa-token.token-name}
|
name: ${sa-token.token-name}
|
||||||
group-configs:
|
group-configs:
|
||||||
- group: 1.web模块
|
- group: 1.演示模块
|
||||||
packages-to-scan: com.ruoyi.web
|
packages-to-scan: com.ruoyi.demo
|
||||||
- group: 2.演示模块
|
- group: 2.通用模块
|
||||||
packages-to-scan:
|
|
||||||
- com.ruoyi.demo
|
|
||||||
- com.ruoyi.mf
|
|
||||||
- group: 3.通用模块
|
|
||||||
packages-to-scan: com.ruoyi.common
|
packages-to-scan: com.ruoyi.common
|
||||||
- group: 4.系统模块
|
- group: 3.系统模块
|
||||||
packages-to-scan: com.ruoyi.system
|
packages-to-scan: com.ruoyi.system
|
||||||
- group: 5.代码生成模块
|
- group: 4.代码生成模块
|
||||||
packages-to-scan: com.ruoyi.generator
|
packages-to-scan: com.ruoyi.generator
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
@ -248,6 +172,15 @@ xss:
|
|||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*,/demo/*
|
urlPatterns: /system/*,/monitor/*,/tool/*,/demo/*
|
||||||
|
|
||||||
|
# 全局线程池相关配置
|
||||||
|
thread-pool:
|
||||||
|
# 是否开启线程池
|
||||||
|
enabled: false
|
||||||
|
# 队列最大长度
|
||||||
|
queueCapacity: 128
|
||||||
|
# 线程池维护线程所允许的空闲时间
|
||||||
|
keepAliveSeconds: 300
|
||||||
|
|
||||||
# 分布式锁 lock4j 全局配置
|
# 分布式锁 lock4j 全局配置
|
||||||
lock4j:
|
lock4j:
|
||||||
# 获取分布式锁超时时间,默认为 3000 毫秒
|
# 获取分布式锁超时时间,默认为 3000 毫秒
|
||||||
@ -300,8 +233,21 @@ security:
|
|||||||
- /captchaImage
|
- /captchaImage
|
||||||
- /captcha/get
|
- /captcha/get
|
||||||
- /captcha/check
|
- /captcha/check
|
||||||
- /genKeyPair
|
|
||||||
- /job/**
|
# 多租户配置
|
||||||
|
tenant:
|
||||||
|
# 是否开启
|
||||||
|
enable: false
|
||||||
|
# 排除表
|
||||||
|
excludes:
|
||||||
|
- sys_menu
|
||||||
|
- sys_tenant
|
||||||
|
- sys_tenant_package
|
||||||
|
- sys_role_dept
|
||||||
|
- sys_role_menu
|
||||||
|
- sys_user_post
|
||||||
|
- sys_user_role
|
||||||
|
- sys_client
|
||||||
|
|
||||||
--- # Actuator 监控端点的配置项
|
--- # Actuator 监控端点的配置项
|
||||||
management:
|
management:
|
||||||
|
@ -29,7 +29,6 @@ user.notfound=请重新登录
|
|||||||
user.forcelogout=管理员强制退出,请重新登录
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
user.unknown.error=未知错误,请重新登录
|
user.unknown.error=未知错误,请重新登录
|
||||||
auth.grant.type.error=认证权限类型错误
|
auth.grant.type.error=认证权限类型错误
|
||||||
auth.grant.type.blocked=认证权限类型已禁用
|
|
||||||
auth.grant.type.not.blank=认证权限类型不能为空
|
auth.grant.type.not.blank=认证权限类型不能为空
|
||||||
auth.clientid.not.blank=认证客户端id不能为空
|
auth.clientid.not.blank=认证客户端id不能为空
|
||||||
##文件上传消息
|
##文件上传消息
|
||||||
@ -50,10 +49,7 @@ sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{1}
|
|||||||
email.code.not.blank=邮箱验证码不能为空
|
email.code.not.blank=邮箱验证码不能为空
|
||||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||||
xcx.code.not.blank=小程序[code]不能为空
|
xcx.code.not.blank=小程序code不能为空
|
||||||
social.source.not.blank=第三方登录平台[source]不能为空
|
|
||||||
social.code.not.blank=第三方登录平台[code]不能为空
|
|
||||||
social.state.not.blank=第三方登录平台[state]不能为空
|
|
||||||
##租户
|
##租户
|
||||||
tenant.number.not.blank=租户编号不能为空
|
tenant.number.not.blank=租户编号不能为空
|
||||||
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
||||||
|
@ -29,7 +29,6 @@ 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
|
||||||
auth.grant.type.error=Auth grant type error
|
auth.grant.type.error=Auth grant type error
|
||||||
auth.grant.type.blocked=Auth grant type disabled
|
|
||||||
auth.grant.type.not.blank=Auth grant type cannot be blank
|
auth.grant.type.not.blank=Auth grant type cannot be blank
|
||||||
auth.clientid.not.blank=Auth clientid cannot be blank
|
auth.clientid.not.blank=Auth clientid cannot be blank
|
||||||
##文件上传消息
|
##文件上传消息
|
||||||
@ -50,10 +49,7 @@ sms.code.retry.limit.exceed=Sms code input error {0} times, account locked for {
|
|||||||
email.code.not.blank=Email code cannot be blank
|
email.code.not.blank=Email code cannot be blank
|
||||||
email.code.retry.limit.count=Email code input error {0} times
|
email.code.retry.limit.count=Email code input error {0} times
|
||||||
email.code.retry.limit.exceed=Email code input error {0} times, account locked for {1} minutes
|
email.code.retry.limit.exceed=Email code input error {0} times, account locked for {1} minutes
|
||||||
xcx.code.not.blank=Mini program [code] cannot be blank
|
xcx.code.not.blank=Mini program code cannot be blank
|
||||||
social.source.not.blank=Social login platform [source] cannot be blank
|
|
||||||
social.code.not.blank=Social login platform [code] cannot be blank
|
|
||||||
social.state.not.blank=Social login platform [state] cannot be blank
|
|
||||||
##租户
|
##租户
|
||||||
tenant.number.not.blank=Tenant number cannot be blank
|
tenant.number.not.blank=Tenant number cannot be blank
|
||||||
tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator
|
tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator
|
||||||
|
@ -29,7 +29,6 @@ user.notfound=请重新登录
|
|||||||
user.forcelogout=管理员强制退出,请重新登录
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
user.unknown.error=未知错误,请重新登录
|
user.unknown.error=未知错误,请重新登录
|
||||||
auth.grant.type.error=认证权限类型错误
|
auth.grant.type.error=认证权限类型错误
|
||||||
auth.grant.type.blocked=认证权限类型已禁用
|
|
||||||
auth.grant.type.not.blank=认证权限类型不能为空
|
auth.grant.type.not.blank=认证权限类型不能为空
|
||||||
auth.clientid.not.blank=认证客户端id不能为空
|
auth.clientid.not.blank=认证客户端id不能为空
|
||||||
##文件上传消息
|
##文件上传消息
|
||||||
@ -50,10 +49,7 @@ sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{1}
|
|||||||
email.code.not.blank=邮箱验证码不能为空
|
email.code.not.blank=邮箱验证码不能为空
|
||||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||||
xcx.code.not.blank=小程序[code]不能为空
|
xcx.code.not.blank=小程序code不能为空
|
||||||
social.source.not.blank=第三方登录平台[source]不能为空
|
|
||||||
social.code.not.blank=第三方登录平台[code]不能为空
|
|
||||||
social.state.not.blank=第三方登录平台[state]不能为空
|
|
||||||
##租户
|
##租户
|
||||||
tenant.number.not.blank=租户编号不能为空
|
tenant.number.not.blank=租户编号不能为空
|
||||||
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="./home/ruoyi/logs" />
|
<property name="log.path" value="/home/ruoyi/logs" />
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
@ -13,23 +13,18 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>ruoyi-common-bom</module>
|
<module>ruoyi-common-bom</module>
|
||||||
<module>ruoyi-common-core</module>
|
<module>ruoyi-common-core</module>
|
||||||
<module>ruoyi-common-encrypt</module>
|
|
||||||
<module>ruoyi-common-excel</module>
|
<module>ruoyi-common-excel</module>
|
||||||
<module>ruoyi-common-job</module>
|
<module>ruoyi-common-job</module>
|
||||||
<module>ruoyi-common-json</module>
|
<module>ruoyi-common-json</module>
|
||||||
<module>ruoyi-common-log</module>
|
<module>ruoyi-common-log</module>
|
||||||
<module>ruoyi-common-mail</module>
|
|
||||||
<module>ruoyi-common-orm</module>
|
<module>ruoyi-common-orm</module>
|
||||||
<module>ruoyi-common-oss</module>
|
|
||||||
<module>ruoyi-common-ratelimiter</module>
|
<module>ruoyi-common-ratelimiter</module>
|
||||||
<module>ruoyi-common-redis</module>
|
<module>ruoyi-common-redis</module>
|
||||||
<module>ruoyi-common-security</module>
|
<module>ruoyi-common-security</module>
|
||||||
<module>ruoyi-common-sms</module>
|
|
||||||
<module>ruoyi-common-social</module>
|
|
||||||
<module>ruoyi-common-springdoc</module>
|
<module>ruoyi-common-springdoc</module>
|
||||||
<module>ruoyi-common-tenant</module>
|
<module>ruoyi-common-tenant</module>
|
||||||
|
<module>ruoyi-common-translation</module>
|
||||||
<module>ruoyi-common-web</module>
|
<module>ruoyi-common-web</module>
|
||||||
<module>ruoyi-common-websocket</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>5.2.0-SNAPSHOT</revision>
|
<revision>4.1.7</revision>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -26,13 +26,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 加解密模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-encrypt</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- excel模块 -->
|
<!-- excel模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -61,13 +54,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 邮件模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-mail</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 数据库映射模块 -->
|
<!-- 数据库映射模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -75,13 +61,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- oss对象存储服务模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-oss</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 限流公共服务 -->
|
<!-- 限流公共服务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -103,20 +82,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 短信模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-sms</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 三方授权认证模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-social</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 接口模块 -->
|
<!-- 接口模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -131,6 +96,13 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 翻译模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common-translation</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- web服务 -->
|
<!-- web服务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -138,13 +110,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- WebSocket模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-websocket</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -60,6 +60,12 @@
|
|||||||
<artifactId>fastjson2</artifactId>
|
<artifactId>fastjson2</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- io常用工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<!-- excel工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
@ -125,6 +131,12 @@
|
|||||||
<artifactId>hutool-extra</artifactId>
|
<artifactId>hutool-extra</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-json</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- mapstruct-plus -->
|
<!-- mapstruct-plus -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.linpeilie</groupId>
|
<groupId>io.github.linpeilie</groupId>
|
||||||
@ -137,22 +149,6 @@
|
|||||||
<artifactId>pagehelper</artifactId>
|
<artifactId>pagehelper</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 离线IP地址定位库 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- findbugs消除打包警告 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
|
||||||
<artifactId>jsr305</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>transmittable-thread-local</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.ruoyi.common.core.config;
|
|||||||
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 程序注解配置
|
* 程序注解配置
|
||||||
@ -12,7 +11,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
|||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
// 表示通过aop框架暴露该代理对象,AopContext能够访问
|
// 表示通过aop框架暴露该代理对象,AopContext能够访问
|
||||||
@EnableAspectJAutoProxy(exposeProxy = true)
|
@EnableAspectJAutoProxy(exposeProxy = true)
|
||||||
@EnableAsync(proxyTargetClass = true)
|
// 指定要扫描的Mapper类的包的路径
|
||||||
public class ApplicationConfig
|
public class ApplicationConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import com.ruoyi.common.core.exception.ServiceException;
|
|||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
@ -15,10 +13,10 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步配置
|
* 异步配置
|
||||||
* <p>
|
*
|
||||||
* 如果未使用虚拟线程则生效
|
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@EnableAsync(proxyTargetClass = true)
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
public class AsyncConfig implements AsyncConfigurer {
|
public class AsyncConfig implements AsyncConfigurer {
|
||||||
|
|
||||||
@ -27,9 +25,6 @@ public class AsyncConfig implements AsyncConfigurer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Executor getAsyncExecutor() {
|
public Executor getAsyncExecutor() {
|
||||||
if(SpringUtils.isVirtual()) {
|
|
||||||
return new VirtualThreadTaskExecutor("async-");
|
|
||||||
}
|
|
||||||
return SpringUtils.getBean("scheduledExecutorService");
|
return SpringUtils.getBean("scheduledExecutorService");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package com.ruoyi.common.core.config;
|
package com.ruoyi.common.core.config;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.config.properties.ThreadPoolProperties;
|
||||||
import com.ruoyi.common.core.utils.Threads;
|
import com.ruoyi.common.core.utils.Threads;
|
||||||
import jakarta.annotation.PreDestroy;
|
import jakarta.annotation.PreDestroy;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
@ -17,6 +21,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||||||
**/
|
**/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
|
@EnableConfigurationProperties(ThreadPoolProperties.class)
|
||||||
public class ThreadPoolConfig
|
public class ThreadPoolConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,6 +31,18 @@ public class ThreadPoolConfig
|
|||||||
|
|
||||||
private ScheduledExecutorService scheduledExecutorService;
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|
||||||
|
@Bean(name = "threadPoolTaskExecutor")
|
||||||
|
@ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true")
|
||||||
|
public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(core);
|
||||||
|
executor.setMaxPoolSize(core * 2);
|
||||||
|
executor.setQueueCapacity(threadPoolProperties.getQueueCapacity());
|
||||||
|
executor.setKeepAliveSeconds(threadPoolProperties.getKeepAliveSeconds());
|
||||||
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行周期性或定时任务
|
* 执行周期性或定时任务
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.ruoyi.common.core.config.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程池 配置属性
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "thread-pool")
|
||||||
|
public class ThreadPoolProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启线程池
|
||||||
|
*/
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 队列最大长度
|
||||||
|
*/
|
||||||
|
private int queueCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程池维护线程所允许的空闲时间
|
||||||
|
*/
|
||||||
|
private int keepAliveSeconds;
|
||||||
|
|
||||||
|
}
|
@ -35,11 +35,6 @@ public interface CacheNames {
|
|||||||
*/
|
*/
|
||||||
String SYS_TENANT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_tenant#30d";
|
String SYS_TENANT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_tenant#30d";
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端
|
|
||||||
*/
|
|
||||||
String SYS_CLIENT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_client#30d";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账户
|
* 用户账户
|
||||||
*/
|
*/
|
||||||
@ -58,7 +53,7 @@ public interface CacheNames {
|
|||||||
/**
|
/**
|
||||||
* OSS配置
|
* OSS配置
|
||||||
*/
|
*/
|
||||||
String SYS_OSS_CONFIG = GlobalConstants.GLOBAL_REDIS_KEY + "sys_oss_config";
|
String SYS_OSS_CONFIG = "sys_oss_config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户
|
* 在线用户
|
||||||
|
@ -80,14 +80,68 @@ public class Constants
|
|||||||
public static final String TOKEN = "token";
|
public static final String TOKEN = "token";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顶级部门id
|
* 令牌前缀
|
||||||
*/
|
*/
|
||||||
public static final Long TOP_PARENT_ID = 0L;
|
public static final String TOKEN_PREFIX = "Bearer ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌前缀
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
public static final String JWT_USERID = "userid";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
public static final String JWT_USERNAME = Claims.SUBJECT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
public static final String JWT_AVATAR = "avatar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
public static final String JWT_CREATED = "created";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户权限
|
||||||
|
*/
|
||||||
|
public static final String JWT_AUTHORITIES = "authorities";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
public static final String RESOURCE_PREFIX = "/profile";
|
public static final String RESOURCE_PREFIX = "/profile";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RMI 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_RMI = "rmi:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAP 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAP = "ldap:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAPS 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务违规的字符
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||||
|
"org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" };
|
||||||
}
|
}
|
||||||
|
@ -5,193 +5,113 @@ package com.ruoyi.common.core.constant;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class GenConstants {
|
public class GenConstants
|
||||||
/**
|
{
|
||||||
* 单表(增删改查)
|
/** 单表(增删改查) */
|
||||||
*/
|
|
||||||
public static final String TPL_CRUD = "crud";
|
public static final String TPL_CRUD = "crud";
|
||||||
|
|
||||||
/**
|
/** 树表(增删改查) */
|
||||||
* 树表(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_TREE = "tree";
|
public static final String TPL_TREE = "tree";
|
||||||
|
|
||||||
/**
|
/** 主子表(增删改查) */
|
||||||
* 主子表(增删改查)
|
|
||||||
*/
|
|
||||||
public static final String TPL_SUB = "sub";
|
public static final String TPL_SUB = "sub";
|
||||||
|
|
||||||
/**
|
/** 树编码字段 */
|
||||||
* 树编码字段
|
|
||||||
*/
|
|
||||||
public static final String TREE_CODE = "treeCode";
|
public static final String TREE_CODE = "treeCode";
|
||||||
|
|
||||||
/**
|
/** 树父编码字段 */
|
||||||
* 树父编码字段
|
|
||||||
*/
|
|
||||||
public static final String TREE_PARENT_CODE = "treeParentCode";
|
public static final String TREE_PARENT_CODE = "treeParentCode";
|
||||||
|
|
||||||
/**
|
/** 树名称字段 */
|
||||||
* 树名称字段
|
|
||||||
*/
|
|
||||||
public static final String TREE_NAME = "treeName";
|
public static final String TREE_NAME = "treeName";
|
||||||
|
|
||||||
/**
|
/** 上级菜单ID字段 */
|
||||||
* 上级菜单ID字段
|
|
||||||
*/
|
|
||||||
public static final String PARENT_MENU_ID = "parentMenuId";
|
public static final String PARENT_MENU_ID = "parentMenuId";
|
||||||
|
|
||||||
/**
|
/** 上级菜单名称字段 */
|
||||||
* 上级菜单名称字段
|
|
||||||
*/
|
|
||||||
public static final String PARENT_MENU_NAME = "parentMenuName";
|
public static final String PARENT_MENU_NAME = "parentMenuName";
|
||||||
|
|
||||||
/**
|
/** 数据库字符串类型 */
|
||||||
* 数据库字符串类型
|
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "enum", "set", "nchar", "nvarchar", "varchar2", "nvarchar2", "character", "character varying"};
|
|
||||||
|
|
||||||
/**
|
/** 数据库文本类型 */
|
||||||
* 数据库文本类型
|
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext", "binary", "varbinary", "blob",
|
|
||||||
"ntext", "image", "bytea"};
|
|
||||||
|
|
||||||
/**
|
/** 数据库时间类型 */
|
||||||
* 数据库时间类型
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp", "timestamp without time zone", "year", "interval",
|
|
||||||
"smalldatetime", "datetime2", "datetimeoffset"};
|
|
||||||
|
|
||||||
/**
|
/** 数据库数字类型 */
|
||||||
* 数据库integer类型
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
*/
|
"bit", "bigint", "float", "double", "decimal" };
|
||||||
public static final String[] COLUMNTYPE_INTEGER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", "bit"};
|
|
||||||
|
|
||||||
/**
|
/** 页面不需要编辑字段 */
|
||||||
* 数据库数字类型
|
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||||
*/
|
|
||||||
public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
|
|
||||||
"bit", "bigint", "float", "double", "decimal", "numeric", "real", "double precision",
|
|
||||||
"smallserial", "serial", "bigserial", "money", "smallmoney"};
|
|
||||||
|
|
||||||
/**
|
/** 页面不需要显示的列表字段 */
|
||||||
* BO对象 不需要添加字段
|
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||||
*/
|
"update_time" };
|
||||||
public static final String[] COLUMNNAME_NOT_ADD = {"tenant_id", "version", "del_flag", "create_by", "create_time", "update_by", "update_time"};
|
|
||||||
|
|
||||||
/**
|
/** 页面不需要查询字段 */
|
||||||
* BO对象 不需要编辑字段
|
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||||
*/
|
"update_time", "remark" };
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = {"tenant_id","del_flag", "create_by", "create_time", "update_by", "update_time"};
|
|
||||||
|
|
||||||
/**
|
/** Entity基类字段 */
|
||||||
* VO对象 不需要显示的列表字段
|
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||||
*/
|
|
||||||
public static final String[] COLUMNNAME_NOT_LIST = {"tenant_id", "version", "del_flag", "create_by", "create_time", "update_by", "update_time"};
|
|
||||||
|
|
||||||
/**
|
/** Tree基类字段 */
|
||||||
* BO对象 不需要查询字段
|
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
|
||||||
*/
|
|
||||||
public static final String[] COLUMNNAME_NOT_QUERY = {"tenant_id", "version", "del_flag", "create_by", "create_time", "update_by", "update_time", "remark", "id"};
|
|
||||||
|
|
||||||
/**
|
/** 文本框 */
|
||||||
* Entity基类字段
|
|
||||||
*/
|
|
||||||
public static final String[] BASE_ENTITY = {"tenantId", "version", "createBy", "createTime", "updateBy", "updateTime"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tree基类字段
|
|
||||||
*/
|
|
||||||
public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文本框
|
|
||||||
*/
|
|
||||||
public static final String HTML_INPUT = "input";
|
public static final String HTML_INPUT = "input";
|
||||||
|
|
||||||
/**
|
/** 文本域 */
|
||||||
* 文本域
|
|
||||||
*/
|
|
||||||
public static final String HTML_TEXTAREA = "textarea";
|
public static final String HTML_TEXTAREA = "textarea";
|
||||||
|
|
||||||
/**
|
/** 下拉框 */
|
||||||
* 下拉框
|
|
||||||
*/
|
|
||||||
public static final String HTML_SELECT = "select";
|
public static final String HTML_SELECT = "select";
|
||||||
|
|
||||||
/**
|
/** 单选框 */
|
||||||
* 单选框
|
|
||||||
*/
|
|
||||||
public static final String HTML_RADIO = "radio";
|
public static final String HTML_RADIO = "radio";
|
||||||
|
|
||||||
/**
|
/** 复选框 */
|
||||||
* 复选框
|
|
||||||
*/
|
|
||||||
public static final String HTML_CHECKBOX = "checkbox";
|
public static final String HTML_CHECKBOX = "checkbox";
|
||||||
|
|
||||||
/**
|
/** 日期控件 */
|
||||||
* 日期控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_DATETIME = "datetime";
|
public static final String HTML_DATETIME = "datetime";
|
||||||
|
|
||||||
/**
|
/** 图片上传控件 */
|
||||||
* 图片上传控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
||||||
|
|
||||||
/**
|
/** 文件上传控件 */
|
||||||
* 文件上传控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
||||||
|
|
||||||
/**
|
/** 富文本控件 */
|
||||||
* 富文本控件
|
|
||||||
*/
|
|
||||||
public static final String HTML_EDITOR = "editor";
|
public static final String HTML_EDITOR = "editor";
|
||||||
|
|
||||||
/**
|
/** 字符串类型 */
|
||||||
* 字符串类型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_STRING = "String";
|
public static final String TYPE_STRING = "String";
|
||||||
|
|
||||||
/**
|
/** 整型 */
|
||||||
* 整型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_INTEGER = "Integer";
|
public static final String TYPE_INTEGER = "Integer";
|
||||||
|
|
||||||
/**
|
/** 长整型 */
|
||||||
* 长整型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_LONG = "Long";
|
public static final String TYPE_LONG = "Long";
|
||||||
|
|
||||||
/**
|
/** 浮点型 */
|
||||||
* 浮点型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_DOUBLE = "Double";
|
public static final String TYPE_DOUBLE = "Double";
|
||||||
|
|
||||||
/**
|
/** 高精度计算类型 */
|
||||||
* 高精度计算类型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
||||||
|
|
||||||
/**
|
/** 时间类型 */
|
||||||
* 时间类型
|
|
||||||
*/
|
|
||||||
public static final String TYPE_DATE = "Date";
|
public static final String TYPE_DATE = "Date";
|
||||||
|
|
||||||
/**
|
/** 模糊查询 */
|
||||||
* 模糊查询
|
|
||||||
*/
|
|
||||||
public static final String QUERY_LIKE = "LIKE";
|
public static final String QUERY_LIKE = "LIKE";
|
||||||
|
|
||||||
/**
|
/** 相等查询 */
|
||||||
* 相等查询
|
|
||||||
*/
|
|
||||||
public static final String QUERY_EQ = "EQ";
|
public static final String QUERY_EQ = "EQ";
|
||||||
|
|
||||||
/**
|
/** 需要 */
|
||||||
* 需要
|
|
||||||
*/
|
|
||||||
public static final String REQUIRE = "1";
|
public static final String REQUIRE = "1";
|
||||||
}
|
}
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package com.ruoyi.common.core.constant;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.RegexPool;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 常用正则表达式字符串
|
|
||||||
* <p>
|
|
||||||
* 常用正则表达式集合,更多正则见: https://any86.github.io/any-rule/
|
|
||||||
*
|
|
||||||
* @author Feng
|
|
||||||
*/
|
|
||||||
public interface RegexConstants extends RegexPool {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)
|
|
||||||
*/
|
|
||||||
public static final String DICTIONARY_TYPE = "^[a-z][a-z0-9_]*$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 身份证号码(后6位)
|
|
||||||
*/
|
|
||||||
public static final String ID_CARD_LAST_6 = "^(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* QQ号码
|
|
||||||
*/
|
|
||||||
public static final String QQ_NUMBER = "^[1-9][0-9]\\d{4,9}$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮政编码
|
|
||||||
*/
|
|
||||||
public static final String POSTAL_CODE = "^[1-9]\\d{5}$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册账号
|
|
||||||
*/
|
|
||||||
public static final String ACCOUNT = "^[a-zA-Z][a-zA-Z0-9_]{4,15}$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码:包含至少8个字符,包括大写字母、小写字母、数字和特殊字符
|
|
||||||
*/
|
|
||||||
public static final String PASSWORD = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用状态(0表示正常,1表示停用)
|
|
||||||
*/
|
|
||||||
public static final String STATUS = "^[01]$";
|
|
||||||
|
|
||||||
}
|
|
@ -4,7 +4,6 @@ package com.ruoyi.common.core.constant;
|
|||||||
* 租户常量信息
|
* 租户常量信息
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @author 数据小王子
|
|
||||||
*/
|
*/
|
||||||
public interface TenantConstants {
|
public interface TenantConstants {
|
||||||
|
|
||||||
@ -26,21 +25,21 @@ public interface TenantConstants {
|
|||||||
/**
|
/**
|
||||||
* 超级管理员角色 roleKey
|
* 超级管理员角色 roleKey
|
||||||
*/
|
*/
|
||||||
String SUPER_ADMIN_ROLE_KEY = "SuperAminRole";
|
String SUPER_ADMIN_ROLE_KEY = "superadmin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户管理员角色 roleKey
|
* 租户管理员角色 roleKey
|
||||||
*/
|
*/
|
||||||
String TENANT_ADMIN_ROLE_KEY = "AdminRole";
|
String TENANT_ADMIN_ROLE_KEY = "admin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户管理员角色名称
|
* 租户管理员角色名称
|
||||||
*/
|
*/
|
||||||
String TENANT_ADMIN_ROLE_NAME = "管理员角色";
|
String TENANT_ADMIN_ROLE_NAME = "管理员";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认租户ID
|
* 默认租户ID
|
||||||
*/
|
*/
|
||||||
Long DEFAULT_TENANT_ID = 1L;
|
String DEFAULT_TENANT_ID = "000000";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,11 @@ public class UserConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String POST_DISABLE = "1";
|
public static final String POST_DISABLE = "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典正常状态
|
||||||
|
*/
|
||||||
|
public static final String DICT_NORMAL = "0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为系统默认(是)
|
* 是否为系统默认(是)
|
||||||
*/
|
*/
|
||||||
@ -76,16 +81,6 @@ public class UserConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String NO_FRAME = "1";
|
public static final String NO_FRAME = "1";
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单正常状态
|
|
||||||
*/
|
|
||||||
public static final String MENU_NORMAL = "0";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单停用状态
|
|
||||||
*/
|
|
||||||
public static final String MENU_DISABLE = "1";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单类型(目录)
|
* 菜单类型(目录)
|
||||||
*/
|
*/
|
||||||
|
@ -34,16 +34,6 @@ public class UserOnlineDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端
|
|
||||||
*/
|
|
||||||
private String clientKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备类型
|
|
||||||
*/
|
|
||||||
private String deviceType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录IP地址
|
* 登录IP地址
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +11,13 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EmailLoginBody extends LoginBody {
|
public class EmailLoginBody {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户ID
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "{tenant.number.not.blank}")
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱
|
* 邮箱
|
||||||
|
@ -40,6 +40,7 @@ public class LoginBody
|
|||||||
/**
|
/**
|
||||||
* 租户ID
|
* 租户ID
|
||||||
*/
|
*/
|
||||||
|
//@NotBlank(message = "{tenant.number.not.blank}")
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,16 +111,6 @@ public class LoginUser
|
|||||||
*/
|
*/
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端
|
|
||||||
*/
|
|
||||||
private String clientKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备类型
|
|
||||||
*/
|
|
||||||
private String deviceType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录id
|
* 获取登录id
|
||||||
*/
|
*/
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package com.ruoyi.common.core.core.domain.model;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
|
||||||
|
|
||||||
import static com.ruoyi.common.core.constant.UserConstants.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码登录对象
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class PasswordLoginBody extends LoginBody {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{user.username.not.blank}")
|
|
||||||
@Length(min = USERNAME_MIN_LENGTH, max = USERNAME_MAX_LENGTH, message = "{user.username.length.valid}")
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户密码
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{user.password.not.blank}")
|
|
||||||
@Length(min = PASSWORD_MIN_LENGTH, max = PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.ruoyi.common.core.core.domain.model;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信登录对象
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class SmsLoginBody extends LoginBody {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信code
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{sms.code.not.blank}")
|
|
||||||
private String smsCode;
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.ruoyi.common.core.core.domain.model;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 三方登录对象
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class SocialLoginBody extends LoginBody {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第三方登录平台
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{social.source.not.blank}")
|
|
||||||
private String source;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第三方登录code
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{social.code.not.blank}")
|
|
||||||
private String socialCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第三方登录socialState
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{social.state.not.blank}")
|
|
||||||
private String socialState;
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.ruoyi.common.core.core.domain.model;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 三方登录对象
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class XcxLoginBody extends LoginBody {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序id(多个小程序时使用)
|
|
||||||
*/
|
|
||||||
private String appid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序code
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "{xcx.code.not.blank}")
|
|
||||||
private String xcxCode;
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.ruoyi.common.core.core.domain.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序登录用户身份权限
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class XcxLoginUser extends LoginUser {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* openid
|
|
||||||
*/
|
|
||||||
private String openid;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,98 @@
|
|||||||
|
package com.ruoyi.common.core.core.page;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格分页数据对象
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class TableDataInfo implements Serializable
|
||||||
|
{
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 总记录数 */
|
||||||
|
private long total;
|
||||||
|
|
||||||
|
/** 列表数据 */
|
||||||
|
private List<?> rows;
|
||||||
|
|
||||||
|
/** 消息状态码 */
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
/** 消息内容 */
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格数据对象
|
||||||
|
*/
|
||||||
|
public TableDataInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param list 列表数据
|
||||||
|
* @param total 总记录数
|
||||||
|
*/
|
||||||
|
public TableDataInfo(List<?> list, int total)
|
||||||
|
{
|
||||||
|
this.rows = list;
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TableDataInfo build(List<?> list) {
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(list);
|
||||||
|
rspData.setTotal(list.size());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotal()
|
||||||
|
{
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(long total)
|
||||||
|
{
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<?> getRows()
|
||||||
|
{
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRows(List<?> rows)
|
||||||
|
{
|
||||||
|
this.rows = rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code)
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg()
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg)
|
||||||
|
{
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,6 @@ package com.ruoyi.common.core.core.text;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
@ -978,12 +977,7 @@ public class Convert
|
|||||||
String s = "";
|
String s = "";
|
||||||
for (int i = 0; i < fraction.length; i++)
|
for (int i = 0; i < fraction.length; i++)
|
||||||
{
|
{
|
||||||
// 优化double计算精度丢失问题
|
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||||
BigDecimal nNum = new BigDecimal(n);
|
|
||||||
BigDecimal decimal = new BigDecimal(10);
|
|
||||||
BigDecimal scale = nNum.multiply(decimal).setScale(2, RoundingMode.HALF_EVEN);
|
|
||||||
double d = scale.doubleValue();
|
|
||||||
s += (digit[(int) (Math.floor(d * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
|
||||||
}
|
}
|
||||||
if (s.length() < 1)
|
if (s.length() < 1)
|
||||||
{
|
{
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
package com.ruoyi.common.core.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户状态
|
|
||||||
*
|
|
||||||
* @author LionLi
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum TenantStatus {
|
|
||||||
/**
|
|
||||||
* 正常
|
|
||||||
*/
|
|
||||||
OK("0", "正常"),
|
|
||||||
/**
|
|
||||||
* 停用
|
|
||||||
*/
|
|
||||||
DISABLE("1", "停用"),
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
DELETED("2", "删除");
|
|
||||||
|
|
||||||
private final String code;
|
|
||||||
private final String info;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.common.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 演示模式异常
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class DemoModeException extends RuntimeException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public DemoModeException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.ruoyi.common.core.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局异常
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class GlobalException extends RuntimeException
|
||||||
|
{
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误提示
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误明细,内部调试错误
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String detailMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 空构造方法,避免反序列化问题
|
||||||
|
*/
|
||||||
|
public GlobalException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalException(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetailMessage()
|
||||||
|
{
|
||||||
|
return detailMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalException setDetailMessage(String detailMessage)
|
||||||
|
{
|
||||||
|
this.detailMessage = detailMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalException setMessage(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.ruoyi.common.core.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工具类异常
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class UtilException extends RuntimeException
|
||||||
|
{
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 8247610319171014183L;
|
||||||
|
|
||||||
|
public UtilException(Throwable e)
|
||||||
|
{
|
||||||
|
super(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UtilException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UtilException(String message, Throwable throwable)
|
||||||
|
{
|
||||||
|
super(message, throwable);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,6 @@ public class BlackListException extends UserException
|
|||||||
|
|
||||||
public BlackListException()
|
public BlackListException()
|
||||||
{
|
{
|
||||||
super("login.blocked", (Object)null);
|
super("login.blocked", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ public class CaptchaException extends UserException
|
|||||||
|
|
||||||
public CaptchaException()
|
public CaptchaException()
|
||||||
{
|
{
|
||||||
super("user.jcaptcha.error", (Object)null);
|
super("user.jcaptcha.error", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ public class CaptchaExpireException extends UserException
|
|||||||
|
|
||||||
public CaptchaExpireException()
|
public CaptchaExpireException()
|
||||||
{
|
{
|
||||||
super("user.jcaptcha.expire", (Object)null);
|
super("user.jcaptcha.expire", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ public class UserNotExistsException extends UserException
|
|||||||
|
|
||||||
public UserNotExistsException()
|
public UserNotExistsException()
|
||||||
{
|
{
|
||||||
super("user.not.exists", (Object)null);
|
super("user.not.exists", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.common.core.exception.user;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户密码不正确或不符合规范异常类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class UserPasswordNotMatchException extends UserException
|
||||||
|
{
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public UserPasswordNotMatchException()
|
||||||
|
{
|
||||||
|
super("user.password.not.match", null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.common.core.exception.user;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户错误最大次数异常类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class UserPasswordRetryLimitExceedException extends UserException
|
||||||
|
{
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime)
|
||||||
|
{
|
||||||
|
super("user.password.retry.limit.exceed", new Object[] { retryLimitCount, lockTime });
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +0,0 @@
|
|||||||
package com.ruoyi.common.core.factory;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.PatternPool;
|
|
||||||
import com.ruoyi.common.core.constant.RegexConstants;
|
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则表达式模式池工厂
|
|
||||||
* <p>初始化的时候将正则表达式加入缓存池当中</p>
|
|
||||||
* <p>提高正则表达式的性能,避免重复编译相同的正则表达式</p>
|
|
||||||
*
|
|
||||||
* @author 21001
|
|
||||||
*/
|
|
||||||
public class RegexPatternPoolFactory extends PatternPool {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)
|
|
||||||
*/
|
|
||||||
public static final Pattern DICTIONARY_TYPE = get(RegexConstants.DICTIONARY_TYPE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 身份证号码(后6位)
|
|
||||||
*/
|
|
||||||
public static final Pattern ID_CARD_LAST_6 = get(RegexConstants.ID_CARD_LAST_6);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* QQ号码
|
|
||||||
*/
|
|
||||||
public static final Pattern QQ_NUMBER = get(RegexConstants.QQ_NUMBER);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮政编码
|
|
||||||
*/
|
|
||||||
public static final Pattern POSTAL_CODE = get(RegexConstants.POSTAL_CODE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册账号
|
|
||||||
*/
|
|
||||||
public static final Pattern ACCOUNT = get(RegexConstants.ACCOUNT);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码:包含至少8个字符,包括大写字母、小写字母、数字和特殊字符
|
|
||||||
*/
|
|
||||||
public static final Pattern PASSWORD = get(RegexConstants.PASSWORD);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用状态(0表示正常,1表示停用)
|
|
||||||
*/
|
|
||||||
public static final Pattern STATUS = get(RegexConstants.STATUS);
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.ruoyi.common.core.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用 OSS服务
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
public interface OssService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过ossId查询对应的url
|
|
||||||
*
|
|
||||||
* @param ossIds ossId串逗号分隔
|
|
||||||
* @return url串逗号分隔
|
|
||||||
*/
|
|
||||||
String selectUrlByIds(String ossIds);
|
|
||||||
|
|
||||||
}
|
|
@ -3,9 +3,7 @@ package com.ruoyi.common.core.utils;
|
|||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import org.springframework.aop.framework.AopContext;
|
import org.springframework.aop.framework.AopContext;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.boot.autoconfigure.thread.Threading;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,8 +98,4 @@ public final class SpringUtils extends SpringUtil
|
|||||||
return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
|
return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVirtual() {
|
|
||||||
return Threading.VIRTUAL.isActive(getBean(Environment.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,21 +26,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
{
|
{
|
||||||
public static final String SEPARATOR = ",";
|
public static final String SEPARATOR = ",";
|
||||||
|
|
||||||
public static final String SLASH = "/";
|
|
||||||
|
|
||||||
/** 空字符串 */
|
/** 空字符串 */
|
||||||
private static final String NULLSTR = "";
|
private static final String NULLSTR = "";
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取参数不为空值
|
|
||||||
*
|
|
||||||
* @param str defaultValue 要判断的value
|
|
||||||
* @return value 返回值
|
|
||||||
*/
|
|
||||||
public static String blankToDefault(String str, String defaultValue) {
|
|
||||||
return StrUtil.blankToDefault(str, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取参数不为空值
|
* 获取参数不为空值
|
||||||
*
|
*
|
||||||
@ -396,7 +384,48 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
*/
|
*/
|
||||||
public static String toUnderScoreCase(String str)
|
public static String toUnderScoreCase(String str)
|
||||||
{
|
{
|
||||||
return StrUtil.toUnderlineCase(str);
|
if (str == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
// 前置字符是否大写
|
||||||
|
boolean preCharIsUpperCase = true;
|
||||||
|
// 当前字符是否大写
|
||||||
|
boolean curreCharIsUpperCase = true;
|
||||||
|
// 下一字符是否大写
|
||||||
|
boolean nexteCharIsUpperCase = true;
|
||||||
|
for (int i = 0; i < str.length(); i++)
|
||||||
|
{
|
||||||
|
char c = str.charAt(i);
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
preCharIsUpperCase = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
curreCharIsUpperCase = Character.isUpperCase(c);
|
||||||
|
|
||||||
|
if (i < (str.length() - 1))
|
||||||
|
{
|
||||||
|
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
|
||||||
|
{
|
||||||
|
sb.append(SEPARATOR);
|
||||||
|
}
|
||||||
|
else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
|
||||||
|
{
|
||||||
|
sb.append(SEPARATOR);
|
||||||
|
}
|
||||||
|
sb.append(Character.toLowerCase(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package com.ruoyi.common.core.utils;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
|
||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
||||||
import cn.hutool.core.lang.tree.TreeUtil;
|
|
||||||
import cn.hutool.core.lang.tree.parser.NodeParser;
|
|
||||||
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展 hutool TreeUtil 封装系统树构建
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class TreeBuildUtils extends TreeUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据前端定制差异化字段
|
|
||||||
*/
|
|
||||||
public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label");
|
|
||||||
|
|
||||||
public static <T, K> List<Tree<K>> build(List<T> list, NodeParser<T, K> nodeParser) {
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
K k = ReflectUtils.invokeGetter(list.get(0), "parentId");
|
|
||||||
return TreeUtil.build(list, k, DEFAULT_CONFIG, nodeParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,33 +1,56 @@
|
|||||||
package com.ruoyi.common.core.utils.ip;
|
package com.ruoyi.common.core.utils.ip;
|
||||||
|
|
||||||
import cn.hutool.core.net.NetUtil;
|
|
||||||
import cn.hutool.http.HtmlUtil;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import lombok.AccessLevel;
|
import org.slf4j.Logger;
|
||||||
import lombok.NoArgsConstructor;
|
import org.slf4j.LoggerFactory;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.common.core.config.RuoYiConfig;
|
||||||
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.utils.http.HttpUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取地址类
|
* 获取地址类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class AddressUtils
|
public class AddressUtils
|
||||||
{
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
|
||||||
|
|
||||||
|
// IP地址查询
|
||||||
|
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
|
||||||
|
|
||||||
// 未知地址
|
// 未知地址
|
||||||
public static final String UNKNOWN = "XX XX";
|
public static final String UNKNOWN = "XX XX";
|
||||||
|
|
||||||
public static String getRealAddressByIP(String ip) {
|
public static String getRealAddressByIP(String ip)
|
||||||
if (StringUtils.isBlank(ip)) {
|
{
|
||||||
return UNKNOWN;
|
|
||||||
}
|
|
||||||
// 内网不查询
|
// 内网不查询
|
||||||
ip = StringUtils.contains(ip, "0:0:0:0:0:0:0:1") ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip);
|
if (IpUtils.internalIp(ip))
|
||||||
if (NetUtil.isInnerIP(ip)) {
|
{
|
||||||
return "内网IP";
|
return "内网IP";
|
||||||
}
|
}
|
||||||
return RegionUtils.getCityInfo(ip);
|
if (RuoYiConfig.isAddressEnabled())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
|
||||||
|
if (StringUtils.isEmpty(rspStr))
|
||||||
|
{
|
||||||
|
log.error("获取地理位置异常 {}", ip);
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
JSONObject obj = JSON.parseObject(rspStr);
|
||||||
|
String region = obj.getString("pro");
|
||||||
|
String city = obj.getString("city");
|
||||||
|
return String.format("%s %s", region, city);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("获取地理位置异常 {}", ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,383 @@
|
|||||||
|
package com.ruoyi.common.core.utils.ip;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IP方法
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class IpUtils
|
||||||
|
{
|
||||||
|
public final static String REGX_0_255 = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)";
|
||||||
|
// 匹配 ip
|
||||||
|
public final static String REGX_IP = "((" + REGX_0_255 + "\\.){3}" + REGX_0_255 + ")";
|
||||||
|
public final static String REGX_IP_WILDCARD = "(((\\*\\.){3}\\*)|(" + REGX_0_255 + "(\\.\\*){3})|(" + REGX_0_255 + "\\." + REGX_0_255 + ")(\\.\\*){2}" + "|((" + REGX_0_255 + "\\.){3}\\*))";
|
||||||
|
// 匹配网段
|
||||||
|
public final static String REGX_IP_SEG = "(" + REGX_IP + "\\-" + REGX_IP + ")";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取客户端IP
|
||||||
|
*
|
||||||
|
* @return IP地址
|
||||||
|
*/
|
||||||
|
public static String getIpAddr()
|
||||||
|
{
|
||||||
|
return getIpAddr(ServletUtils.getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取客户端IP
|
||||||
|
*
|
||||||
|
* @param request 请求对象
|
||||||
|
* @return IP地址
|
||||||
|
*/
|
||||||
|
public static String getIpAddr(HttpServletRequest request)
|
||||||
|
{
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("X-Forwarded-For");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("X-Real-IP");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getRemoteAddr();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否为内部IP地址
|
||||||
|
*
|
||||||
|
* @param ip IP地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static boolean internalIp(String ip)
|
||||||
|
{
|
||||||
|
byte[] addr = textToNumericFormatV4(ip);
|
||||||
|
return internalIp(addr) || "127.0.0.1".equals(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否为内部IP地址
|
||||||
|
*
|
||||||
|
* @param addr byte地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
private static boolean internalIp(byte[] addr)
|
||||||
|
{
|
||||||
|
if (StringUtils.isNull(addr) || addr.length < 2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final byte b0 = addr[0];
|
||||||
|
final byte b1 = addr[1];
|
||||||
|
// 10.x.x.x/8
|
||||||
|
final byte SECTION_1 = 0x0A;
|
||||||
|
// 172.16.x.x/12
|
||||||
|
final byte SECTION_2 = (byte) 0xAC;
|
||||||
|
final byte SECTION_3 = (byte) 0x10;
|
||||||
|
final byte SECTION_4 = (byte) 0x1F;
|
||||||
|
// 192.168.x.x/16
|
||||||
|
final byte SECTION_5 = (byte) 0xC0;
|
||||||
|
final byte SECTION_6 = (byte) 0xA8;
|
||||||
|
switch (b0)
|
||||||
|
{
|
||||||
|
case SECTION_1:
|
||||||
|
return true;
|
||||||
|
case SECTION_2:
|
||||||
|
if (b1 >= SECTION_3 && b1 <= SECTION_4)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case SECTION_5:
|
||||||
|
switch (b1)
|
||||||
|
{
|
||||||
|
case SECTION_6:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将IPv4地址转换成字节
|
||||||
|
*
|
||||||
|
* @param text IPv4地址
|
||||||
|
* @return byte 字节
|
||||||
|
*/
|
||||||
|
public static byte[] textToNumericFormatV4(String text)
|
||||||
|
{
|
||||||
|
if (text.length() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] bytes = new byte[4];
|
||||||
|
String[] elements = text.split("\\.", -1);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long l;
|
||||||
|
int i;
|
||||||
|
switch (elements.length)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
l = Long.parseLong(elements[0]);
|
||||||
|
if ((l < 0L) || (l > 4294967295L))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
||||||
|
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
|
||||||
|
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||||
|
bytes[3] = (byte) (int) (l & 0xFF);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
l = Integer.parseInt(elements[0]);
|
||||||
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bytes[0] = (byte) (int) (l & 0xFF);
|
||||||
|
l = Integer.parseInt(elements[1]);
|
||||||
|
if ((l < 0L) || (l > 16777215L))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
||||||
|
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||||
|
bytes[3] = (byte) (int) (l & 0xFF);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
for (i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
l = Integer.parseInt(elements[i]);
|
||||||
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bytes[i] = (byte) (int) (l & 0xFF);
|
||||||
|
}
|
||||||
|
l = Integer.parseInt(elements[2]);
|
||||||
|
if ((l < 0L) || (l > 65535L))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
||||||
|
bytes[3] = (byte) (int) (l & 0xFF);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
l = Integer.parseInt(elements[i]);
|
||||||
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bytes[i] = (byte) (int) (l & 0xFF);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IP地址
|
||||||
|
*
|
||||||
|
* @return 本地IP地址
|
||||||
|
*/
|
||||||
|
public static String getHostIp()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return InetAddress.getLocalHost().getHostAddress();
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return "127.0.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主机名
|
||||||
|
*
|
||||||
|
* @return 本地主机名
|
||||||
|
*/
|
||||||
|
public static String getHostName()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return InetAddress.getLocalHost().getHostName();
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从多级反向代理中获得第一个非unknown IP地址
|
||||||
|
*
|
||||||
|
* @param ip 获得的IP地址
|
||||||
|
* @return 第一个非unknown IP地址
|
||||||
|
*/
|
||||||
|
public static String getMultistageReverseProxyIp(String ip)
|
||||||
|
{
|
||||||
|
// 多级反向代理检测
|
||||||
|
if (ip != null && ip.indexOf(",") > 0)
|
||||||
|
{
|
||||||
|
final String[] ips = ip.trim().split(",");
|
||||||
|
for (String subIp : ips)
|
||||||
|
{
|
||||||
|
if (false == isUnknown(subIp))
|
||||||
|
{
|
||||||
|
ip = subIp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringUtils.substring(ip, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测给定字符串是否为未知,多用于检测HTTP请求相关
|
||||||
|
*
|
||||||
|
* @param checkString 被检测的字符串
|
||||||
|
* @return 是否未知
|
||||||
|
*/
|
||||||
|
public static boolean isUnknown(String checkString)
|
||||||
|
{
|
||||||
|
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为IP
|
||||||
|
*/
|
||||||
|
public static boolean isIP(String ip)
|
||||||
|
{
|
||||||
|
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为IP,或 *为间隔的通配符地址
|
||||||
|
*/
|
||||||
|
public static boolean isIpWildCard(String ip)
|
||||||
|
{
|
||||||
|
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP_WILDCARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测参数是否在ip通配符里
|
||||||
|
*/
|
||||||
|
public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip)
|
||||||
|
{
|
||||||
|
String[] s1 = ipWildCard.split("\\.");
|
||||||
|
String[] s2 = ip.split("\\.");
|
||||||
|
boolean isMatchedSeg = true;
|
||||||
|
for (int i = 0; i < s1.length && !s1[i].equals("*"); i++)
|
||||||
|
{
|
||||||
|
if (!s1[i].equals(s2[i]))
|
||||||
|
{
|
||||||
|
isMatchedSeg = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isMatchedSeg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为特定格式如:“10.10.10.1-10.10.10.99”的ip段字符串
|
||||||
|
*/
|
||||||
|
public static boolean isIPSegment(String ipSeg)
|
||||||
|
{
|
||||||
|
return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断ip是否在指定网段中
|
||||||
|
*/
|
||||||
|
public static boolean ipIsInNetNoCheck(String iparea, String ip)
|
||||||
|
{
|
||||||
|
int idx = iparea.indexOf('-');
|
||||||
|
String[] sips = iparea.substring(0, idx).split("\\.");
|
||||||
|
String[] sipe = iparea.substring(idx + 1).split("\\.");
|
||||||
|
String[] sipt = ip.split("\\.");
|
||||||
|
long ips = 0L, ipe = 0L, ipt = 0L;
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
ips = ips << 8 | Integer.parseInt(sips[i]);
|
||||||
|
ipe = ipe << 8 | Integer.parseInt(sipe[i]);
|
||||||
|
ipt = ipt << 8 | Integer.parseInt(sipt[i]);
|
||||||
|
}
|
||||||
|
if (ips > ipe)
|
||||||
|
{
|
||||||
|
long t = ips;
|
||||||
|
ips = ipe;
|
||||||
|
ipe = t;
|
||||||
|
}
|
||||||
|
return ips <= ipt && ipt <= ipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验ip是否符合过滤串规则
|
||||||
|
*
|
||||||
|
* @param filter 过滤IP列表,支持后缀'*'通配,支持网段如:`10.10.10.1-10.10.10.99`
|
||||||
|
* @param ip 校验IP地址
|
||||||
|
* @return boolean 结果
|
||||||
|
*/
|
||||||
|
public static boolean isMatchedIp(String filter, String ip)
|
||||||
|
{
|
||||||
|
if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(ip))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String[] ips = filter.split(";");
|
||||||
|
for (String iStr : ips)
|
||||||
|
{
|
||||||
|
if (isIP(iStr) && iStr.equals(ip))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -1,67 +0,0 @@
|
|||||||
package com.ruoyi.common.core.utils.ip;
|
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import cn.hutool.core.io.resource.ClassPathResource;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.core.utils.file.FileUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.lionsoul.ip2region.xdb.Searcher;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ip地址定位工具类,离线方式
|
|
||||||
* 参考地址:<a href="https://gitee.com/lionsoul/ip2region/tree/master/binding/java">集成 ip2region 实现离线IP地址定位库</a>
|
|
||||||
*
|
|
||||||
* @author lishuyan
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class RegionUtils {
|
|
||||||
|
|
||||||
private static final Searcher SEARCHER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
String fileName = "/ip2region.xdb";
|
|
||||||
File existFile = FileUtils.file(FileUtil.getTmpDir() + FileUtil.FILE_SEPARATOR + fileName);
|
|
||||||
if (!FileUtils.exist(existFile)) {
|
|
||||||
ClassPathResource fileStream = new ClassPathResource(fileName);
|
|
||||||
if (ObjectUtil.isEmpty(fileStream.getStream())) {
|
|
||||||
throw new ServiceException("RegionUtils初始化失败,原因:IP地址库数据不存在!");
|
|
||||||
}
|
|
||||||
FileUtils.writeFromStream(fileStream.getStream(), existFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
String dbPath = existFile.getPath();
|
|
||||||
|
|
||||||
// 1、从 dbPath 加载整个 xdb 到内存。
|
|
||||||
byte[] cBuff;
|
|
||||||
try {
|
|
||||||
cBuff = Searcher.loadContentFromFile(dbPath);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ServiceException("RegionUtils初始化失败,原因:从ip2region.xdb文件加载内容失败!" + e.getMessage());
|
|
||||||
}
|
|
||||||
// 2、使用上述的 cBuff 创建一个完全基于内存的查询对象。
|
|
||||||
try {
|
|
||||||
SEARCHER = Searcher.newWithBuffer(cBuff);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ServiceException("RegionUtils初始化失败,原因:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据IP地址离线获取城市
|
|
||||||
*/
|
|
||||||
public static String getCityInfo(String ip) {
|
|
||||||
try {
|
|
||||||
ip = ip.trim();
|
|
||||||
// 3、执行查询
|
|
||||||
String region = SEARCHER.search(ip);
|
|
||||||
return region.replace("0|", "").replace("|0", "");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("IP地址离线获取城市异常 {}", ip);
|
|
||||||
return "未知";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -76,6 +76,7 @@ import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ruoyi.common.core.config.RuoYiConfig;
|
import com.ruoyi.common.core.config.RuoYiConfig;
|
||||||
|
import com.ruoyi.common.core.exception.UtilException;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
||||||
import com.ruoyi.common.core.utils.file.FileUtils;
|
import com.ruoyi.common.core.utils.file.FileUtils;
|
||||||
@ -539,7 +540,7 @@ public class ExcelUtil<T> {
|
|||||||
return AjaxResult.success(filename);
|
return AjaxResult.success(filename);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导出Excel异常{}", e.getMessage());
|
log.error("导出Excel异常{}", e.getMessage());
|
||||||
throw new IllegalArgumentException("导出Excel失败,请联系网站管理员!");
|
throw new UtilException("导出Excel失败,请联系网站管理员!");
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(wb);
|
IOUtils.closeQuietly(wb);
|
||||||
IOUtils.closeQuietly(out);
|
IOUtils.closeQuietly(out);
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
package com.ruoyi.common.core.utils.regex;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ReUtil;
|
|
||||||
import com.ruoyi.common.core.constant.RegexConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则相关工具类
|
|
||||||
*
|
|
||||||
* @author Feng
|
|
||||||
*/
|
|
||||||
public final class RegexUtils extends ReUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从输入字符串中提取匹配的部分,如果没有匹配则返回默认值
|
|
||||||
*
|
|
||||||
* @param input 要提取的输入字符串
|
|
||||||
* @param regex 用于匹配的正则表达式,可以使用 {@link RegexConstants} 中定义的常量
|
|
||||||
* @param defaultInput 如果没有匹配时返回的默认值
|
|
||||||
* @return 如果找到匹配的部分,则返回匹配的部分,否则返回默认值
|
|
||||||
*/
|
|
||||||
public static String extractFromString(String input, String regex, String defaultInput) {
|
|
||||||
try {
|
|
||||||
return ReUtil.get(regex, input, 1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return defaultInput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package com.ruoyi.common.core.utils.regex;
|
|
||||||
|
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
|
||||||
import cn.hutool.core.lang.Validator;
|
|
||||||
import com.ruoyi.common.core.factory.RegexPatternPoolFactory;
|
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则字段校验器
|
|
||||||
* 主要验证字段非空、是否为满足指定格式等
|
|
||||||
*
|
|
||||||
* @author Feng
|
|
||||||
*/
|
|
||||||
public class RegexValidator extends Validator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)
|
|
||||||
*/
|
|
||||||
public static final Pattern DICTIONARY_TYPE = RegexPatternPoolFactory.DICTIONARY_TYPE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 身份证号码(后6位)
|
|
||||||
*/
|
|
||||||
public static final Pattern ID_CARD_LAST_6 = RegexPatternPoolFactory.ID_CARD_LAST_6;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* QQ号码
|
|
||||||
*/
|
|
||||||
public static final Pattern QQ_NUMBER = RegexPatternPoolFactory.QQ_NUMBER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮政编码
|
|
||||||
*/
|
|
||||||
public static final Pattern POSTAL_CODE = RegexPatternPoolFactory.POSTAL_CODE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册账号
|
|
||||||
*/
|
|
||||||
public static final Pattern ACCOUNT = RegexPatternPoolFactory.ACCOUNT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码:包含至少8个字符,包括大写字母、小写字母、数字和特殊字符
|
|
||||||
*/
|
|
||||||
public static final Pattern PASSWORD = RegexPatternPoolFactory.PASSWORD;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用状态(0表示正常,1表示停用)
|
|
||||||
*/
|
|
||||||
public static final Pattern STATUS = RegexPatternPoolFactory.STATUS;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入的账号是否匹配预定义的规则
|
|
||||||
*
|
|
||||||
* @param value 要验证的账号
|
|
||||||
* @return 如果账号符合规则,返回 true;否则,返回 false。
|
|
||||||
*/
|
|
||||||
public static boolean isAccount(CharSequence value) {
|
|
||||||
return isMatchRegex(ACCOUNT, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证输入的账号是否符合规则,如果不符合,则抛出 ValidateException 异常
|
|
||||||
*
|
|
||||||
* @param value 要验证的账号
|
|
||||||
* @param errorMsg 验证失败时抛出的异常消息
|
|
||||||
* @param <T> CharSequence 的子类型
|
|
||||||
* @return 如果验证通过,返回输入的账号
|
|
||||||
* @throws ValidateException 如果验证失败
|
|
||||||
*/
|
|
||||||
public static <T extends CharSequence> T validateAccount(T value, String errorMsg) throws ValidateException {
|
|
||||||
if (!isAccount(value)) {
|
|
||||||
throw new ValidateException(errorMsg);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查输入的状态是否匹配预定义的规则
|
|
||||||
*
|
|
||||||
* @param value 要验证的状态
|
|
||||||
* @return 如果状态符合规则,返回 true;否则,返回 false。
|
|
||||||
*/
|
|
||||||
public static boolean isStatus(CharSequence value) {
|
|
||||||
return isMatchRegex(STATUS, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证输入的状态是否符合规则,如果不符合,则抛出 ValidateException 异常
|
|
||||||
*
|
|
||||||
* @param value 要验证的状态
|
|
||||||
* @param errorMsg 验证失败时抛出的异常消息
|
|
||||||
* @param <T> CharSequence 的子类型
|
|
||||||
* @return 如果验证通过,返回输入的状态
|
|
||||||
* @throws ValidateException 如果验证失败
|
|
||||||
*/
|
|
||||||
public static <T extends CharSequence> T validateStatus(T value, String errorMsg) throws ValidateException {
|
|
||||||
if (!isStatus(value)) {
|
|
||||||
throw new ValidateException(errorMsg);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.common.core.utils.sql;
|
package com.ruoyi.common.core.utils.sql;
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.exception.UtilException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sql操作工具类
|
* sql操作工具类
|
||||||
@ -31,11 +32,11 @@ public class SqlUtil
|
|||||||
{
|
{
|
||||||
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
|
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("参数不符合规范,不能进行查询");
|
throw new UtilException("参数不符合规范,不能进行查询");
|
||||||
}
|
}
|
||||||
if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH)
|
if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("参数已超过最大限制,不能进行查询");
|
throw new UtilException("参数已超过最大限制,不能进行查询");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ public class SqlUtil
|
|||||||
{
|
{
|
||||||
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
|
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("参数存在SQL注入风险");
|
throw new UtilException("参数存在SQL注入风险");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import com.ruoyi.common.core.exception.UtilException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供通用唯一识别码(universally unique identifier)(UUID)实现
|
* 提供通用唯一识别码(universally unique identifier)(UUID)实现
|
||||||
@ -466,7 +467,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException e)
|
catch (NoSuchAlgorithmException e)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(e);
|
throw new UtilException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.ruoyi.common.core.xss;
|
package com.ruoyi.common.core.xss;
|
||||||
|
|
||||||
import cn.hutool.core.util.ReUtil;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import cn.hutool.http.HtmlUtil;
|
|
||||||
import jakarta.validation.ConstraintValidator;
|
import jakarta.validation.ConstraintValidator;
|
||||||
import jakarta.validation.ConstraintValidatorContext;
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义xss校验注解实现
|
* 自定义xss校验注解实现
|
||||||
@ -12,9 +13,22 @@ import jakarta.validation.ConstraintValidatorContext;
|
|||||||
*/
|
*/
|
||||||
public class XssValidator implements ConstraintValidator<Xss, String>
|
public class XssValidator implements ConstraintValidator<Xss, String>
|
||||||
{
|
{
|
||||||
|
private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
|
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
|
||||||
{
|
{
|
||||||
return !ReUtil.contains(HtmlUtil.RE_HTML_MARK, value);
|
if (StringUtils.isBlank(value))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return !containsHtml(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean containsHtml(String value)
|
||||||
|
{
|
||||||
|
Pattern pattern = Pattern.compile(HTML_PATTERN);
|
||||||
|
Matcher matcher = pattern.matcher(value);
|
||||||
|
return matcher.matches();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,46 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>ruoyi-common-encrypt</artifactId>
|
|
||||||
|
|
||||||
<description>
|
|
||||||
ruoyi-common-encrypt 数据加解密模块
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk18on</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-crypto</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-orm</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,20 +0,0 @@
|
|||||||
package com.ruoyi.common.encrypt.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 强制加密注解
|
|
||||||
*
|
|
||||||
* @author Michelle.Chung
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Target({ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface ApiEncrypt {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应加密忽略,默认不加密,为 true 时加密
|
|
||||||
*/
|
|
||||||
boolean response() default false;
|
|
||||||
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package com.ruoyi.common.encrypt.annotation;
|
|
||||||
|
|
||||||
import com.ruoyi.common.encrypt.enumd.AlgorithmType;
|
|
||||||
import com.ruoyi.common.encrypt.enumd.EncodeType;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段加密注解
|
|
||||||
*
|
|
||||||
* @author 老马
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Inherited
|
|
||||||
@Target({ElementType.FIELD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface EncryptField {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密算法
|
|
||||||
*/
|
|
||||||
AlgorithmType algorithm() default AlgorithmType.DEFAULT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 秘钥。AES、SM4需要
|
|
||||||
*/
|
|
||||||
String password() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公钥。RSA、SM2需要
|
|
||||||
*/
|
|
||||||
String publicKey() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私钥。RSA、SM2需要
|
|
||||||
*/
|
|
||||||
String privateKey() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编码方式。对加密算法为BASE64的不起作用
|
|
||||||
*/
|
|
||||||
EncodeType encode() default EncodeType.DEFAULT;
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.ruoyi.common.encrypt.config;
|
|
||||||
|
|
||||||
import com.ruoyi.common.encrypt.filter.CryptoFilter;
|
|
||||||
import jakarta.servlet.DispatcherType;
|
|
||||||
import com.ruoyi.common.encrypt.properties.ApiDecryptProperties;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* api 解密自动配置
|
|
||||||
*
|
|
||||||
* @author wdhcr
|
|
||||||
*/
|
|
||||||
@AutoConfiguration
|
|
||||||
@EnableConfigurationProperties(ApiDecryptProperties.class)
|
|
||||||
@ConditionalOnProperty(value = "api-decrypt.enabled", havingValue = "true")
|
|
||||||
public class ApiDecryptAutoConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean<CryptoFilter> cryptoFilterRegistration(ApiDecryptProperties properties) {
|
|
||||||
FilterRegistrationBean<CryptoFilter> registration = new FilterRegistrationBean<>();
|
|
||||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
|
||||||
registration.setFilter(new CryptoFilter(properties));
|
|
||||||
registration.addUrlPatterns("/*");
|
|
||||||
registration.setName("cryptoFilter");
|
|
||||||
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
|
||||||
return registration;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package com.ruoyi.common.encrypt.config;
|
|
||||||
|
|
||||||
import com.ruoyi.common.encrypt.core.EncryptorManager;
|
|
||||||
import com.ruoyi.common.encrypt.interceptor.MybatisDecryptInterceptor;
|
|
||||||
import com.ruoyi.common.encrypt.interceptor.MybatisEncryptInterceptor;
|
|
||||||
import com.ruoyi.common.encrypt.properties.EncryptorProperties;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加解密配置
|
|
||||||
*
|
|
||||||
* @author 老马
|
|
||||||
* @version 4.6.0
|
|
||||||
*/
|
|
||||||
@AutoConfiguration
|
|
||||||
@EnableConfigurationProperties(EncryptorProperties.class)
|
|
||||||
@ConditionalOnProperty(value = "mybatis-encryptor.enable", havingValue = "true")
|
|
||||||
public class EncryptorAutoConfiguration {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EncryptorProperties properties;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public EncryptorManager encryptorManager() {
|
|
||||||
return new EncryptorManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MybatisEncryptInterceptor mybatisEncryptInterceptor(EncryptorManager encryptorManager) {
|
|
||||||
return new MybatisEncryptInterceptor(encryptorManager, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MybatisDecryptInterceptor mybatisDecryptInterceptor(EncryptorManager encryptorManager) {
|
|
||||||
return new MybatisDecryptInterceptor(encryptorManager, properties);
|
|
||||||
}
|
|
||||||
}
|
|