Compare commits
No commits in common. "master" and "v3.2.1" have entirely different histories.
|
|
@ -1 +0,0 @@
|
||||||
custom: http://doc.ruoyi.vip/ruoyi-vue/other/donate.html
|
|
||||||
|
|
@ -25,9 +25,6 @@ target/
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
### JRebel ###
|
|
||||||
rebel.xml
|
|
||||||
|
|
||||||
### NetBeans ###
|
### NetBeans ###
|
||||||
nbproject/private/
|
nbproject/private/
|
||||||
build/*
|
build/*
|
||||||
|
|
|
||||||
43
README.md
43
README.md
|
|
@ -1,26 +1,15 @@
|
||||||
<p align="center">
|
|
||||||
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
|
|
||||||
</p>
|
|
||||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.9.1</h1>
|
|
||||||
<h4 align="center">基于SpringBoot+Vue前后端分离的Java快速开发框架</h4>
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Vue/stargazers"><img src="https://gitee.com/y_project/RuoYi-Vue/badge/star.svg?theme=dark"></a>
|
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Vue"><img src="https://img.shields.io/badge/RuoYi-v3.9.1-brightgreen.svg"></a>
|
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Vue/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## 平台简介
|
## 平台简介
|
||||||
|
|
||||||
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
|
||||||
|
|
||||||
* 前端采用Vue、Element UI。
|
* 前端采用Vue、Element UI。
|
||||||
* 后端采用Spring Boot、Spring Security、Redis & Jwt。
|
* 后端采用Spring Boot、Spring Security、Redis & Jwt。
|
||||||
* 权限认证使用Jwt,支持多终端认证系统。
|
* 权限认证使用Jwt,支持多终端认证系统。
|
||||||
* 支持加载动态权限菜单,多方式轻松权限控制。
|
* 支持加载动态权限菜单,多方式轻松权限控制。
|
||||||
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
||||||
* 提供了技术栈(Vue3 Element Plus Vite)的 [RuoYi-Vue3](https://gitcode.com/yangzongzhuan/RuoYi-Vue3)版本,以及技术栈(TypeScript)的 [RuoYi-Vue3-TypeScript](https://gitcode.com/yangzongzhuan/RuoYi-Vue3/tree/typescript)版本,两者保持同步更新。
|
* 提供了一个Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
|
||||||
* 提供了适配 Spring Boot 3 的版本分支 [RuoYi-Vue (springboot3)](https://gitee.com/y_project/RuoYi-Vue/tree/springboot3),以及特定需求的 单应用版本 [RuoYi-Vue-fast](https://gitcode.com/yangzongzhuan/RuoYi-Vue-fast) 与 Oracle数据库版本 [RuoYi-Vue-Oracle](https://gitcode.com/yangzongzhuan/RuoYi-Vue-Oracle),均保持同步更新。
|
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
||||||
|
* 感谢[Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://gitee.com/elunez/eladmin-web?_from=gitee_search)。
|
||||||
* 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)
|
* 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)
|
||||||
|
* 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)
|
||||||
|
|
||||||
## 内置功能
|
## 内置功能
|
||||||
|
|
||||||
|
|
@ -39,24 +28,8 @@
|
||||||
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
||||||
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
||||||
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
||||||
16. 缓存监控:对系统的缓存信息查询,命令统计等。
|
16. 在线构建器:拖动表单元素生成相应的HTML代码。
|
||||||
17. 在线构建器:拖动表单元素生成相应的HTML代码。
|
17. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
||||||
18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
|
||||||
|
|
||||||
# 版本对比
|
|
||||||
|
|
||||||
RuoYi-Vue 前端项目的三个主要演进版本,方便你直观对比其技术栈差异(并行开发维护)。
|
|
||||||
|
|
||||||
| 项目名称 | **RuoYi-Vue** | **RuoYi-Vue3** | **RuoYi-Vue3-TypeScript** |
|
|
||||||
| :--- | :--- | :--- | :--- |
|
|
||||||
| **前端框架** | Vue 2 | Vue 3 | Vue 3 |
|
|
||||||
| **脚本语言** | JavaScript | JavaScript | TypeScript |
|
|
||||||
| **构建工具** | Vue CLI | Vite | Vite |
|
|
||||||
| **UI 组件库** | Element UI | Element Plus | Element Plus |
|
|
||||||
| **状态管理** | Vuex | Pinia | Pinia |
|
|
||||||
| **路由管理** | Vue Router 3 | Vue Router 4 | Vue Router 4 |
|
|
||||||
| **核心特点** | 1. 技术栈经典稳定<br>2. 社区资料丰富<br>3. 当前维护重心已转移 | 1. 现代前端技术栈<br>2. 开发体验与性能更优<br>3. 官方主推的活跃版本 | 1. 类型加持,减少沟通成本<br>2. 开发时有提示,效率更高<br>3. 多人协作企业级开发项目 |
|
|
||||||
| **仓库地址** | [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue) | [RuoYi-Vue3](https://gitcode.com/yangzongzhuan/RuoYi-Vue3) | [RuoYi-Vue3-TypeScript](https://gitcode.com/yangzongzhuan/RuoYi-Vue3/tree/typescript) |
|
|
||||||
|
|
||||||
## 在线体验
|
## 在线体验
|
||||||
|
|
||||||
|
|
@ -99,11 +72,11 @@ RuoYi-Vue 前端项目的三个主要演进版本,方便你直观对比其技
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
||||||
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-6d73c2140ce694e3de4c05035fdc1868d4c.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
## 若依前后端分离交流群
|
## 若依前后端分离交流群
|
||||||
|
|
||||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) [](https://jq.qq.com/?_wv=1027&k=96Dkdq0k) [](https://jq.qq.com/?_wv=1027&k=0fsNiYZt) [](https://jq.qq.com/?_wv=1027&k=7xw4xUG1) [](https://jq.qq.com/?_wv=1027&k=eCx8eyoJ) [](https://jq.qq.com/?_wv=1027&k=SpyH2875) [](https://jq.qq.com/?_wv=1027&k=tKEt51dz) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0vBbSb0ztbBgVtn3kJS-Q4HUNYwip89G&authKey=8irq5PhutrZmWIvsUsklBxhj57l%2F1nOZqjzigkXZVoZE451GG4JHPOqW7AW6cf0T&noverify=0&group_code=143961921) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ZFAPAbp09S2ltvwrJzp7wGlbopsc0rwi&authKey=HB2cxpxP2yspk%2Bo3WKTBfktRCccVkU26cgi5B16u0KcAYrVu7sBaE7XSEqmMdFQp&noverify=0&group_code=174951577) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=Fn2aF5IHpwsy8j6VlalNJK6qbwFLFHat&authKey=uyIT%2B97x2AXj3odyXpsSpVaPMC%2Bidw0LxG5MAtEqlrcBcWJUA%2FeS43rsF1Tg7IRJ&noverify=0&group_code=161281055) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=XIzkm_mV2xTsUtFxo63bmicYoDBA6Ifm&authKey=dDW%2F4qsmw3x9govoZY9w%2FoWAoC4wbHqGal%2BbqLzoS6VBarU8EBptIgPKN%2FviyC8j&noverify=0&group_code=138988063) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=DkugnCg68PevlycJSKSwjhFqfIgrWWwR&authKey=pR1Pa5lPIeGF%2FFtIk6d%2FGB5qFi0EdvyErtpQXULzo03zbhopBHLWcuqdpwY241R%2F&noverify=0&group_code=151450850) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=F58bgRa-Dp-rsQJThiJqIYv8t4-lWfXh&authKey=UmUs4CVG5OPA1whvsa4uSespOvyd8%2FAr9olEGaWAfdLmfKQk%2FVBp2YU3u2xXXt76&noverify=0&group_code=224622315) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=Nxb2EQ5qozWa218Wbs7zgBnjLSNk_tVT&authKey=obBKXj6SBKgrFTJZx0AqQnIYbNOvBB2kmgwWvGhzxR67RoRr84%2Bus5OadzMcdJl5&noverify=0&group_code=287842588) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=numtK1M_I4eVd2Gvg8qtbuL8JgX42qNh&authKey=giV9XWMaFZTY%2FqPlmWbkB9g3fi0Ev5CwEtT9Tgei0oUlFFCQLDp4ozWRiVIzubIm&noverify=0&group_code=187944233) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=G6r5KGCaa3pqdbUSXNIgYloyb8e0_L0D&authKey=4w8tF1eGW7%2FedWn%2FHAypQksdrML%2BDHolQSx7094Agm7Luakj9EbfPnSTxSi2T1LQ&noverify=0&group_code=228578329) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=GsOo-OLz53J8y_9TPoO6XXSGNRTgbFxA&authKey=R7Uy%2Feq%2BZsoKNqHvRKhiXpypW7DAogoWapOawUGHokJSBIBIre2%2FoiAZeZBSLuBc&noverify=0&group_code=191164766) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=PmYavuzsOthVqfdAPbo4uAeIbu7Ttjgc&authKey=p52l8%2FXa4PS1JcEmS3VccKSwOPJUZ1ZfQ69MEKzbrooNUljRtlKjvsXf04bxNp3G&noverify=0&group_code=174569686) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=M9y5NjAl44lAL_Vh2crmEehZU_PMU6KS&authKey=ZSDz8hEREWSaPuxQV3gEwqGIaGjfRNnkB4rJjf0IvXhrSUGSGwQFmBA%2Boe8HFxyl&noverify=0&group_code=127358632) 点击按钮入群。
|
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) 点击按钮入群。
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
@echo off
|
@echo off
|
||||||
echo.
|
echo.
|
||||||
echo [信息] 清理工程target生成路径。
|
echo [信息] 清理生成路径。
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
%~d0
|
%~d0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
@echo off
|
@echo off
|
||||||
echo.
|
echo.
|
||||||
echo [信息] 使用Jar命令运行Web工程。
|
echo [信息] 运行Web工程。
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
cd %~dp0
|
cd %~dp0
|
||||||
|
|
|
||||||
Binary file not shown.
185
pom.xml
185
pom.xml
|
|
@ -6,121 +6,67 @@
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.9.1</version>
|
<version>3.2.1</version>
|
||||||
|
|
||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依管理系统</description>
|
<description>若依管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.9.1</ruoyi.version>
|
<ruoyi.version>3.2.1</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
<spring-boot.version>2.5.15</spring-boot.version>
|
<druid.version>1.2.2</druid.version>
|
||||||
<druid.version>1.2.27</druid.version>
|
<bitwalker.version>1.19</bitwalker.version>
|
||||||
<yauaa.version>7.32.0</yauaa.version>
|
<swagger.version>2.9.2</swagger.version>
|
||||||
<swagger.version>3.0.0</swagger.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<kaptcha.version>2.3.3</kaptcha.version>
|
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
||||||
<pagehelper.boot.version>1.4.7</pagehelper.boot.version>
|
<fastjson.version>1.2.74</fastjson.version>
|
||||||
<fastjson.version>2.0.60</fastjson.version>
|
<oshi.version>5.2.5</oshi.version>
|
||||||
<oshi.version>6.9.1</oshi.version>
|
<jna.version>5.5.0</jna.version>
|
||||||
<commons.io.version>2.21.0</commons.io.version>
|
<commons.io.version>2.5</commons.io.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<poi.version>3.17</poi.version>
|
||||||
|
<velocity.version>1.7</velocity.version>
|
||||||
<jwt.version>0.9.1</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
<!-- override dependency version -->
|
|
||||||
<tomcat.version>9.0.112</tomcat.version>
|
|
||||||
<logback.version>1.2.13</logback.version>
|
|
||||||
<spring-security.version>5.7.14</spring-security.version>
|
|
||||||
<spring-framework.version>5.3.39</spring-framework.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- 覆盖SpringFramework的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-framework-bom</artifactId>
|
|
||||||
<version>${spring-framework.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 覆盖SpringSecurity的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-bom</artifactId>
|
|
||||||
<version>${spring-security.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringBoot的依赖配置-->
|
<!-- SpringBoot的依赖配置-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>2.1.17.RELEASE</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 覆盖logback的依赖配置-->
|
<!--阿里数据库连接池 -->
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-core</artifactId>
|
|
||||||
<version>${logback.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>${logback.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 覆盖tomcat的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-core</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-el</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-websocket</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 阿里数据库连接池 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
<version>${druid.version}</version>
|
<version>${druid.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 解析客户端操作系统、浏览器等 -->
|
<!-- 解析客户端操作系统、浏览器等 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.basjes.parse.useragent</groupId>
|
<groupId>eu.bitwalker</groupId>
|
||||||
<artifactId>yauaa</artifactId>
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
<version>${yauaa.version}</version>
|
<version>${bitwalker.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- pagehelper 分页插件 -->
|
<!-- pagehelper 分页插件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
<version>${pagehelper.boot.version}</version>
|
<version>${pagehelper.boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 获取系统信息 -->
|
<!-- 获取系统信息 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.oshi</groupId>
|
<groupId>com.github.oshi</groupId>
|
||||||
|
|
@ -128,89 +74,119 @@
|
||||||
<version>${oshi.version}</version>
|
<version>${oshi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger3依赖 -->
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<version>${jna.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna-platform</artifactId>
|
||||||
|
<version>${jna.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- swagger2-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-boot-starter</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-models</artifactId>
|
<artifactId>swagger-models</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- io常用工具类 -->
|
<!-- swagger2-UI-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--io常用工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons.io.version}</version>
|
<version>${commons.io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--文件上传工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>${commons.fileupload.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<!-- excel工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- velocity代码生成使用模板 -->
|
<!--velocity代码生成使用模板 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity</artifactId>
|
||||||
<version>${velocity.version}</version>
|
<version>${velocity.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 阿里JSON解析器 -->
|
<!-- 阿里JSON解析器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson2</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Token生成与解析-->
|
<!--Token生成与解析-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt</artifactId>
|
||||||
<version>${jwt.version}</version>
|
<version>${jwt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 验证码 -->
|
<!--验证码 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pro.fessional</groupId>
|
<groupId>com.github.penggle</groupId>
|
||||||
<artifactId>kaptcha</artifactId>
|
<artifactId>kaptcha</artifactId>
|
||||||
<version>${kaptcha.version}</version>
|
<version>${kaptcha.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务-->
|
<!-- 定时任务-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
<artifactId>ruoyi-quartz</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 代码生成-->
|
<!-- 代码生成-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-framework</artifactId>
|
<artifactId>ruoyi-framework</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 系统模块-->
|
<!-- 系统模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-system</artifactId>
|
<artifactId>ruoyi-system</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 通用工具-->
|
<!-- 通用工具-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
|
|
@ -231,6 +207,11 @@
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
@ -250,7 +231,7 @@
|
||||||
<repository>
|
<repository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
<name>aliyun nexus</name>
|
<name>aliyun nexus</name>
|
||||||
<url>https://maven.aliyun.com/repository/public</url>
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
|
|
@ -261,7 +242,7 @@
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
<name>aliyun nexus</name>
|
<name>aliyun nexus</name>
|
||||||
<url>https://maven.aliyun.com/repository/public</url>
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.9.1</version>
|
<version>3.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
@ -24,17 +24,29 @@
|
||||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger3-->
|
<!-- swagger2-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-boot-starter</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.5.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-models</artifactId>
|
<artifactId>swagger-models</artifactId>
|
||||||
<version>1.6.2</version>
|
<version>1.5.21</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- swagger2-UI-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
<!-- Mysql驱动包 -->
|
||||||
|
|
@ -68,7 +80,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.15</version>
|
<version>2.1.1.RELEASE</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,16 @@ import javax.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.util.FastByteArrayOutputStream;
|
import org.springframework.util.FastByteArrayOutputStream;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.google.code.kaptcha.Producer;
|
import com.google.code.kaptcha.Producer;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.utils.sign.Base64;
|
import com.ruoyi.common.utils.sign.Base64;
|
||||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码操作处理
|
* 验证码操作处理
|
||||||
|
|
@ -37,31 +35,24 @@ public class CaptchaController
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@Autowired
|
// 验证码类型
|
||||||
private ISysConfigService configService;
|
@Value("${ruoyi.captchaType}")
|
||||||
|
private String captchaType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@GetMapping("/captchaImage")
|
@GetMapping("/captchaImage")
|
||||||
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
||||||
{
|
{
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
|
||||||
ajax.put("captchaEnabled", captchaEnabled);
|
|
||||||
if (!captchaEnabled)
|
|
||||||
{
|
|
||||||
return ajax;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtils.simpleUUID();
|
String uuid = IdUtils.simpleUUID();
|
||||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
|
|
||||||
String capStr = null, code = null;
|
String capStr = null, code = null;
|
||||||
BufferedImage image = null;
|
BufferedImage image = null;
|
||||||
|
|
||||||
// 生成验证码
|
// 生成验证码
|
||||||
String captchaType = RuoYiConfig.getCaptchaType();
|
|
||||||
if ("math".equals(captchaType))
|
if ("math".equals(captchaType))
|
||||||
{
|
{
|
||||||
String capText = captchaProducerMath.createText();
|
String capText = captchaProducerMath.createText();
|
||||||
|
|
@ -87,6 +78,7 @@ public class CaptchaController
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid", uuid);
|
||||||
ajax.put("img", Base64.encode(os.toByteArray()));
|
ajax.put("img", Base64.encode(os.toByteArray()));
|
||||||
return ajax;
|
return ajax;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.ruoyi.web.controller.common;
|
package com.ruoyi.web.controller.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -10,10 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
|
|
@ -26,7 +24,6 @@ import com.ruoyi.framework.config.ServerConfig;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/common")
|
|
||||||
public class CommonController
|
public class CommonController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
|
|
@ -34,15 +31,13 @@ public class CommonController
|
||||||
@Autowired
|
@Autowired
|
||||||
private ServerConfig serverConfig;
|
private ServerConfig serverConfig;
|
||||||
|
|
||||||
private static final String FILE_DELIMITER = ",";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用下载请求
|
* 通用下载请求
|
||||||
*
|
*
|
||||||
* @param fileName 文件名称
|
* @param fileName 文件名称
|
||||||
* @param delete 是否删除
|
* @param delete 是否删除
|
||||||
*/
|
*/
|
||||||
@GetMapping("/download")
|
@GetMapping("common/download")
|
||||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -69,9 +64,9 @@ public class CommonController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用上传请求(单个)
|
* 通用上传请求
|
||||||
*/
|
*/
|
||||||
@PostMapping("/upload")
|
@PostMapping("/common/upload")
|
||||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -82,47 +77,8 @@ public class CommonController
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
String url = serverConfig.getUrl() + fileName;
|
String url = serverConfig.getUrl() + fileName;
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("url", url);
|
|
||||||
ajax.put("fileName", fileName);
|
ajax.put("fileName", fileName);
|
||||||
ajax.put("newFileName", FileUtils.getName(fileName));
|
ajax.put("url", url);
|
||||||
ajax.put("originalFilename", file.getOriginalFilename());
|
|
||||||
return ajax;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return AjaxResult.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用上传请求(多个)
|
|
||||||
*/
|
|
||||||
@PostMapping("/uploads")
|
|
||||||
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 上传文件路径
|
|
||||||
String filePath = RuoYiConfig.getUploadPath();
|
|
||||||
List<String> urls = new ArrayList<String>();
|
|
||||||
List<String> fileNames = new ArrayList<String>();
|
|
||||||
List<String> newFileNames = new ArrayList<String>();
|
|
||||||
List<String> originalFilenames = new ArrayList<String>();
|
|
||||||
for (MultipartFile file : files)
|
|
||||||
{
|
|
||||||
// 上传并返回新文件名称
|
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
|
||||||
String url = serverConfig.getUrl() + fileName;
|
|
||||||
urls.add(url);
|
|
||||||
fileNames.add(fileName);
|
|
||||||
newFileNames.add(FileUtils.getName(fileName));
|
|
||||||
originalFilenames.add(file.getOriginalFilename());
|
|
||||||
}
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
ajax.put("urls", StringUtils.join(urls, FILE_DELIMITER));
|
|
||||||
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMITER));
|
|
||||||
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMITER));
|
|
||||||
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMITER));
|
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -134,7 +90,7 @@ public class CommonController
|
||||||
/**
|
/**
|
||||||
* 本地资源通用下载
|
* 本地资源通用下载
|
||||||
*/
|
*/
|
||||||
@GetMapping("/download/resource")
|
@GetMapping("/common/download/resource")
|
||||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
@ -147,7 +103,7 @@ public class CommonController
|
||||||
// 本地资源路径
|
// 本地资源路径
|
||||||
String localPath = RuoYiConfig.getProfile();
|
String localPath = RuoYiConfig.getProfile();
|
||||||
// 数据库资源地址
|
// 数据库资源地址
|
||||||
String downloadPath = localPath + FileUtils.stripPrefix(resource);
|
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||||
// 下载名称
|
// 下载名称
|
||||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
|
|
||||||
|
|
@ -1,121 +0,0 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.RedisCallback;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.system.domain.SysCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 缓存监控
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/monitor/cache")
|
|
||||||
public class CacheController
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private RedisTemplate<String, String> redisTemplate;
|
|
||||||
|
|
||||||
private final static List<SysCache> caches = new ArrayList<SysCache>();
|
|
||||||
{
|
|
||||||
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
|
|
||||||
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
|
|
||||||
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
|
|
||||||
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
|
||||||
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
|
|
||||||
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
|
|
||||||
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@GetMapping()
|
|
||||||
public AjaxResult getInfo() throws Exception
|
|
||||||
{
|
|
||||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
|
||||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
|
||||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>(3);
|
|
||||||
result.put("info", info);
|
|
||||||
result.put("dbSize", dbSize);
|
|
||||||
|
|
||||||
List<Map<String, String>> pieList = new ArrayList<>();
|
|
||||||
commandStats.stringPropertyNames().forEach(key -> {
|
|
||||||
Map<String, String> data = new HashMap<>(2);
|
|
||||||
String property = commandStats.getProperty(key);
|
|
||||||
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
|
||||||
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
|
||||||
pieList.add(data);
|
|
||||||
});
|
|
||||||
result.put("commandStats", pieList);
|
|
||||||
return AjaxResult.success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@GetMapping("/getNames")
|
|
||||||
public AjaxResult cache()
|
|
||||||
{
|
|
||||||
return AjaxResult.success(caches);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@GetMapping("/getKeys/{cacheName}")
|
|
||||||
public AjaxResult getCacheKeys(@PathVariable String cacheName)
|
|
||||||
{
|
|
||||||
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
|
||||||
return AjaxResult.success(new TreeSet<>(cacheKeys));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
|
||||||
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
|
|
||||||
{
|
|
||||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
|
||||||
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
|
||||||
return AjaxResult.success(sysCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
|
||||||
public AjaxResult clearCacheName(@PathVariable String cacheName)
|
|
||||||
{
|
|
||||||
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
|
||||||
redisTemplate.delete(cacheKeys);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
|
||||||
public AjaxResult clearCacheKey(@PathVariable String cacheKey)
|
|
||||||
{
|
|
||||||
redisTemplate.delete(cacheKey);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
|
||||||
@DeleteMapping("/clearCacheAll")
|
|
||||||
public AjaxResult clearCacheAll()
|
|
||||||
{
|
|
||||||
Collection<String> cacheKeys = redisTemplate.keys("*");
|
|
||||||
redisTemplate.delete(cacheKeys);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,6 +4,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.framework.web.domain.Server;
|
import com.ruoyi.framework.web.domain.Server;
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ import com.ruoyi.framework.web.domain.Server;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/server")
|
@RequestMapping("/monitor/server")
|
||||||
public class ServerController
|
public class ServerController extends BaseController
|
||||||
{
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
|
@ -16,7 +14,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.web.service.SysPasswordService;
|
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
|
|
||||||
|
|
@ -32,9 +29,6 @@ public class SysLogininforController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysLogininforService logininforService;
|
private ISysLogininforService logininforService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPasswordService passwordService;
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysLogininfor logininfor)
|
public TableDataInfo list(SysLogininfor logininfor)
|
||||||
|
|
@ -46,12 +40,12 @@ public class SysLogininforController extends BaseController
|
||||||
|
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysLogininfor logininfor)
|
public AjaxResult export(SysLogininfor logininfor)
|
||||||
{
|
{
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||||
util.exportExcel(response, list, "登录日志");
|
return util.exportExcel(list, "登录日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
|
|
@ -68,15 +62,6 @@ public class SysLogininforController extends BaseController
|
||||||
public AjaxResult clean()
|
public AjaxResult clean()
|
||||||
{
|
{
|
||||||
logininforService.cleanLogininfor();
|
logininforService.cleanLogininfor();
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
|
|
||||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
|
||||||
@GetMapping("/unlock/{userName}")
|
|
||||||
public AjaxResult unlock(@PathVariable("userName") String userName)
|
|
||||||
{
|
|
||||||
passwordService.clearLoginRecordCache(userName);
|
|
||||||
return success();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
|
@ -42,15 +40,14 @@ public class SysOperlogController extends BaseController
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysOperLog operLog)
|
public AjaxResult export(SysOperLog operLog)
|
||||||
{
|
{
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||||
util.exportExcel(response, list, "操作日志");
|
return util.exportExcel(list, "操作日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
@DeleteMapping("/{operIds}")
|
@DeleteMapping("/{operIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||||
|
|
@ -64,6 +61,6 @@ public class SysOperlogController extends BaseController
|
||||||
public AjaxResult clean()
|
public AjaxResult clean()
|
||||||
{
|
{
|
||||||
operLogService.cleanOperLog();
|
operLogService.cleanOperLog();
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
|
@ -42,22 +42,31 @@ public class SysUserOnlineController extends BaseController
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(String ipaddr, String userName)
|
public TableDataInfo list(String ipaddr, String userName)
|
||||||
{
|
{
|
||||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
||||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||||
for (String key : keys)
|
for (String key : keys)
|
||||||
{
|
{
|
||||||
LoginUser user = redisCache.getCacheObject(key);
|
LoginUser user = redisCache.getCacheObject(key);
|
||||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(ipaddr))
|
else if (StringUtils.isNotEmpty(ipaddr))
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
if (StringUtils.equals(userName, user.getUsername()))
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +86,7 @@ public class SysUserOnlineController extends BaseController
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public AjaxResult forceLogout(@PathVariable String tokenId)
|
public AjaxResult forceLogout(@PathVariable String tokenId)
|
||||||
{
|
{
|
||||||
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -14,10 +13,13 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
|
@ -48,12 +50,12 @@ public class SysConfigController extends BaseController
|
||||||
|
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysConfig config)
|
public AjaxResult export(SysConfig config)
|
||||||
{
|
{
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||||
util.exportExcel(response, list, "参数数据");
|
return util.exportExcel(list, "参数数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,7 +65,7 @@ public class SysConfigController extends BaseController
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long configId)
|
public AjaxResult getInfo(@PathVariable Long configId)
|
||||||
{
|
{
|
||||||
return success(configService.selectConfigById(configId));
|
return AjaxResult.success(configService.selectConfigById(configId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,7 +74,7 @@ public class SysConfigController extends BaseController
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
public AjaxResult getConfigKey(@PathVariable String configKey)
|
public AjaxResult getConfigKey(@PathVariable String configKey)
|
||||||
{
|
{
|
||||||
return success(configService.selectConfigByKey(configKey));
|
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,13 +83,14 @@ public class SysConfigController extends BaseController
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@RepeatSubmit
|
||||||
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
||||||
{
|
{
|
||||||
if (!configService.checkConfigKeyUnique(config))
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||||
{
|
{
|
||||||
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setCreateBy(getUsername());
|
config.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(configService.insertConfig(config));
|
return toAjax(configService.insertConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,11 +102,11 @@ public class SysConfigController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
||||||
{
|
{
|
||||||
if (!configService.checkConfigKeyUnique(config))
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||||
{
|
{
|
||||||
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setUpdateBy(getUsername());
|
config.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(configService.updateConfig(config));
|
return toAjax(configService.updateConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,19 +118,18 @@ public class SysConfigController extends BaseController
|
||||||
@DeleteMapping("/{configIds}")
|
@DeleteMapping("/{configIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] configIds)
|
public AjaxResult remove(@PathVariable Long[] configIds)
|
||||||
{
|
{
|
||||||
configService.deleteConfigByIds(configIds);
|
return toAjax(configService.deleteConfigByIds(configIds));
|
||||||
return success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新参数缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/clearCache")
|
||||||
public AjaxResult refreshCache()
|
public AjaxResult clearCache()
|
||||||
{
|
{
|
||||||
configService.resetConfigCache();
|
configService.clearCache();
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -19,6 +20,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
|
||||||
|
|
@ -42,7 +44,7 @@ public class SysDeptController extends BaseController
|
||||||
public AjaxResult list(SysDept dept)
|
public AjaxResult list(SysDept dept)
|
||||||
{
|
{
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return success(depts);
|
return AjaxResult.success(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,8 +55,17 @@ public class SysDeptController extends BaseController
|
||||||
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
||||||
{
|
{
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
Iterator<SysDept> it = depts.iterator();
|
||||||
return success(depts);
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
SysDept d = (SysDept) it.next();
|
||||||
|
if (d.getDeptId().intValue() == deptId
|
||||||
|
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,8 +75,30 @@ public class SysDeptController extends BaseController
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long deptId)
|
public AjaxResult getInfo(@PathVariable Long deptId)
|
||||||
{
|
{
|
||||||
deptService.checkDeptDataScope(deptId);
|
return AjaxResult.success(deptService.selectDeptById(deptId));
|
||||||
return success(deptService.selectDeptById(deptId));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门下拉树列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/treeselect")
|
||||||
|
public AjaxResult treeselect(SysDept dept)
|
||||||
|
{
|
||||||
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
|
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载对应角色部门列表树
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||||
|
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
||||||
|
{
|
||||||
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||||
|
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||||
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -76,11 +109,11 @@ public class SysDeptController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
||||||
{
|
{
|
||||||
if (!deptService.checkDeptNameUnique(dept))
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(getUsername());
|
dept.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(deptService.insertDept(dept));
|
return toAjax(deptService.insertDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,21 +125,20 @@ public class SysDeptController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||||
{
|
{
|
||||||
Long deptId = dept.getDeptId();
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
deptService.checkDeptDataScope(deptId);
|
|
||||||
if (!deptService.checkDeptNameUnique(dept))
|
|
||||||
{
|
{
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
else if (dept.getParentId().equals(deptId))
|
else if (dept.getParentId().equals(dept.getDeptId()))
|
||||||
{
|
{
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
}
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||||
|
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
||||||
{
|
{
|
||||||
return error("该部门包含未停用的子部门!");
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
dept.setUpdateBy(getUsername());
|
dept.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(deptService.updateDept(dept));
|
return toAjax(deptService.updateDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,13 +152,12 @@ public class SysDeptController extends BaseController
|
||||||
{
|
{
|
||||||
if (deptService.hasChildByDeptId(deptId))
|
if (deptService.hasChildByDeptId(deptId))
|
||||||
{
|
{
|
||||||
return warn("存在下级部门,不允许删除");
|
return AjaxResult.error("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId))
|
if (deptService.checkDeptExistUser(deptId))
|
||||||
{
|
{
|
||||||
return warn("部门存在用户,不允许删除");
|
return AjaxResult.error("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
deptService.checkDeptDataScope(deptId);
|
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -20,7 +18,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
|
@ -51,12 +49,12 @@ public class SysDictDataController extends BaseController
|
||||||
|
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysDictData dictData)
|
public AjaxResult export(SysDictData dictData)
|
||||||
{
|
{
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||||
util.exportExcel(response, list, "字典数据");
|
return util.exportExcel(list, "字典数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,7 +64,7 @@ public class SysDictDataController extends BaseController
|
||||||
@GetMapping(value = "/{dictCode}")
|
@GetMapping(value = "/{dictCode}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictCode)
|
public AjaxResult getInfo(@PathVariable Long dictCode)
|
||||||
{
|
{
|
||||||
return success(dictDataService.selectDictDataById(dictCode));
|
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,12 +73,7 @@ public class SysDictDataController extends BaseController
|
||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public AjaxResult dictType(@PathVariable String dictType)
|
public AjaxResult dictType(@PathVariable String dictType)
|
||||||
{
|
{
|
||||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
|
||||||
if (StringUtils.isNull(data))
|
|
||||||
{
|
|
||||||
data = new ArrayList<SysDictData>();
|
|
||||||
}
|
|
||||||
return success(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,7 +84,7 @@ public class SysDictDataController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setCreateBy(getUsername());
|
dict.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +96,7 @@ public class SysDictDataController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setUpdateBy(getUsername());
|
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +108,6 @@ public class SysDictDataController extends BaseController
|
||||||
@DeleteMapping("/{dictCodes}")
|
@DeleteMapping("/{dictCodes}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
||||||
{
|
{
|
||||||
dictDataService.deleteDictDataByIds(dictCodes);
|
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
|
||||||
return success();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -14,11 +13,13 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
|
|
@ -45,12 +46,12 @@ public class SysDictTypeController extends BaseController
|
||||||
|
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysDictType dictType)
|
public AjaxResult export(SysDictType dictType)
|
||||||
{
|
{
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||||
util.exportExcel(response, list, "字典类型");
|
return util.exportExcel(list, "字典类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -60,7 +61,7 @@ public class SysDictTypeController extends BaseController
|
||||||
@GetMapping(value = "/{dictId}")
|
@GetMapping(value = "/{dictId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictId)
|
public AjaxResult getInfo(@PathVariable Long dictId)
|
||||||
{
|
{
|
||||||
return success(dictTypeService.selectDictTypeById(dictId));
|
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -71,11 +72,11 @@ public class SysDictTypeController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||||
{
|
{
|
||||||
if (!dictTypeService.checkDictTypeUnique(dict))
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setCreateBy(getUsername());
|
dict.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(dictTypeService.insertDictType(dict));
|
return toAjax(dictTypeService.insertDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,11 +88,11 @@ public class SysDictTypeController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||||
{
|
{
|
||||||
if (!dictTypeService.checkDictTypeUnique(dict))
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setUpdateBy(getUsername());
|
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(dictTypeService.updateDictType(dict));
|
return toAjax(dictTypeService.updateDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,20 +104,19 @@ public class SysDictTypeController extends BaseController
|
||||||
@DeleteMapping("/{dictIds}")
|
@DeleteMapping("/{dictIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictIds)
|
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||||
{
|
{
|
||||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
||||||
return success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新字典缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/clearCache")
|
||||||
public AjaxResult refreshCache()
|
public AjaxResult clearCache()
|
||||||
{
|
{
|
||||||
dictTypeService.resetDictCache();
|
dictTypeService.clearCache();
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,6 +126,6 @@ public class SysDictTypeController extends BaseController
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect()
|
||||||
{
|
{
|
||||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
return success(dictTypes);
|
return AjaxResult.success(dictTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package com.ruoyi.web.controller.system;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 首页
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
public class SysIndexController
|
|
||||||
{
|
|
||||||
/** 系统基础配置 */
|
|
||||||
@Autowired
|
|
||||||
private RuoYiConfig ruoyiConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 访问首页,提示语
|
|
||||||
*/
|
|
||||||
@RequestMapping("/")
|
|
||||||
public String index()
|
|
||||||
{
|
|
||||||
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -14,14 +13,10 @@ import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.framework.web.service.SysLoginService;
|
import com.ruoyi.framework.web.service.SysLoginService;
|
||||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,9 +39,6 @@ public class SysLoginController
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysConfigService configService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录方法
|
* 登录方法
|
||||||
*
|
*
|
||||||
|
|
@ -72,23 +64,16 @@ public class SysLoginController
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public AjaxResult getInfo()
|
public AjaxResult getInfo()
|
||||||
{
|
{
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
SysUser user = loginUser.getUser();
|
SysUser user = loginUser.getUser();
|
||||||
// 角色集合
|
// 角色集合
|
||||||
Set<String> roles = permissionService.getRolePermission(user);
|
Set<String> roles = permissionService.getRolePermission(user);
|
||||||
// 权限集合
|
// 权限集合
|
||||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||||
if (!loginUser.getPermissions().equals(permissions))
|
|
||||||
{
|
|
||||||
loginUser.setPermissions(permissions);
|
|
||||||
tokenService.refreshToken(loginUser);
|
|
||||||
}
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("user", user);
|
ajax.put("user", user);
|
||||||
ajax.put("roles", roles);
|
ajax.put("roles", roles);
|
||||||
ajax.put("permissions", permissions);
|
ajax.put("permissions", permissions);
|
||||||
ajax.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
|
|
||||||
ajax.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));
|
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,32 +85,10 @@ public class SysLoginController
|
||||||
@GetMapping("getRouters")
|
@GetMapping("getRouters")
|
||||||
public AjaxResult getRouters()
|
public AjaxResult getRouters()
|
||||||
{
|
{
|
||||||
Long userId = SecurityUtils.getUserId();
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
// 用户信息
|
||||||
|
SysUser user = loginUser.getUser();
|
||||||
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId());
|
||||||
return AjaxResult.success(menuService.buildMenus(menus));
|
return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查初始密码是否提醒修改
|
|
||||||
public boolean initPasswordIsModify(Date pwdUpdateDate)
|
|
||||||
{
|
|
||||||
Integer initPasswordModify = Convert.toInt(configService.selectConfigByKey("sys.account.initPasswordModify"));
|
|
||||||
return initPasswordModify != null && initPasswordModify == 1 && pwdUpdateDate == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查密码是否过期
|
|
||||||
public boolean passwordIsExpiration(Date pwdUpdateDate)
|
|
||||||
{
|
|
||||||
Integer passwordValidateDays = Convert.toInt(configService.selectConfigByKey("sys.account.passwordValidateDays"));
|
|
||||||
if (passwordValidateDays != null && passwordValidateDays > 0)
|
|
||||||
{
|
|
||||||
if (StringUtils.isNull(pwdUpdateDate))
|
|
||||||
{
|
|
||||||
// 如果从未修改过初始密码,直接提醒过期
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Date nowDate = DateUtils.getNowDate();
|
|
||||||
return DateUtils.differentDaysByMillisecond(nowDate, pwdUpdateDate) > passwordValidateDays;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,17 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,6 +38,9 @@ public class SysMenuController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysMenuService menuService;
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单列表
|
* 获取菜单列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -40,8 +48,10 @@ public class SysMenuController extends BaseController
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(SysMenu menu)
|
public AjaxResult list(SysMenu menu)
|
||||||
{
|
{
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
return success(menus);
|
Long userId = loginUser.getUser().getUserId();
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
|
return AjaxResult.success(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,7 +61,7 @@ public class SysMenuController extends BaseController
|
||||||
@GetMapping(value = "/{menuId}")
|
@GetMapping(value = "/{menuId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long menuId)
|
public AjaxResult getInfo(@PathVariable Long menuId)
|
||||||
{
|
{
|
||||||
return success(menuService.selectMenuById(menuId));
|
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -60,8 +70,10 @@ public class SysMenuController extends BaseController
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(SysMenu menu)
|
public AjaxResult treeselect(SysMenu menu)
|
||||||
{
|
{
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
return success(menuService.buildMenuTreeSelect(menus));
|
Long userId = loginUser.getUser().getUserId();
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
|
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,7 +82,8 @@ public class SysMenuController extends BaseController
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
||||||
{
|
{
|
||||||
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||||
|
|
@ -85,19 +98,16 @@ public class SysMenuController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
||||||
{
|
{
|
||||||
if (!menuService.checkMenuNameUnique(menu))
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||||
{
|
{
|
||||||
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
|
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
||||||
{
|
{
|
||||||
return error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
}
|
||||||
else if (!menuService.checkRouteConfigUnique(menu))
|
menu.setCreateBy(SecurityUtils.getUsername());
|
||||||
{
|
|
||||||
return error("新增菜单'" + menu.getMenuName() + "'失败,路由名称或地址已存在");
|
|
||||||
}
|
|
||||||
menu.setCreateBy(getUsername());
|
|
||||||
return toAjax(menuService.insertMenu(menu));
|
return toAjax(menuService.insertMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,23 +119,20 @@ public class SysMenuController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
||||||
{
|
{
|
||||||
if (!menuService.checkMenuNameUnique(menu))
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||||
{
|
{
|
||||||
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
|
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
||||||
{
|
{
|
||||||
return error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
}
|
||||||
else if (menu.getMenuId().equals(menu.getParentId()))
|
else if (menu.getMenuId().equals(menu.getParentId()))
|
||||||
{
|
{
|
||||||
return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
}
|
}
|
||||||
else if (!menuService.checkRouteConfigUnique(menu))
|
menu.setUpdateBy(SecurityUtils.getUsername());
|
||||||
{
|
|
||||||
return error("修改菜单'" + menu.getMenuName() + "'失败,路由名称或地址已存在");
|
|
||||||
}
|
|
||||||
menu.setUpdateBy(getUsername());
|
|
||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,11 +146,11 @@ public class SysMenuController extends BaseController
|
||||||
{
|
{
|
||||||
if (menuService.hasChildByMenuId(menuId))
|
if (menuService.hasChildByMenuId(menuId))
|
||||||
{
|
{
|
||||||
return warn("存在子菜单,不允许删除");
|
return AjaxResult.error("存在子菜单,不允许删除");
|
||||||
}
|
}
|
||||||
if (menuService.checkMenuExistRole(menuId))
|
if (menuService.checkMenuExistRole(menuId))
|
||||||
{
|
{
|
||||||
return warn("菜单已分配,不允许删除");
|
return AjaxResult.error("菜单已分配,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ public class SysNoticeController extends BaseController
|
||||||
@GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/{noticeId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
public AjaxResult getInfo(@PathVariable Long noticeId)
|
||||||
{
|
{
|
||||||
return success(noticeService.selectNoticeById(noticeId));
|
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,7 +63,7 @@ public class SysNoticeController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
||||||
{
|
{
|
||||||
notice.setCreateBy(getUsername());
|
notice.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +75,7 @@ public class SysNoticeController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
||||||
{
|
{
|
||||||
notice.setUpdateBy(getUsername());
|
notice.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -14,10 +13,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
|
|
@ -48,12 +49,12 @@ public class SysPostController extends BaseController
|
||||||
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysPost post)
|
public AjaxResult export(SysPost post)
|
||||||
{
|
{
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||||
util.exportExcel(response, list, "岗位数据");
|
return util.exportExcel(list, "岗位数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,7 +64,7 @@ public class SysPostController extends BaseController
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long postId)
|
public AjaxResult getInfo(@PathVariable Long postId)
|
||||||
{
|
{
|
||||||
return success(postService.selectPostById(postId));
|
return AjaxResult.success(postService.selectPostById(postId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,15 +75,15 @@ public class SysPostController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
public AjaxResult add(@Validated @RequestBody SysPost post)
|
||||||
{
|
{
|
||||||
if (!postService.checkPostNameUnique(post))
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||||
{
|
{
|
||||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
}
|
||||||
else if (!postService.checkPostCodeUnique(post))
|
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||||
{
|
{
|
||||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setCreateBy(getUsername());
|
post.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(postService.insertPost(post));
|
return toAjax(postService.insertPost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,15 +95,15 @@ public class SysPostController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
||||||
{
|
{
|
||||||
if (!postService.checkPostNameUnique(post))
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||||
{
|
{
|
||||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
}
|
||||||
else if (!postService.checkPostCodeUnique(post))
|
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||||
{
|
{
|
||||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setUpdateBy(getUsername());
|
post.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,6 +125,6 @@ public class SysPostController extends BaseController
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect()
|
||||||
{
|
{
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
return success(posts);
|
return AjaxResult.success(posts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.io.IOException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
@ -17,12 +17,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUtils;
|
|
||||||
import com.ruoyi.common.utils.file.MimeTypeUtils;
|
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
|
|
@ -47,7 +44,7 @@ public class SysProfileController extends BaseController
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public AjaxResult profile()
|
public AjaxResult profile()
|
||||||
{
|
{
|
||||||
LoginUser loginUser = getLoginUser();
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
SysUser user = loginUser.getUser();
|
SysUser user = loginUser.getUser();
|
||||||
AjaxResult ajax = AjaxResult.success(user);
|
AjaxResult ajax = AjaxResult.success(user);
|
||||||
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||||
|
|
@ -62,27 +59,18 @@ public class SysProfileController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
LoginUser loginUser = getLoginUser();
|
if (userService.updateUserProfile(user) > 0)
|
||||||
SysUser currentUser = loginUser.getUser();
|
|
||||||
currentUser.setNickName(user.getNickName());
|
|
||||||
currentUser.setEmail(user.getEmail());
|
|
||||||
currentUser.setPhonenumber(user.getPhonenumber());
|
|
||||||
currentUser.setSex(user.getSex());
|
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
|
|
||||||
{
|
|
||||||
return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
|
|
||||||
{
|
|
||||||
return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在");
|
|
||||||
}
|
|
||||||
if (userService.updateUserProfile(currentUser) > 0)
|
|
||||||
{
|
{
|
||||||
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
// 更新缓存用户信息
|
// 更新缓存用户信息
|
||||||
|
loginUser.getUser().setNickName(user.getNickName());
|
||||||
|
loginUser.getUser().setPhonenumber(user.getPhonenumber());
|
||||||
|
loginUser.getUser().setEmail(user.getEmail());
|
||||||
|
loginUser.getUser().setSex(user.getSex());
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return error("修改个人信息异常,请联系管理员");
|
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -90,32 +78,27 @@ public class SysProfileController extends BaseController
|
||||||
*/
|
*/
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updatePwd")
|
@PutMapping("/updatePwd")
|
||||||
public AjaxResult updatePwd(@RequestBody Map<String, String> params)
|
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
||||||
{
|
{
|
||||||
String oldPassword = params.get("oldPassword");
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
String newPassword = params.get("newPassword");
|
String userName = loginUser.getUsername();
|
||||||
LoginUser loginUser = getLoginUser();
|
String password = loginUser.getPassword();
|
||||||
Long userId = loginUser.getUserId();
|
|
||||||
SysUser user = userService.selectUserById(userId);
|
|
||||||
String password = user.getPassword();
|
|
||||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||||
{
|
{
|
||||||
return error("修改密码失败,旧密码错误");
|
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if (SecurityUtils.matchesPassword(newPassword, password))
|
if (SecurityUtils.matchesPassword(newPassword, password))
|
||||||
{
|
{
|
||||||
return error("新密码不能与旧密码相同");
|
return AjaxResult.error("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
newPassword = SecurityUtils.encryptPassword(newPassword);
|
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
||||||
if (userService.resetUserPwd(userId, newPassword) > 0)
|
|
||||||
{
|
{
|
||||||
// 更新缓存用户密码&密码最后更新时间
|
// 更新缓存用户密码
|
||||||
loginUser.getUser().setPwdUpdateDate(DateUtils.getNowDate());
|
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||||
loginUser.getUser().setPassword(newPassword);
|
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return error("修改密码异常,请联系管理员");
|
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,19 +106,14 @@ public class SysProfileController extends BaseController
|
||||||
*/
|
*/
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/avatar")
|
@PostMapping("/avatar")
|
||||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception
|
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
||||||
{
|
{
|
||||||
if (!file.isEmpty())
|
if (!file.isEmpty())
|
||||||
{
|
{
|
||||||
LoginUser loginUser = getLoginUser();
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION, true);
|
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
||||||
if (userService.updateUserAvatar(loginUser.getUserId(), avatar))
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
||||||
{
|
{
|
||||||
String oldAvatar = loginUser.getUser().getAvatar();
|
|
||||||
if (StringUtils.isNotEmpty(oldAvatar))
|
|
||||||
{
|
|
||||||
FileUtils.deleteFile(RuoYiConfig.getProfile() + FileUtils.stripPrefix(oldAvatar));
|
|
||||||
}
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("imgUrl", avatar);
|
ajax.put("imgUrl", avatar);
|
||||||
// 更新缓存用户头像
|
// 更新缓存用户头像
|
||||||
|
|
@ -144,6 +122,6 @@ public class SysProfileController extends BaseController
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return error("上传图片异常,请联系管理员");
|
return AjaxResult.error("上传图片异常,请联系管理员");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
package com.ruoyi.web.controller.system;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.framework.web.service.SysRegisterService;
|
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册验证
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
public class SysRegisterController extends BaseController
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private SysRegisterService registerService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysConfigService configService;
|
|
||||||
|
|
||||||
@PostMapping("/register")
|
|
||||||
public AjaxResult register(@RequestBody RegisterBody user)
|
|
||||||
{
|
|
||||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
|
||||||
{
|
|
||||||
return error("当前系统没有开启注册功能!");
|
|
||||||
}
|
|
||||||
String msg = registerService.register(user);
|
|
||||||
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -14,20 +13,19 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
|
|
@ -45,16 +43,13 @@ public class SysRoleController extends BaseController
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysPermissionService permissionService;
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysDeptService deptService;
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysRole role)
|
public TableDataInfo list(SysRole role)
|
||||||
|
|
@ -66,12 +61,12 @@ public class SysRoleController extends BaseController
|
||||||
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysRole role)
|
public AjaxResult export(SysRole role)
|
||||||
{
|
{
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||||
util.exportExcel(response, list, "角色数据");
|
return util.exportExcel(list, "角色数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,8 +76,7 @@ public class SysRoleController extends BaseController
|
||||||
@GetMapping(value = "/{roleId}")
|
@GetMapping(value = "/{roleId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long roleId)
|
public AjaxResult getInfo(@PathVariable Long roleId)
|
||||||
{
|
{
|
||||||
roleService.checkRoleDataScope(roleId);
|
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||||
return success(roleService.selectRoleById(roleId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -93,15 +87,15 @@ public class SysRoleController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysRole role)
|
public AjaxResult add(@Validated @RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
if (!roleService.checkRoleNameUnique(role))
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
{
|
{
|
||||||
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
}
|
}
|
||||||
else if (!roleService.checkRoleKeyUnique(role))
|
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||||
{
|
{
|
||||||
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setCreateBy(getUsername());
|
role.setCreateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(roleService.insertRole(role));
|
return toAjax(roleService.insertRole(role));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -115,30 +109,29 @@ public class SysRoleController extends BaseController
|
||||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
if (!roleService.checkRoleNameUnique(role))
|
|
||||||
{
|
{
|
||||||
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
}
|
}
|
||||||
else if (!roleService.checkRoleKeyUnique(role))
|
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||||
{
|
{
|
||||||
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setUpdateBy(getUsername());
|
role.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
|
||||||
if (roleService.updateRole(role) > 0)
|
if (roleService.updateRole(role) > 0)
|
||||||
{
|
{
|
||||||
// 更新缓存用户权限
|
// 更新缓存用户权限
|
||||||
LoginUser loginUser = getLoginUser();
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
||||||
{
|
{
|
||||||
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
|
||||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||||
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
}
|
}
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -150,7 +143,6 @@ public class SysRoleController extends BaseController
|
||||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
|
||||||
return toAjax(roleService.authDataScope(role));
|
return toAjax(roleService.authDataScope(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,8 +155,7 @@ public class SysRoleController extends BaseController
|
||||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
role.setUpdateBy(SecurityUtils.getUsername());
|
||||||
role.setUpdateBy(getUsername());
|
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,77 +177,6 @@ public class SysRoleController extends BaseController
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect()
|
||||||
{
|
{
|
||||||
return success(roleService.selectRoleAll());
|
return AjaxResult.success(roleService.selectRoleAll());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询已分配用户角色列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
|
||||||
@GetMapping("/authUser/allocatedList")
|
|
||||||
public TableDataInfo allocatedList(SysUser user)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<SysUser> list = userService.selectAllocatedList(user);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询未分配用户角色列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
|
||||||
@GetMapping("/authUser/unallocatedList")
|
|
||||||
public TableDataInfo unallocatedList(SysUser user)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<SysUser> list = userService.selectUnallocatedList(user);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消授权用户
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
||||||
@PutMapping("/authUser/cancel")
|
|
||||||
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
|
|
||||||
{
|
|
||||||
return toAjax(roleService.deleteAuthUser(userRole));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量取消授权用户
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
||||||
@PutMapping("/authUser/cancelAll")
|
|
||||||
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
|
|
||||||
{
|
|
||||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量选择用户授权
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
||||||
@PutMapping("/authUser/selectAll")
|
|
||||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
|
||||||
{
|
|
||||||
roleService.checkRoleDataScope(roleId);
|
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对应角色部门树列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
|
||||||
@GetMapping(value = "/deptTree/{roleId}")
|
|
||||||
public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
|
|
||||||
{
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
|
||||||
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
|
||||||
return ajax;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -17,17 +15,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
@ -48,10 +48,10 @@ public class SysUserController extends BaseController
|
||||||
private ISysRoleService roleService;
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService deptService;
|
private ISysPostService postService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPostService postService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
|
|
@ -67,12 +67,12 @@ public class SysUserController extends BaseController
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||||
@PostMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysUser user)
|
public AjaxResult export(SysUser user)
|
||||||
{
|
{
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
util.exportExcel(response, list, "用户数据");
|
return util.exportExcel(list, "用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
|
|
@ -82,16 +82,17 @@ public class SysUserController extends BaseController
|
||||||
{
|
{
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||||
String operName = getUsername();
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
String operName = loginUser.getUsername();
|
||||||
String message = userService.importUser(userList, updateSupport, operName);
|
String message = userService.importUser(userList, updateSupport, operName);
|
||||||
return success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/importTemplate")
|
@GetMapping("/importTemplate")
|
||||||
public void importTemplate(HttpServletResponse response)
|
public AjaxResult importTemplate()
|
||||||
{
|
{
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
util.importTemplateExcel(response, "用户数据");
|
return util.importTemplateExcel("用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -102,17 +103,15 @@ public class SysUserController extends BaseController
|
||||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||||
{
|
{
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
|
ajax.put("posts", postService.selectPostAll());
|
||||||
if (StringUtils.isNotNull(userId))
|
if (StringUtils.isNotNull(userId))
|
||||||
{
|
{
|
||||||
userService.checkUserDataScope(userId);
|
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||||
SysUser sysUser = userService.selectUserById(userId);
|
|
||||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
||||||
}
|
}
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
|
||||||
ajax.put("roles", SecurityUtils.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
||||||
ajax.put("posts", postService.selectPostAll());
|
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,21 +123,19 @@ public class SysUserController extends BaseController
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysUser user)
|
public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
deptService.checkDeptDataScope(user.getDeptId());
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
||||||
roleService.checkRoleDataScope(user.getRoleIds());
|
|
||||||
if (!userService.checkUserNameUnique(user))
|
|
||||||
{
|
{
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setCreateBy(getUsername());
|
user.setCreateBy(SecurityUtils.getUsername());
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
return toAjax(userService.insertUser(user));
|
return toAjax(userService.insertUser(user));
|
||||||
}
|
}
|
||||||
|
|
@ -152,22 +149,15 @@ public class SysUserController extends BaseController
|
||||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
deptService.checkDeptDataScope(user.getDeptId());
|
|
||||||
roleService.checkRoleDataScope(user.getRoleIds());
|
|
||||||
if (!userService.checkUserNameUnique(user))
|
|
||||||
{
|
{
|
||||||
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
{
|
|
||||||
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
||||||
}
|
|
||||||
user.setUpdateBy(getUsername());
|
|
||||||
return toAjax(userService.updateUser(user));
|
return toAjax(userService.updateUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,10 +169,6 @@ public class SysUserController extends BaseController
|
||||||
@DeleteMapping("/{userIds}")
|
@DeleteMapping("/{userIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||||
{
|
{
|
||||||
if (ArrayUtils.contains(userIds, getUserId()))
|
|
||||||
{
|
|
||||||
return error("当前用户不能删除");
|
|
||||||
}
|
|
||||||
return toAjax(userService.deleteUserByIds(userIds));
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,9 +181,8 @@ public class SysUserController extends BaseController
|
||||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setUpdateBy(getUsername());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(userService.resetPwd(user));
|
return toAjax(userService.resetPwd(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,47 +195,7 @@ public class SysUserController extends BaseController
|
||||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
user.setUpdateBy(getUsername());
|
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户编号获取授权角色
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
|
||||||
@GetMapping("/authRole/{userId}")
|
|
||||||
public AjaxResult authRole(@PathVariable("userId") Long userId)
|
|
||||||
{
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
SysUser user = userService.selectUserById(userId);
|
|
||||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
|
||||||
ajax.put("user", user);
|
|
||||||
ajax.put("roles", SecurityUtils.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
||||||
return ajax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户授权角色
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
|
||||||
@PutMapping("/authRole")
|
|
||||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
|
||||||
{
|
|
||||||
userService.checkUserDataScope(userId);
|
|
||||||
roleService.checkRoleDataScope(roleIds);
|
|
||||||
userService.insertUserAuth(userId, roleIds);
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门树列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
|
||||||
@GetMapping("/deptTree")
|
|
||||||
public AjaxResult deptTree(SysDept dept)
|
|
||||||
{
|
|
||||||
return success(deptService.selectDeptTreeList(dept));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ruoyi.web.controller.tool;
|
||||||
|
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* swagger 接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/tool/swagger")
|
||||||
|
public class SwaggerController extends BaseController
|
||||||
|
{
|
||||||
|
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
||||||
|
@GetMapping()
|
||||||
|
public String index()
|
||||||
|
{
|
||||||
|
return redirect("/swagger-ui.html");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,15 +9,13 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
@ -40,80 +38,74 @@ public class TestController extends BaseController
|
||||||
|
|
||||||
@ApiOperation("获取用户列表")
|
@ApiOperation("获取用户列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public R<List<UserEntity>> userList()
|
public AjaxResult userList()
|
||||||
{
|
{
|
||||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||||
return R.ok(userList);
|
return AjaxResult.success(userList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取用户详细")
|
@ApiOperation("获取用户详细")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
||||||
@GetMapping("/{userId}")
|
@GetMapping("/{userId}")
|
||||||
public R<UserEntity> getUser(@PathVariable Integer userId)
|
public AjaxResult getUser(@PathVariable Integer userId)
|
||||||
{
|
{
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
if (!users.isEmpty() && users.containsKey(userId))
|
||||||
{
|
{
|
||||||
return R.ok(users.get(userId));
|
return AjaxResult.success(users.get(userId));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return R.fail("用户不存在");
|
return AjaxResult.error("用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
|
|
||||||
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
|
|
||||||
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
|
|
||||||
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
|
||||||
})
|
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public R<String> save(UserEntity user)
|
public AjaxResult save(UserEntity user)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||||
{
|
{
|
||||||
return R.fail("用户ID不能为空");
|
return AjaxResult.error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
users.put(user.getUserId(), user);
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("更新用户")
|
@ApiOperation("更新用户")
|
||||||
|
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
public R<String> update(@RequestBody UserEntity user)
|
public AjaxResult update(UserEntity user)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||||
{
|
{
|
||||||
return R.fail("用户ID不能为空");
|
return AjaxResult.error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
||||||
{
|
{
|
||||||
return R.fail("用户不存在");
|
return AjaxResult.error("用户不存在");
|
||||||
}
|
}
|
||||||
users.remove(user.getUserId());
|
users.remove(user.getUserId());
|
||||||
users.put(user.getUserId(), user);
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除用户信息")
|
@ApiOperation("删除用户信息")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
||||||
@DeleteMapping("/{userId}")
|
@DeleteMapping("/{userId}")
|
||||||
public R<String> delete(@PathVariable Integer userId)
|
public AjaxResult delete(@PathVariable Integer userId)
|
||||||
{
|
{
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
if (!users.isEmpty() && users.containsKey(userId))
|
||||||
{
|
{
|
||||||
users.remove(userId);
|
users.remove(userId);
|
||||||
return R.ok();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return R.fail("用户不存在");
|
return AjaxResult.error("用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModel(value = "UserEntity", description = "用户实体")
|
@ApiModel("用户实体")
|
||||||
class UserEntity
|
class UserEntity
|
||||||
{
|
{
|
||||||
@ApiModelProperty("用户ID")
|
@ApiModelProperty("用户ID")
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.models.auth.In;
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
|
@ -17,10 +16,10 @@ import springfox.documentation.service.ApiKey;
|
||||||
import springfox.documentation.service.AuthorizationScope;
|
import springfox.documentation.service.AuthorizationScope;
|
||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.service.SecurityReference;
|
import springfox.documentation.service.SecurityReference;
|
||||||
import springfox.documentation.service.SecurityScheme;
|
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger2的接口配置
|
* Swagger2的接口配置
|
||||||
|
|
@ -28,6 +27,7 @@ import springfox.documentation.spring.web.plugins.Docket;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
public class SwaggerConfig
|
public class SwaggerConfig
|
||||||
{
|
{
|
||||||
/** 系统基础配置 */
|
/** 系统基础配置 */
|
||||||
|
|
@ -48,7 +48,7 @@ public class SwaggerConfig
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi()
|
public Docket createRestApi()
|
||||||
{
|
{
|
||||||
return new Docket(DocumentationType.OAS_30)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
// 是否启用Swagger
|
// 是否启用Swagger
|
||||||
.enable(enabled)
|
.enable(enabled)
|
||||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||||
|
|
@ -71,10 +71,10 @@ public class SwaggerConfig
|
||||||
/**
|
/**
|
||||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||||
*/
|
*/
|
||||||
private List<SecurityScheme> securitySchemes()
|
private List<ApiKey> securitySchemes()
|
||||||
{
|
{
|
||||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
|
||||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
|
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
||||||
return apiKeyList;
|
return apiKeyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class SwaggerConfig
|
||||||
securityContexts.add(
|
securityContexts.add(
|
||||||
SecurityContext.builder()
|
SecurityContext.builder()
|
||||||
.securityReferences(defaultAuth())
|
.securityReferences(defaultAuth())
|
||||||
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
.forPaths(PathSelectors.regex("^(?!auth).*$"))
|
||||||
.build());
|
.build());
|
||||||
return securityContexts;
|
return securityContexts;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
restart.include.json=/com.alibaba.fastjson2.*.jar
|
restart.include.json=/com.alibaba.fastjson.*.jar
|
||||||
|
|
@ -24,10 +24,6 @@ spring:
|
||||||
maxActive: 20
|
maxActive: 20
|
||||||
# 配置获取连接等待超时的时间
|
# 配置获取连接等待超时的时间
|
||||||
maxWait: 60000
|
maxWait: 60000
|
||||||
# 配置连接超时时间
|
|
||||||
connectTimeout: 30000
|
|
||||||
# 配置网络超时时间
|
|
||||||
socketTimeout: 60000
|
|
||||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
timeBetweenEvictionRunsMillis: 60000
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
|
|
@ -47,8 +43,8 @@ spring:
|
||||||
allow:
|
allow:
|
||||||
url-pattern: /druid/*
|
url-pattern: /druid/*
|
||||||
# 控制台管理用户名和密码
|
# 控制台管理用户名和密码
|
||||||
login-username: ruoyi
|
login-username:
|
||||||
login-password: 123456
|
login-password:
|
||||||
filter:
|
filter:
|
||||||
stat:
|
stat:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,16 @@ ruoyi:
|
||||||
# 名称
|
# 名称
|
||||||
name: RuoYi
|
name: RuoYi
|
||||||
# 版本
|
# 版本
|
||||||
version: 3.9.1
|
version: 3.2.1
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2026
|
copyrightYear: 2020
|
||||||
|
# 实例演示开关
|
||||||
|
demoEnabled: true
|
||||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||||
profile: D:/ruoyi/uploadPath
|
profile: D:/ruoyi/uploadPath
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
addressEnabled: false
|
addressEnabled: false
|
||||||
# 验证码类型 math 数字计算 char 字符验证
|
# 验证码类型 math 数组计算 char 字符验证
|
||||||
captchaType: math
|
captchaType: math
|
||||||
|
|
||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
|
|
@ -23,13 +25,10 @@ server:
|
||||||
tomcat:
|
tomcat:
|
||||||
# tomcat的URI编码
|
# tomcat的URI编码
|
||||||
uri-encoding: UTF-8
|
uri-encoding: UTF-8
|
||||||
# 连接数满后的排队数,默认为100
|
# tomcat最大线程数,默认为200
|
||||||
accept-count: 1000
|
max-threads: 800
|
||||||
threads:
|
# Tomcat启动初始化的线程数,默认值25
|
||||||
# tomcat最大线程数,默认为200
|
min-spare-threads: 30
|
||||||
max: 800
|
|
||||||
# Tomcat启动初始化的线程数,默认值10
|
|
||||||
min-spare: 100
|
|
||||||
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
|
|
@ -37,29 +36,21 @@ logging:
|
||||||
com.ruoyi: debug
|
com.ruoyi: debug
|
||||||
org.springframework: warn
|
org.springframework: warn
|
||||||
|
|
||||||
# 用户配置
|
|
||||||
user:
|
|
||||||
password:
|
|
||||||
# 密码最大错误次数
|
|
||||||
maxRetryCount: 5
|
|
||||||
# 密码锁定时间(默认10分钟)
|
|
||||||
lockTime: 10
|
|
||||||
|
|
||||||
# Spring配置
|
# Spring配置
|
||||||
spring:
|
spring:
|
||||||
# 资源信息
|
# 资源信息
|
||||||
messages:
|
messages:
|
||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
basename: i18n/messages
|
basename: i18n/messages
|
||||||
profiles:
|
profiles:
|
||||||
active: druid
|
active: druid
|
||||||
# 文件上传
|
# 文件上传
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
# 单个文件大小
|
# 单个文件大小
|
||||||
max-file-size: 10MB
|
max-file-size: 10MB
|
||||||
# 设置总上传的文件大小
|
# 设置总上传的文件大小
|
||||||
max-request-size: 20MB
|
max-request-size: 20MB
|
||||||
# 服务模块
|
# 服务模块
|
||||||
devtools:
|
devtools:
|
||||||
restart:
|
restart:
|
||||||
|
|
@ -71,10 +62,8 @@ spring:
|
||||||
host: localhost
|
host: localhost
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
|
||||||
database: 0
|
|
||||||
# 密码
|
# 密码
|
||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lettuce:
|
lettuce:
|
||||||
|
|
@ -90,27 +79,28 @@ spring:
|
||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
token:
|
token:
|
||||||
# 令牌自定义标识
|
# 令牌自定义标识
|
||||||
header: Authorization
|
header: Authorization
|
||||||
# 令牌密钥
|
# 令牌密钥
|
||||||
secret: abcdefghijklmnopqrstuvwxyz
|
secret: abcdefghijklmnopqrstuvwxyz
|
||||||
# 令牌有效期(默认30分钟)
|
# 令牌有效期(默认30分钟)
|
||||||
expireTime: 30
|
expireTime: 30
|
||||||
|
|
||||||
# MyBatis配置
|
# MyBatis配置
|
||||||
mybatis:
|
mybatis:
|
||||||
# 搜索指定包别名
|
# 搜索指定包别名
|
||||||
typeAliasesPackage: com.ruoyi.**.domain
|
typeAliasesPackage: com.ruoyi.**.domain
|
||||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
# 加载全局的配置文件
|
# 加载全局的配置文件
|
||||||
configLocation: classpath:mybatis/mybatis-config.xml
|
configLocation: classpath:mybatis/mybatis-config.xml
|
||||||
|
|
||||||
# PageHelper分页插件
|
# PageHelper分页插件
|
||||||
pagehelper:
|
pagehelper:
|
||||||
helperDialect: mysql
|
helperDialect: mysql
|
||||||
|
reasonable: true
|
||||||
supportMethodsArguments: true
|
supportMethodsArguments: true
|
||||||
params: count=countSql
|
params: count=countSql
|
||||||
|
|
||||||
# Swagger配置
|
# Swagger配置
|
||||||
swagger:
|
swagger:
|
||||||
|
|
@ -119,18 +109,11 @@ swagger:
|
||||||
# 请求前缀
|
# 请求前缀
|
||||||
pathMapping: /dev-api
|
pathMapping: /dev-api
|
||||||
|
|
||||||
# 防盗链配置
|
|
||||||
referer:
|
|
||||||
# 防盗链开关
|
|
||||||
enabled: false
|
|
||||||
# 允许的域名列表
|
|
||||||
allowed-domains: localhost,127.0.0.1,ruoyi.vip,www.ruoyi.vip
|
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
xss:
|
xss:
|
||||||
# 过滤开关
|
# 过滤开关
|
||||||
enabled: true
|
enabled: true
|
||||||
# 排除链接(多个用逗号分隔)
|
# 排除链接(多个用逗号分隔)
|
||||||
excludes: /system/notice
|
excludes: /system/notice/*
|
||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ user.jcaptcha.expire=验证码已失效
|
||||||
user.not.exists=用户不存在/密码错误
|
user.not.exists=用户不存在/密码错误
|
||||||
user.password.not.match=用户不存在/密码错误
|
user.password.not.match=用户不存在/密码错误
|
||||||
user.password.retry.limit.count=密码输入错误{0}次
|
user.password.retry.limit.count=密码输入错误{0}次
|
||||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟
|
||||||
user.password.delete=对不起,您的账号已被删除
|
user.password.delete=对不起,您的账号已被删除
|
||||||
user.blocked=用户已封禁,请联系管理员
|
user.blocked=用户已封禁,请联系管理员
|
||||||
role.blocked=角色已封禁,请联系管理员
|
role.blocked=角色已封禁,请联系管理员
|
||||||
login.blocked=很遗憾,访问IP已被列入系统黑名单
|
|
||||||
user.logout.success=退出成功
|
user.logout.success=退出成功
|
||||||
|
|
||||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||||
|
|
@ -20,7 +19,6 @@ user.password.not.valid=* 5-50个字符
|
||||||
user.email.not.valid=邮箱格式错误
|
user.email.not.valid=邮箱格式错误
|
||||||
user.mobile.phone.number.not.valid=手机号格式错误
|
user.mobile.phone.number.not.valid=手机号格式错误
|
||||||
user.login.success=登录成功
|
user.login.success=登录成功
|
||||||
user.register.success=注册成功
|
|
||||||
user.notfound=请重新登录
|
user.notfound=请重新登录
|
||||||
user.forcelogout=管理员强制退出,请重新登录
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
user.unknown.error=未知错误,请重新登录
|
user.unknown.error=未知错误,请重新登录
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,13 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- 全局参数 -->
|
|
||||||
<settings>
|
<settings>
|
||||||
<!-- 使全局的映射器启用或禁用缓存 -->
|
<setting name="cacheEnabled" value="true" /> <!-- 全局映射器启用缓存 -->
|
||||||
<setting name="cacheEnabled" value="true" />
|
<setting name="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 -->
|
||||||
<!-- 允许JDBC 支持自动生成主键 -->
|
<setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 -->
|
||||||
<setting name="useGeneratedKeys" value="true" />
|
<setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||||
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
|
||||||
<setting name="defaultExecutorType" value="SIMPLE" />
|
|
||||||
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
|
||||||
<setting name="logImpl" value="SLF4J" />
|
|
||||||
<!-- 使用驼峰命名法转换字段 -->
|
|
||||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
|
||||||
</settings>
|
</settings>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.9.1</version>
|
<version>3.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -43,8 +43,8 @@
|
||||||
|
|
||||||
<!-- 自定义验证注解 -->
|
<!-- 自定义验证注解 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>javax.validation</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>validation-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--常用工具类 -->
|
<!--常用工具类 -->
|
||||||
|
|
@ -58,11 +58,11 @@
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 阿里JSON解析器 -->
|
<!-- 阿里JSON解析器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson2</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- io常用工具类 -->
|
<!-- io常用工具类 -->
|
||||||
|
|
@ -71,24 +71,30 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 文件上传工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<!-- excel工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Token生成与解析-->
|
<!-- yml解析器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Token生成与解析-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Jaxb -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- redis 缓存操作 -->
|
<!-- redis 缓存操作 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
@ -103,8 +109,8 @@
|
||||||
|
|
||||||
<!-- 解析客户端操作系统、浏览器等 -->
|
<!-- 解析客户端操作系统、浏览器等 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.basjes.parse.useragent</groupId>
|
<groupId>eu.bitwalker</groupId>
|
||||||
<artifactId>yauaa</artifactId>
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- servlet包 -->
|
<!-- servlet包 -->
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 匿名访问不鉴权注解
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface Anonymous
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -25,9 +25,4 @@ public @interface DataScope
|
||||||
* 用户表的别名
|
* 用户表的别名
|
||||||
*/
|
*/
|
||||||
public String userAlias() default "";
|
public String userAlias() default "";
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@ss获取,多个权限用逗号分隔开来
|
|
||||||
*/
|
|
||||||
public String permission() default "";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,6 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
||||||
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义导出Excel数据注解
|
* 自定义导出Excel数据注解
|
||||||
|
|
@ -59,12 +56,17 @@ public @interface Excel
|
||||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度
|
* 导出类型(0数字 1字符串)
|
||||||
|
*/
|
||||||
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出时在excel中每个列的高度 单位为字符
|
||||||
*/
|
*/
|
||||||
public double height() default 14;
|
public double height() default 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的宽度
|
* 导出时在excel中每个列的宽 单位为字符
|
||||||
*/
|
*/
|
||||||
public double width() default 16;
|
public double width() default 16;
|
||||||
|
|
||||||
|
|
@ -83,26 +85,11 @@ public @interface Excel
|
||||||
*/
|
*/
|
||||||
public String prompt() default "";
|
public String prompt() default "";
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否允许内容换行
|
|
||||||
*/
|
|
||||||
public boolean wrapText() default false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置只能选择不能输入的列内容.
|
* 设置只能选择不能输入的列内容.
|
||||||
*/
|
*/
|
||||||
public String[] combo() default {};
|
public String[] combo() default {};
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否从字典读数据到combo,默认不读取,如读取需要设置dictType注解.
|
|
||||||
*/
|
|
||||||
public boolean comboReadDict() default false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
|
||||||
*/
|
|
||||||
public boolean needMerge() default false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||||
*/
|
*/
|
||||||
|
|
@ -118,46 +105,6 @@ public @interface Excel
|
||||||
*/
|
*/
|
||||||
public boolean isStatistics() default false;
|
public boolean isStatistics() default false;
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出类型(0数字 1字符串 2图片)
|
|
||||||
*/
|
|
||||||
public ColumnType cellType() default ColumnType.STRING;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出列头背景颜色
|
|
||||||
*/
|
|
||||||
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出列头字体颜色
|
|
||||||
*/
|
|
||||||
public IndexedColors headerColor() default IndexedColors.WHITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出单元格背景颜色
|
|
||||||
*/
|
|
||||||
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出单元格字体颜色
|
|
||||||
*/
|
|
||||||
public IndexedColors color() default IndexedColors.BLACK;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出字段对齐方式
|
|
||||||
*/
|
|
||||||
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义数据处理器
|
|
||||||
*/
|
|
||||||
public Class<?> handler() default ExcelHandlerAdapter.class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义数据处理器参数
|
|
||||||
*/
|
|
||||||
public String[] args() default {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
*/
|
*/
|
||||||
|
|
@ -181,7 +128,7 @@ public @interface Excel
|
||||||
|
|
||||||
public enum ColumnType
|
public enum ColumnType
|
||||||
{
|
{
|
||||||
NUMERIC(0), STRING(1), IMAGE(2), TEXT(3);
|
NUMERIC(0), STRING(1);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
ColumnType(int value)
|
ColumnType(int value)
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,5 @@ import java.lang.annotation.Target;
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Excels
|
public @interface Excels
|
||||||
{
|
{
|
||||||
public Excel[] value();
|
Excel[] value();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import com.ruoyi.common.enums.OperatorType;
|
||||||
public @interface Log
|
public @interface Log
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 模块
|
* 模块
|
||||||
*/
|
*/
|
||||||
public String title() default "";
|
public String title() default "";
|
||||||
|
|
||||||
|
|
@ -38,14 +38,4 @@ public @interface Log
|
||||||
* 是否保存请求的参数
|
* 是否保存请求的参数
|
||||||
*/
|
*/
|
||||||
public boolean isSaveRequestData() default true;
|
public boolean isSaveRequestData() default true;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否保存响应的参数
|
|
||||||
*/
|
|
||||||
public boolean isSaveResponseData() default true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排除指定的请求参数
|
|
||||||
*/
|
|
||||||
public String[] excludeParamNames() default {};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
|
||||||
import com.ruoyi.common.enums.LimitType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流注解
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface RateLimiter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 限流key
|
|
||||||
*/
|
|
||||||
public String key() default CacheConstants.RATE_LIMIT_KEY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流时间,单位秒
|
|
||||||
*/
|
|
||||||
public int time() default 60;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流次数
|
|
||||||
*/
|
|
||||||
public int count() default 100;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流类型
|
|
||||||
*/
|
|
||||||
public LimitType limitType() default LimitType.DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
@ -19,13 +19,5 @@ import java.lang.annotation.Target;
|
||||||
@Documented
|
@Documented
|
||||||
public @interface RepeatSubmit
|
public @interface RepeatSubmit
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 间隔时间(ms),小于此时间视为重复提交
|
|
||||||
*/
|
|
||||||
public int interval() default 5000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提示消息
|
|
||||||
*/
|
|
||||||
public String message() default "不允许重复提交,请稍候再试";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import com.ruoyi.common.config.serializer.SensitiveJsonSerializer;
|
|
||||||
import com.ruoyi.common.enums.DesensitizedType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据脱敏注解
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
@JacksonAnnotationsInside
|
|
||||||
@JsonSerialize(using = SensitiveJsonSerializer.class)
|
|
||||||
public @interface Sensitive
|
|
||||||
{
|
|
||||||
DesensitizedType desensitizedType();
|
|
||||||
}
|
|
||||||
|
|
@ -21,15 +21,15 @@ public class RuoYiConfig
|
||||||
/** 版权年份 */
|
/** 版权年份 */
|
||||||
private String copyrightYear;
|
private String copyrightYear;
|
||||||
|
|
||||||
|
/** 实例演示开关 */
|
||||||
|
private boolean demoEnabled;
|
||||||
|
|
||||||
/** 上传路径 */
|
/** 上传路径 */
|
||||||
private static String profile;
|
private static String profile;
|
||||||
|
|
||||||
/** 获取地址开关 */
|
/** 获取地址开关 */
|
||||||
private static boolean addressEnabled;
|
private static boolean addressEnabled;
|
||||||
|
|
||||||
/** 验证码类型 */
|
|
||||||
private static String captchaType;
|
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
|
|
@ -60,6 +60,16 @@ public class RuoYiConfig
|
||||||
this.copyrightYear = copyrightYear;
|
this.copyrightYear = copyrightYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDemoEnabled()
|
||||||
|
{
|
||||||
|
return demoEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDemoEnabled(boolean demoEnabled)
|
||||||
|
{
|
||||||
|
this.demoEnabled = demoEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getProfile()
|
public static String getProfile()
|
||||||
{
|
{
|
||||||
return profile;
|
return profile;
|
||||||
|
|
@ -80,22 +90,6 @@ public class RuoYiConfig
|
||||||
RuoYiConfig.addressEnabled = addressEnabled;
|
RuoYiConfig.addressEnabled = addressEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCaptchaType() {
|
|
||||||
return captchaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCaptchaType(String captchaType) {
|
|
||||||
RuoYiConfig.captchaType = captchaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取导入上传路径
|
|
||||||
*/
|
|
||||||
public static String getImportPath()
|
|
||||||
{
|
|
||||||
return getProfile() + "/import";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取头像上传路径
|
* 获取头像上传路径
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
package com.ruoyi.common.config.serializer;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
||||||
import com.fasterxml.jackson.databind.BeanProperty;
|
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
|
||||||
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
|
||||||
import com.ruoyi.common.annotation.Sensitive;
|
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.enums.DesensitizedType;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据脱敏序列化过滤
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer
|
|
||||||
{
|
|
||||||
private DesensitizedType desensitizedType;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException
|
|
||||||
{
|
|
||||||
if (desensitization())
|
|
||||||
{
|
|
||||||
gen.writeString(desensitizedType.desensitizer().apply(value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gen.writeString(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
|
|
||||||
throws JsonMappingException
|
|
||||||
{
|
|
||||||
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
|
||||||
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass()))
|
|
||||||
{
|
|
||||||
this.desensitizedType = annotation.desensitizedType();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return prov.findValueSerializer(property.getType(), property);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否需要脱敏处理
|
|
||||||
*/
|
|
||||||
private boolean desensitization()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoginUser securityUser = SecurityUtils.getLoginUser();
|
|
||||||
// 管理员不脱敏
|
|
||||||
return !securityUser.getUser().isAdmin();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
package com.ruoyi.common.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 缓存的key 常量
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class CacheConstants
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 登录用户 redis key
|
|
||||||
*/
|
|
||||||
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码 redis key
|
|
||||||
*/
|
|
||||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数管理 cache key
|
|
||||||
*/
|
|
||||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典管理 cache key
|
|
||||||
*/
|
|
||||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 防重提交 redis key
|
|
||||||
*/
|
|
||||||
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流 redis key
|
|
||||||
*/
|
|
||||||
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录账户密码错误次数 redis key
|
|
||||||
*/
|
|
||||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import io.jsonwebtoken.Claims;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用常量信息
|
* 通用常量信息
|
||||||
*
|
*
|
||||||
|
|
@ -20,16 +17,6 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String GBK = "GBK";
|
public static final String GBK = "GBK";
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统语言
|
|
||||||
*/
|
|
||||||
public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* www主域
|
|
||||||
*/
|
|
||||||
public static final String WWW = "www.";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http请求
|
* http请求
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,35 +47,25 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String LOGOUT = "Logout";
|
public static final String LOGOUT = "Logout";
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册
|
|
||||||
*/
|
|
||||||
public static final String REGISTER = "Register";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录失败
|
* 登录失败
|
||||||
*/
|
*/
|
||||||
public static final String LOGIN_FAIL = "Error";
|
public static final String LOGIN_FAIL = "Error";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有权限标识
|
* 验证码 redis key
|
||||||
*/
|
*/
|
||||||
public static final String ALL_PERMISSION = "*:*:*";
|
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员角色权限标识
|
* 登录用户 redis key
|
||||||
*/
|
*/
|
||||||
public static final String SUPER_ADMIN = "admin";
|
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色权限分隔符
|
* 防重提交 redis key
|
||||||
*/
|
*/
|
||||||
public static final String ROLE_DELIMITER = ",";
|
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限标识分隔符
|
|
||||||
*/
|
|
||||||
public static final String PERMISSION_DELIMITER = ",";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码有效期(分钟)
|
* 验证码有效期(分钟)
|
||||||
|
|
@ -118,7 +95,7 @@ public class Constants
|
||||||
/**
|
/**
|
||||||
* 用户名称
|
* 用户名称
|
||||||
*/
|
*/
|
||||||
public static final String JWT_USERNAME = Claims.SUBJECT;
|
public static final String JWT_USERNAME = "sub";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户头像
|
* 用户头像
|
||||||
|
|
@ -135,39 +112,18 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String JWT_AUTHORITIES = "authorities";
|
public static final String JWT_AUTHORITIES = "authorities";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数管理 cache key
|
||||||
|
*/
|
||||||
|
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典管理 cache key
|
||||||
|
*/
|
||||||
|
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
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:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
|
||||||
*/
|
|
||||||
public static final String[] JSON_WHITELIST_STR = { "com.ruoyi" };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
|
||||||
*/
|
|
||||||
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi.quartz.task" };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务违规的字符
|
|
||||||
*/
|
|
||||||
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", "com.ruoyi.generator" };
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@ public class GenConstants
|
||||||
/** 树表(增删改查) */
|
/** 树表(增删改查) */
|
||||||
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 TREE_CODE = "treeCode";
|
public static final String TREE_CODE = "treeCode";
|
||||||
|
|
||||||
|
|
@ -32,17 +29,15 @@ public class GenConstants
|
||||||
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", "varchar2", "tinytext", "text",
|
||||||
|
"mediumtext", "longtext" };
|
||||||
/** 数据库文本类型 */
|
|
||||||
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
|
||||||
|
|
||||||
/** 数据库时间类型 */
|
/** 数据库时间类型 */
|
||||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||||
|
|
||||||
/** 数据库数字类型 */
|
/** 数据库数字类型 */
|
||||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
"bit", "bigint", "float", "double", "decimal" };
|
"bit", "bigint", "float", "float", "double", "decimal" };
|
||||||
|
|
||||||
/** 页面不需要编辑字段 */
|
/** 页面不需要编辑字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||||
|
|
@ -79,11 +74,8 @@ public class GenConstants
|
||||||
/** 日期控件 */
|
/** 日期控件 */
|
||||||
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_UPLOAD_IMAGE = "uploadImage";
|
||||||
|
|
||||||
/** 文件上传控件 */
|
|
||||||
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
|
||||||
|
|
||||||
/** 富文本控件 */
|
/** 富文本控件 */
|
||||||
public static final String HTML_EDITOR = "editor";
|
public static final String HTML_EDITOR = "editor";
|
||||||
|
|
@ -109,9 +101,6 @@ public class GenConstants
|
||||||
/** 模糊查询 */
|
/** 模糊查询 */
|
||||||
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 REQUIRE = "1";
|
public static final String REQUIRE = "1";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,4 @@ public class HttpStatus
|
||||||
* 接口未实现
|
* 接口未实现
|
||||||
*/
|
*/
|
||||||
public static final int NOT_IMPLEMENTED = 501;
|
public static final int NOT_IMPLEMENTED = 501;
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统警告消息
|
|
||||||
*/
|
|
||||||
public static final int WARN = 601;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@ public class UserConstants
|
||||||
/** 用户封禁状态 */
|
/** 用户封禁状态 */
|
||||||
public static final String USER_DISABLE = "1";
|
public static final String USER_DISABLE = "1";
|
||||||
|
|
||||||
/** 角色正常状态 */
|
|
||||||
public static final String ROLE_NORMAL = "0";
|
|
||||||
|
|
||||||
/** 角色封禁状态 */
|
/** 角色封禁状态 */
|
||||||
public static final String ROLE_DISABLE = "1";
|
public static final String ROLE_DISABLE = "1";
|
||||||
|
|
||||||
|
|
@ -56,26 +53,8 @@ public class UserConstants
|
||||||
|
|
||||||
/** Layout组件标识 */
|
/** Layout组件标识 */
|
||||||
public final static String LAYOUT = "Layout";
|
public final static String LAYOUT = "Layout";
|
||||||
|
|
||||||
/** ParentView组件标识 */
|
|
||||||
public final static String PARENT_VIEW = "ParentView";
|
|
||||||
|
|
||||||
/** InnerLink组件标识 */
|
/** 校验返回结果码 */
|
||||||
public final static String INNER_LINK = "InnerLink";
|
public final static String UNIQUE = "0";
|
||||||
|
public final static String NOT_UNIQUE = "1";
|
||||||
/** 校验是否唯一的返回标识 */
|
|
||||||
public final static boolean UNIQUE = true;
|
|
||||||
public final static boolean NOT_UNIQUE = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名长度限制
|
|
||||||
*/
|
|
||||||
public static final int USERNAME_MIN_LENGTH = 2;
|
|
||||||
public static final int USERNAME_MAX_LENGTH = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码长度限制
|
|
||||||
*/
|
|
||||||
public static final int PASSWORD_MIN_LENGTH = 5;
|
|
||||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,10 @@ import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.ruoyi.common.constant.HttpStatus;
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.core.page.PageDomain;
|
import com.ruoyi.common.core.page.PageDomain;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.page.TableSupport;
|
import com.ruoyi.common.core.page.TableSupport;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.PageUtils;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||||
|
|
||||||
|
|
@ -28,7 +25,7 @@ import com.ruoyi.common.utils.sql.SqlUtil;
|
||||||
*/
|
*/
|
||||||
public class BaseController
|
public class BaseController
|
||||||
{
|
{
|
||||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
|
|
@ -51,31 +48,17 @@ public class BaseController
|
||||||
* 设置请求分页数据
|
* 设置请求分页数据
|
||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage()
|
||||||
{
|
|
||||||
PageUtils.startPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置请求排序数据
|
|
||||||
*/
|
|
||||||
protected void startOrderBy()
|
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
||||||
{
|
{
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.orderBy(orderBy);
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 清理分页的线程变量
|
|
||||||
*/
|
|
||||||
protected void clearPage()
|
|
||||||
{
|
|
||||||
PageUtils.clearPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
|
|
@ -90,54 +73,6 @@ public class BaseController
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功
|
|
||||||
*/
|
|
||||||
public AjaxResult success()
|
|
||||||
{
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回失败消息
|
|
||||||
*/
|
|
||||||
public AjaxResult error()
|
|
||||||
{
|
|
||||||
return AjaxResult.error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*/
|
|
||||||
public AjaxResult success(String message)
|
|
||||||
{
|
|
||||||
return AjaxResult.success(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*/
|
|
||||||
public AjaxResult success(Object data)
|
|
||||||
{
|
|
||||||
return AjaxResult.success(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回失败消息
|
|
||||||
*/
|
|
||||||
public AjaxResult error(String message)
|
|
||||||
{
|
|
||||||
return AjaxResult.error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回警告消息
|
|
||||||
*/
|
|
||||||
public AjaxResult warn(String message)
|
|
||||||
{
|
|
||||||
return AjaxResult.warn(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应返回结果
|
* 响应返回结果
|
||||||
*
|
*
|
||||||
|
|
@ -149,17 +84,6 @@ public class BaseController
|
||||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应返回结果
|
|
||||||
*
|
|
||||||
* @param result 结果
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
protected AjaxResult toAjax(boolean result)
|
|
||||||
{
|
|
||||||
return result ? success() : error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
|
|
@ -167,36 +91,4 @@ public class BaseController
|
||||||
{
|
{
|
||||||
return StringUtils.format("redirect:{}", url);
|
return StringUtils.format("redirect:{}", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户缓存信息
|
|
||||||
*/
|
|
||||||
public LoginUser getLoginUser()
|
|
||||||
{
|
|
||||||
return SecurityUtils.getLoginUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录用户id
|
|
||||||
*/
|
|
||||||
public Long getUserId()
|
|
||||||
{
|
|
||||||
return getLoginUser().getUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录部门id
|
|
||||||
*/
|
|
||||||
public Long getDeptId()
|
|
||||||
{
|
|
||||||
return getLoginUser().getDeptId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录用户名
|
|
||||||
*/
|
|
||||||
public String getUsername()
|
|
||||||
{
|
|
||||||
return getLoginUser().getUsername();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
|
||||||
import com.ruoyi.common.constant.HttpStatus;
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
|
@ -102,33 +101,10 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回警告消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult warn(String msg)
|
|
||||||
{
|
|
||||||
return AjaxResult.warn(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回警告消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @param data 数据对象
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult warn(String msg, Object data)
|
|
||||||
{
|
|
||||||
return new AjaxResult(HttpStatus.WARN, msg, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @return 错误消息
|
* @return
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error()
|
public static AjaxResult error()
|
||||||
{
|
{
|
||||||
|
|
@ -139,7 +115,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 错误消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(String msg)
|
public static AjaxResult error(String msg)
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +127,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @param data 数据对象
|
* @param data 数据对象
|
||||||
* @return 错误消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(String msg, Object data)
|
public static AjaxResult error(String msg, Object data)
|
||||||
{
|
{
|
||||||
|
|
@ -163,54 +139,10 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
*
|
*
|
||||||
* @param code 状态码
|
* @param code 状态码
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 错误消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(int code, String msg)
|
public static AjaxResult error(int code, String msg)
|
||||||
{
|
{
|
||||||
return new AjaxResult(code, msg, null);
|
return new AjaxResult(code, msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为成功消息
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean isSuccess()
|
|
||||||
{
|
|
||||||
return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为警告消息
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean isWarn()
|
|
||||||
{
|
|
||||||
return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为错误消息
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean isError()
|
|
||||||
{
|
|
||||||
return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 方便链式调用
|
|
||||||
*
|
|
||||||
* @param key 键
|
|
||||||
* @param value 值
|
|
||||||
* @return 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AjaxResult put(String key, Object value)
|
|
||||||
{
|
|
||||||
super.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity基类
|
* Entity基类
|
||||||
|
|
@ -18,7 +17,6 @@ public class BaseEntity implements Serializable
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 搜索值 */
|
/** 搜索值 */
|
||||||
@JsonIgnore
|
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
/** 创建者 */
|
/** 创建者 */
|
||||||
|
|
@ -38,8 +36,15 @@ public class BaseEntity implements Serializable
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/** 开始时间 */
|
||||||
|
@JsonIgnore
|
||||||
|
private String beginTime;
|
||||||
|
|
||||||
|
/** 结束时间 */
|
||||||
|
@JsonIgnore
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
/** 请求参数 */
|
/** 请求参数 */
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
public String getSearchValue()
|
public String getSearchValue()
|
||||||
|
|
@ -102,6 +107,26 @@ public class BaseEntity implements Serializable
|
||||||
this.remark = remark;
|
this.remark = remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBeginTime()
|
||||||
|
{
|
||||||
|
return beginTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeginTime(String beginTime)
|
||||||
|
{
|
||||||
|
this.beginTime = beginTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndTime()
|
||||||
|
{
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(String endTime)
|
||||||
|
{
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Object> getParams()
|
public Map<String, Object> getParams()
|
||||||
{
|
{
|
||||||
if (params == null)
|
if (params == null)
|
||||||
|
|
|
||||||
|
|
@ -1,115 +0,0 @@
|
||||||
package com.ruoyi.common.core.domain;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import com.ruoyi.common.constant.HttpStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应信息主体
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class R<T> implements Serializable
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 成功 */
|
|
||||||
public static final int SUCCESS = HttpStatus.SUCCESS;
|
|
||||||
|
|
||||||
/** 失败 */
|
|
||||||
public static final int FAIL = HttpStatus.ERROR;
|
|
||||||
|
|
||||||
private int code;
|
|
||||||
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
public static <T> R<T> ok()
|
|
||||||
{
|
|
||||||
return restResult(null, SUCCESS, "操作成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(T data)
|
|
||||||
{
|
|
||||||
return restResult(data, SUCCESS, "操作成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> ok(T data, String msg)
|
|
||||||
{
|
|
||||||
return restResult(data, SUCCESS, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail()
|
|
||||||
{
|
|
||||||
return restResult(null, FAIL, "操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(String msg)
|
|
||||||
{
|
|
||||||
return restResult(null, FAIL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(T data)
|
|
||||||
{
|
|
||||||
return restResult(data, FAIL, "操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(T data, String msg)
|
|
||||||
{
|
|
||||||
return restResult(data, FAIL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> R<T> fail(int code, String msg)
|
|
||||||
{
|
|
||||||
return restResult(null, code, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> R<T> restResult(T data, int code, String msg)
|
|
||||||
{
|
|
||||||
R<T> apiResult = new R<>();
|
|
||||||
apiResult.setCode(code);
|
|
||||||
apiResult.setData(data);
|
|
||||||
apiResult.setMsg(msg);
|
|
||||||
return apiResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getData()
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(T data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Boolean isError(R<T> ret)
|
|
||||||
{
|
|
||||||
return !isSuccess(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Boolean isSuccess(R<T> ret)
|
|
||||||
{
|
|
||||||
return R.SUCCESS == ret.getCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,10 +4,8 @@ import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Treeselect树结构实体类
|
* Treeselect树结构实体类
|
||||||
|
|
@ -24,9 +22,6 @@ public class TreeSelect implements Serializable
|
||||||
/** 节点名称 */
|
/** 节点名称 */
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
/** 节点禁用 */
|
|
||||||
private boolean disabled = false;
|
|
||||||
|
|
||||||
/** 子节点 */
|
/** 子节点 */
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
private List<TreeSelect> children;
|
private List<TreeSelect> children;
|
||||||
|
|
@ -40,7 +35,6 @@ public class TreeSelect implements Serializable
|
||||||
{
|
{
|
||||||
this.id = dept.getDeptId();
|
this.id = dept.getDeptId();
|
||||||
this.label = dept.getDeptName();
|
this.label = dept.getDeptName();
|
||||||
this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
|
|
||||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,16 +65,6 @@ public class TreeSelect implements Serializable
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisabled()
|
|
||||||
{
|
|
||||||
return disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisabled(boolean disabled)
|
|
||||||
{
|
|
||||||
this.disabled = disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TreeSelect> getChildren()
|
public List<TreeSelect> getChildren()
|
||||||
{
|
{
|
||||||
return children;
|
return children;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
@ -32,7 +31,7 @@ public class SysDept extends BaseEntity
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
/** 显示顺序 */
|
/** 显示顺序 */
|
||||||
private Integer orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
/** 负责人 */
|
/** 负责人 */
|
||||||
private String leader;
|
private String leader;
|
||||||
|
|
@ -97,13 +96,13 @@ public class SysDept extends BaseEntity
|
||||||
this.deptName = deptName;
|
this.deptName = deptName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
public Integer getOrderNum()
|
public String getOrderNum()
|
||||||
{
|
{
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNum(Integer orderNum)
|
public void setOrderNum(String orderNum)
|
||||||
{
|
{
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ public class SysDictData extends BaseEntity
|
||||||
|
|
||||||
public boolean getDefault()
|
public boolean getDefault()
|
||||||
{
|
{
|
||||||
return UserConstants.YES.equals(this.isDefault);
|
return UserConstants.YES.equals(this.isDefault) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsDefault()
|
public String getIsDefault()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.common.core.domain.entity;
|
package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
@ -58,7 +57,6 @@ public class SysDictType extends BaseEntity
|
||||||
|
|
||||||
@NotBlank(message = "字典类型不能为空")
|
@NotBlank(message = "字典类型不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||||
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
|
|
||||||
public String getDictType()
|
public String getDictType()
|
||||||
{
|
{
|
||||||
return dictType;
|
return dictType;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.ruoyi.common.core.domain.entity;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
@ -31,7 +30,7 @@ public class SysMenu extends BaseEntity
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/** 显示顺序 */
|
/** 显示顺序 */
|
||||||
private Integer orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
/** 路由地址 */
|
/** 路由地址 */
|
||||||
private String path;
|
private String path;
|
||||||
|
|
@ -39,12 +38,6 @@ public class SysMenu extends BaseEntity
|
||||||
/** 组件路径 */
|
/** 组件路径 */
|
||||||
private String component;
|
private String component;
|
||||||
|
|
||||||
/** 路由参数 */
|
|
||||||
private String query;
|
|
||||||
|
|
||||||
/** 路由名称,默认和路由地址相同的驼峰格式(注意:因为vue3版本的router会删除名称相同路由,为避免名字的冲突,特殊情况可以自定义) */
|
|
||||||
private String routeName;
|
|
||||||
|
|
||||||
/** 是否为外链(0是 1否) */
|
/** 是否为外链(0是 1否) */
|
||||||
private String isFrame;
|
private String isFrame;
|
||||||
|
|
||||||
|
|
@ -56,8 +49,8 @@ public class SysMenu extends BaseEntity
|
||||||
|
|
||||||
/** 显示状态(0显示 1隐藏) */
|
/** 显示状态(0显示 1隐藏) */
|
||||||
private String visible;
|
private String visible;
|
||||||
|
|
||||||
/** 菜单状态(0正常 1停用) */
|
/** 菜单状态(0显示 1隐藏) */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 权限字符串 */
|
/** 权限字符串 */
|
||||||
|
|
@ -111,13 +104,13 @@ public class SysMenu extends BaseEntity
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
public Integer getOrderNum()
|
public String getOrderNum()
|
||||||
{
|
{
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNum(Integer orderNum)
|
public void setOrderNum(String orderNum)
|
||||||
{
|
{
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
}
|
}
|
||||||
|
|
@ -144,26 +137,6 @@ public class SysMenu extends BaseEntity
|
||||||
this.component = component;
|
this.component = component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getQuery()
|
|
||||||
{
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuery(String query)
|
|
||||||
{
|
|
||||||
this.query = query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRouteName()
|
|
||||||
{
|
|
||||||
return routeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRouteName(String routeName)
|
|
||||||
{
|
|
||||||
this.routeName = routeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsFrame()
|
public String getIsFrame()
|
||||||
{
|
{
|
||||||
return isFrame;
|
return isFrame;
|
||||||
|
|
@ -245,7 +218,7 @@ public class SysMenu extends BaseEntity
|
||||||
{
|
{
|
||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
@ -255,8 +228,6 @@ public class SysMenu extends BaseEntity
|
||||||
.append("orderNum", getOrderNum())
|
.append("orderNum", getOrderNum())
|
||||||
.append("path", getPath())
|
.append("path", getPath())
|
||||||
.append("component", getComponent())
|
.append("component", getComponent())
|
||||||
.append("query", getQuery())
|
|
||||||
.append("routeName", getRouteName())
|
|
||||||
.append("isFrame", getIsFrame())
|
.append("isFrame", getIsFrame())
|
||||||
.append("IsCache", getIsCache())
|
.append("IsCache", getIsCache())
|
||||||
.append("menuType", getMenuType())
|
.append("menuType", getMenuType())
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.ruoyi.common.core.domain.entity;
|
package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
@ -33,10 +31,10 @@ public class SysRole extends BaseEntity
|
||||||
|
|
||||||
/** 角色排序 */
|
/** 角色排序 */
|
||||||
@Excel(name = "角色排序")
|
@Excel(name = "角色排序")
|
||||||
private Integer roleSort;
|
private String roleSort;
|
||||||
|
|
||||||
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */
|
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */
|
||||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
||||||
private String dataScope;
|
private String dataScope;
|
||||||
|
|
||||||
/** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
|
/** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
|
||||||
|
|
@ -61,9 +59,6 @@ public class SysRole extends BaseEntity
|
||||||
/** 部门组(数据权限) */
|
/** 部门组(数据权限) */
|
||||||
private Long[] deptIds;
|
private Long[] deptIds;
|
||||||
|
|
||||||
/** 角色菜单权限 */
|
|
||||||
private Set<String> permissions;
|
|
||||||
|
|
||||||
public SysRole()
|
public SysRole()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -118,13 +113,13 @@ public class SysRole extends BaseEntity
|
||||||
this.roleKey = roleKey;
|
this.roleKey = roleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
public Integer getRoleSort()
|
public String getRoleSort()
|
||||||
{
|
{
|
||||||
return roleSort;
|
return roleSort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleSort(Integer roleSort)
|
public void setRoleSort(String roleSort)
|
||||||
{
|
{
|
||||||
this.roleSort = roleSort;
|
this.roleSort = roleSort;
|
||||||
}
|
}
|
||||||
|
|
@ -208,17 +203,7 @@ public class SysRole extends BaseEntity
|
||||||
{
|
{
|
||||||
this.deptIds = deptIds;
|
this.deptIds = deptIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPermissions()
|
|
||||||
{
|
|
||||||
return permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPermissions(Set<String> permissions)
|
|
||||||
{
|
|
||||||
this.permissions = permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,18 @@ package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.Email;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
import com.ruoyi.common.annotation.Excel.ColumnType;
|
||||||
import com.ruoyi.common.annotation.Excel.Type;
|
import com.ruoyi.common.annotation.Excel.Type;
|
||||||
import com.ruoyi.common.annotation.Excels;
|
import com.ruoyi.common.annotation.Excels;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.common.xss.Xss;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户对象 sys_user
|
* 用户对象 sys_user
|
||||||
|
|
@ -24,7 +25,7 @@ public class SysUser extends BaseEntity
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
@Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/** 部门ID */
|
/** 部门ID */
|
||||||
|
|
@ -44,7 +45,7 @@ public class SysUser extends BaseEntity
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/** 手机号码 */
|
/** 手机号码 */
|
||||||
@Excel(name = "手机号码", cellType = ColumnType.TEXT)
|
@Excel(name = "手机号码")
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
/** 用户性别 */
|
/** 用户性别 */
|
||||||
|
|
@ -57,8 +58,11 @@ public class SysUser extends BaseEntity
|
||||||
/** 密码 */
|
/** 密码 */
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/** 账号状态(0正常 1停用) */
|
/** 盐加密 */
|
||||||
@Excel(name = "账号状态", readConverterExp = "0=正常,1=停用")
|
private String salt;
|
||||||
|
|
||||||
|
/** 帐号状态(0正常 1停用) */
|
||||||
|
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 删除标志(0代表存在 2代表删除) */
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
|
|
@ -72,9 +76,6 @@ public class SysUser extends BaseEntity
|
||||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
/** 密码最后更新时间 */
|
|
||||||
private Date pwdUpdateDate;
|
|
||||||
|
|
||||||
/** 部门对象 */
|
/** 部门对象 */
|
||||||
@Excels({
|
@Excels({
|
||||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||||
|
|
@ -91,9 +92,6 @@ public class SysUser extends BaseEntity
|
||||||
/** 岗位组 */
|
/** 岗位组 */
|
||||||
private Long[] postIds;
|
private Long[] postIds;
|
||||||
|
|
||||||
/** 角色ID */
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
public SysUser()
|
public SysUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -116,7 +114,12 @@ public class SysUser extends BaseEntity
|
||||||
|
|
||||||
public boolean isAdmin()
|
public boolean isAdmin()
|
||||||
{
|
{
|
||||||
return SecurityUtils.isAdmin(this.userId);
|
return isAdmin(this.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAdmin(Long userId)
|
||||||
|
{
|
||||||
|
return userId != null && 1L == userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDeptId()
|
public Long getDeptId()
|
||||||
|
|
@ -129,7 +132,6 @@ public class SysUser extends BaseEntity
|
||||||
this.deptId = deptId;
|
this.deptId = deptId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Xss(message = "用户昵称不能包含脚本字符")
|
|
||||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||||
public String getNickName()
|
public String getNickName()
|
||||||
{
|
{
|
||||||
|
|
@ -141,7 +143,6 @@ public class SysUser extends BaseEntity
|
||||||
this.nickName = nickName;
|
this.nickName = nickName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Xss(message = "用户账号不能包含脚本字符")
|
|
||||||
@NotBlank(message = "用户账号不能为空")
|
@NotBlank(message = "用户账号不能为空")
|
||||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||||
public String getUserName()
|
public String getUserName()
|
||||||
|
|
@ -197,7 +198,8 @@ public class SysUser extends BaseEntity
|
||||||
this.avatar = avatar;
|
this.avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
@JsonIgnore
|
||||||
|
@JsonProperty
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
return password;
|
return password;
|
||||||
|
|
@ -208,6 +210,16 @@ public class SysUser extends BaseEntity
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSalt()
|
||||||
|
{
|
||||||
|
return salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSalt(String salt)
|
||||||
|
{
|
||||||
|
this.salt = salt;
|
||||||
|
}
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
|
|
@ -248,16 +260,6 @@ public class SysUser extends BaseEntity
|
||||||
this.loginDate = loginDate;
|
this.loginDate = loginDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getPwdUpdateDate()
|
|
||||||
{
|
|
||||||
return pwdUpdateDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPwdUpdateDate(Date pwdUpdateDate)
|
|
||||||
{
|
|
||||||
this.pwdUpdateDate = pwdUpdateDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SysDept getDept()
|
public SysDept getDept()
|
||||||
{
|
{
|
||||||
return dept;
|
return dept;
|
||||||
|
|
@ -298,16 +300,6 @@ public class SysUser extends BaseEntity
|
||||||
this.postIds = postIds;
|
this.postIds = postIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getRoleId()
|
|
||||||
{
|
|
||||||
return roleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRoleId(Long roleId)
|
|
||||||
{
|
|
||||||
this.roleId = roleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
@ -320,11 +312,11 @@ public class SysUser extends BaseEntity
|
||||||
.append("sex", getSex())
|
.append("sex", getSex())
|
||||||
.append("avatar", getAvatar())
|
.append("avatar", getAvatar())
|
||||||
.append("password", getPassword())
|
.append("password", getPassword())
|
||||||
|
.append("salt", getSalt())
|
||||||
.append("status", getStatus())
|
.append("status", getStatus())
|
||||||
.append("delFlag", getDelFlag())
|
.append("delFlag", getDelFlag())
|
||||||
.append("loginIp", getLoginIp())
|
.append("loginIp", getLoginIp())
|
||||||
.append("loginDate", getLoginDate())
|
.append("loginDate", getLoginDate())
|
||||||
.append("pwdUpdateDate", getPwdUpdateDate())
|
|
||||||
.append("createBy", getCreateBy())
|
.append("createBy", getCreateBy())
|
||||||
.append("createTime", getCreateTime())
|
.append("createTime", getCreateTime())
|
||||||
.append("updateBy", getUpdateBy())
|
.append("updateBy", getUpdateBy())
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class LoginBody
|
||||||
/**
|
/**
|
||||||
* 唯一标识
|
* 唯一标识
|
||||||
*/
|
*/
|
||||||
private String uuid;
|
private String uuid = "";
|
||||||
|
|
||||||
public String getUsername()
|
public String getUsername()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package com.ruoyi.common.core.domain.model;
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录用户身份权限
|
* 登录用户身份权限
|
||||||
|
|
@ -16,16 +16,6 @@ public class LoginUser implements UserDetails
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户唯一标识
|
* 用户唯一标识
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,44 +61,6 @@ public class LoginUser implements UserDetails
|
||||||
*/
|
*/
|
||||||
private SysUser user;
|
private SysUser user;
|
||||||
|
|
||||||
public LoginUser()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoginUser(SysUser user, Set<String> permissions)
|
|
||||||
{
|
|
||||||
this.user = user;
|
|
||||||
this.permissions = permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
|
|
||||||
{
|
|
||||||
this.userId = userId;
|
|
||||||
this.deptId = deptId;
|
|
||||||
this.user = user;
|
|
||||||
this.permissions = permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getUserId()
|
|
||||||
{
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserId(Long userId)
|
|
||||||
{
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getDeptId()
|
|
||||||
{
|
|
||||||
return deptId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeptId(Long deptId)
|
|
||||||
{
|
|
||||||
this.deptId = deptId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToken()
|
public String getToken()
|
||||||
{
|
{
|
||||||
return token;
|
return token;
|
||||||
|
|
@ -119,7 +71,17 @@ public class LoginUser implements UserDetails
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
public LoginUser()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoginUser(SysUser user, Set<String> permissions)
|
||||||
|
{
|
||||||
|
this.user = user;
|
||||||
|
this.permissions = permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
|
|
@ -135,7 +97,7 @@ public class LoginUser implements UserDetails
|
||||||
/**
|
/**
|
||||||
* 账户是否未过期,过期无法验证
|
* 账户是否未过期,过期无法验证
|
||||||
*/
|
*/
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public boolean isAccountNonExpired()
|
public boolean isAccountNonExpired()
|
||||||
{
|
{
|
||||||
|
|
@ -147,7 +109,7 @@ public class LoginUser implements UserDetails
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public boolean isAccountNonLocked()
|
public boolean isAccountNonLocked()
|
||||||
{
|
{
|
||||||
|
|
@ -159,7 +121,7 @@ public class LoginUser implements UserDetails
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public boolean isCredentialsNonExpired()
|
public boolean isCredentialsNonExpired()
|
||||||
{
|
{
|
||||||
|
|
@ -171,7 +133,7 @@ public class LoginUser implements UserDetails
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
package com.ruoyi.common.core.domain.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户注册对象
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class RegisterBody extends LoginBody
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,101 +1,72 @@
|
||||||
package com.ruoyi.common.core.page;
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页数据
|
* 分页数据
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class PageDomain
|
public class PageDomain
|
||||||
{
|
{
|
||||||
/** 当前记录起始索引 */
|
/** 当前记录起始索引 */
|
||||||
private Integer pageNum;
|
private Integer pageNum;
|
||||||
|
|
||||||
/** 每页显示记录数 */
|
/** 每页显示记录数 */
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
/** 排序列 */
|
/** 排序列 */
|
||||||
private String orderByColumn;
|
private String orderByColumn;
|
||||||
|
|
||||||
/** 排序的方向desc或者asc */
|
/** 排序的方向desc或者asc */
|
||||||
private String isAsc = "asc";
|
private String isAsc = "asc";
|
||||||
|
|
||||||
/** 分页参数合理化 */
|
public String getOrderBy()
|
||||||
private Boolean reasonable = true;
|
{
|
||||||
|
if (StringUtils.isEmpty(orderByColumn))
|
||||||
public String getOrderBy()
|
{
|
||||||
{
|
return "";
|
||||||
if (StringUtils.isEmpty(orderByColumn))
|
}
|
||||||
{
|
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||||
return "";
|
}
|
||||||
}
|
|
||||||
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
public Integer getPageNum()
|
||||||
}
|
{
|
||||||
|
return pageNum;
|
||||||
public Integer getPageNum()
|
}
|
||||||
{
|
|
||||||
return pageNum;
|
public void setPageNum(Integer pageNum)
|
||||||
}
|
{
|
||||||
|
this.pageNum = pageNum;
|
||||||
public void setPageNum(Integer pageNum)
|
}
|
||||||
{
|
|
||||||
this.pageNum = pageNum;
|
public Integer getPageSize()
|
||||||
}
|
{
|
||||||
|
return pageSize;
|
||||||
public Integer getPageSize()
|
}
|
||||||
{
|
|
||||||
return pageSize;
|
public void setPageSize(Integer pageSize)
|
||||||
}
|
{
|
||||||
|
this.pageSize = pageSize;
|
||||||
public void setPageSize(Integer pageSize)
|
}
|
||||||
{
|
|
||||||
this.pageSize = pageSize;
|
public String getOrderByColumn()
|
||||||
}
|
{
|
||||||
|
return orderByColumn;
|
||||||
public String getOrderByColumn()
|
}
|
||||||
{
|
|
||||||
return orderByColumn;
|
public void setOrderByColumn(String orderByColumn)
|
||||||
}
|
{
|
||||||
|
this.orderByColumn = orderByColumn;
|
||||||
public void setOrderByColumn(String orderByColumn)
|
}
|
||||||
{
|
|
||||||
this.orderByColumn = orderByColumn;
|
public String getIsAsc()
|
||||||
}
|
{
|
||||||
|
return isAsc;
|
||||||
public String getIsAsc()
|
}
|
||||||
{
|
|
||||||
return isAsc;
|
public void setIsAsc(String isAsc)
|
||||||
}
|
{
|
||||||
|
this.isAsc = isAsc;
|
||||||
public void setIsAsc(String isAsc)
|
}
|
||||||
{
|
}
|
||||||
if (StringUtils.isNotEmpty(isAsc))
|
|
||||||
{
|
|
||||||
// 兼容前端排序类型
|
|
||||||
if ("ascending".equals(isAsc))
|
|
||||||
{
|
|
||||||
isAsc = "asc";
|
|
||||||
}
|
|
||||||
else if ("descending".equals(isAsc))
|
|
||||||
{
|
|
||||||
isAsc = "desc";
|
|
||||||
}
|
|
||||||
this.isAsc = isAsc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getReasonable()
|
|
||||||
{
|
|
||||||
if (StringUtils.isNull(reasonable))
|
|
||||||
{
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return reasonable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReasonable(Boolean reasonable)
|
|
||||||
{
|
|
||||||
this.reasonable = reasonable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class TableDataInfo implements Serializable
|
||||||
* @param list 列表数据
|
* @param list 列表数据
|
||||||
* @param total 总记录数
|
* @param total 总记录数
|
||||||
*/
|
*/
|
||||||
public TableDataInfo(List<?> list, long total)
|
public TableDataInfo(List<?> list, int total)
|
||||||
{
|
{
|
||||||
this.rows = list;
|
this.rows = list;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ruoyi.common.core.page;
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,22 +29,16 @@ public class TableSupport
|
||||||
*/
|
*/
|
||||||
public static final String IS_ASC = "isAsc";
|
public static final String IS_ASC = "isAsc";
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页参数合理化
|
|
||||||
*/
|
|
||||||
public static final String REASONABLE = "reasonable";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 封装分页对象
|
* 封装分页对象
|
||||||
*/
|
*/
|
||||||
public static PageDomain getPageDomain()
|
public static PageDomain getPageDomain()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = new PageDomain();
|
PageDomain pageDomain = new PageDomain();
|
||||||
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
|
pageDomain.setPageNum(ServletUtils.getParameterToInt(PAGE_NUM));
|
||||||
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
|
pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE));
|
||||||
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
|
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
|
||||||
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
|
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
|
||||||
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
|
|
||||||
return pageDomain;
|
return pageDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
package com.ruoyi.common.core.redis;
|
package com.ruoyi.common.core.redis;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.BoundSetOperations;
|
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
|
|
@ -74,28 +72,6 @@ public class RedisCache
|
||||||
return redisTemplate.expire(key, timeout, unit);
|
return redisTemplate.expire(key, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取有效时间
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @return 有效时间
|
|
||||||
*/
|
|
||||||
public long getExpire(final String key)
|
|
||||||
{
|
|
||||||
return redisTemplate.getExpire(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断 key是否存在
|
|
||||||
*
|
|
||||||
* @param key 键
|
|
||||||
* @return true 存在 false不存在
|
|
||||||
*/
|
|
||||||
public Boolean hasKey(String key)
|
|
||||||
{
|
|
||||||
return redisTemplate.hasKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的基本对象。
|
* 获得缓存的基本对象。
|
||||||
*
|
*
|
||||||
|
|
@ -124,9 +100,9 @@ public class RedisCache
|
||||||
* @param collection 多个对象
|
* @param collection 多个对象
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final Collection collection)
|
public long deleteObject(final Collection collection)
|
||||||
{
|
{
|
||||||
return redisTemplate.delete(collection) > 0;
|
return redisTemplate.delete(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -160,15 +136,10 @@ public class RedisCache
|
||||||
* @param dataSet 缓存的数据
|
* @param dataSet 缓存的数据
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
public <T> long setCacheSet(final String key, final Set<T> dataSet)
|
||||||
{
|
{
|
||||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
Long count = redisTemplate.opsForSet().add(key, dataSet);
|
||||||
Iterator<T> it = dataSet.iterator();
|
return count == null ? 0 : count;
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
setOperation.add(it.next());
|
|
||||||
}
|
|
||||||
return setOperation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -243,18 +214,6 @@ public class RedisCache
|
||||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除Hash中的某条数据
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @param hKey Hash键
|
|
||||||
* @return 是否成功
|
|
||||||
*/
|
|
||||||
public boolean deleteCacheMapValue(final String key, final String hKey)
|
|
||||||
{
|
|
||||||
return redisTemplate.opsForHash().delete(key, hKey) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的基本对象列表
|
* 获得缓存的基本对象列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class CharsetKit
|
||||||
|
|
||||||
if (null == destCharset)
|
if (null == destCharset)
|
||||||
{
|
{
|
||||||
destCharset = StandardCharsets.UTF_8;
|
srcCharset = StandardCharsets.UTF_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.ruoyi.common.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;
|
||||||
|
|
@ -11,7 +10,7 @@ import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型转换器
|
* 类型转换器
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Convert
|
public class Convert
|
||||||
|
|
@ -20,7 +19,7 @@ public class Convert
|
||||||
* 转换为字符串<br>
|
* 转换为字符串<br>
|
||||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -42,7 +41,7 @@ public class Convert
|
||||||
* 转换为字符串<br>
|
* 转换为字符串<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,7 +54,7 @@ public class Convert
|
||||||
* 转换为字符<br>
|
* 转换为字符<br>
|
||||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -79,7 +78,7 @@ public class Convert
|
||||||
* 转换为字符<br>
|
* 转换为字符<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -92,7 +91,7 @@ public class Convert
|
||||||
* 转换为byte<br>
|
* 转换为byte<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -130,7 +129,7 @@ public class Convert
|
||||||
* 转换为byte<br>
|
* 转换为byte<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -143,7 +142,7 @@ public class Convert
|
||||||
* 转换为Short<br>
|
* 转换为Short<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -181,7 +180,7 @@ public class Convert
|
||||||
* 转换为Short<br>
|
* 转换为Short<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -194,7 +193,7 @@ public class Convert
|
||||||
* 转换为Number<br>
|
* 转换为Number<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -228,7 +227,7 @@ public class Convert
|
||||||
* 转换为Number<br>
|
* 转换为Number<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -241,7 +240,7 @@ public class Convert
|
||||||
* 转换为int<br>
|
* 转换为int<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -279,7 +278,7 @@ public class Convert
|
||||||
* 转换为int<br>
|
* 转换为int<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -290,7 +289,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -301,7 +300,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Long数组<br>
|
* 转换为Long数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -312,7 +311,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param split 被转换的值
|
* @param split 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -335,7 +334,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Long数组<br>
|
* 转换为Long数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -358,22 +357,18 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为String数组<br>
|
* 转换为String数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String[] toStrArray(String str)
|
public static String[] toStrArray(String str)
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(str))
|
|
||||||
{
|
|
||||||
return new String[] {};
|
|
||||||
}
|
|
||||||
return toStrArray(",", str);
|
return toStrArray(",", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为String数组<br>
|
* 转换为String数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param split 被转换的值
|
* @param split 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -387,7 +382,7 @@ public class Convert
|
||||||
* 转换为long<br>
|
* 转换为long<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -426,7 +421,7 @@ public class Convert
|
||||||
* 转换为long<br>
|
* 转换为long<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -439,7 +434,7 @@ public class Convert
|
||||||
* 转换为double<br>
|
* 转换为double<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -478,7 +473,7 @@ public class Convert
|
||||||
* 转换为double<br>
|
* 转换为double<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -491,7 +486,7 @@ public class Convert
|
||||||
* 转换为Float<br>
|
* 转换为Float<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -529,7 +524,7 @@ public class Convert
|
||||||
* 转换为Float<br>
|
* 转换为Float<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -540,9 +535,9 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为boolean<br>
|
* 转换为boolean<br>
|
||||||
* String支持的值为:true、false、yes、ok、no、1、0、是、否, 如果给定的值为空,或者转换失败,返回默认值<br>
|
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -566,15 +561,18 @@ public class Convert
|
||||||
switch (valueStr)
|
switch (valueStr)
|
||||||
{
|
{
|
||||||
case "true":
|
case "true":
|
||||||
case "yes":
|
|
||||||
case "ok":
|
|
||||||
case "1":
|
|
||||||
case "是":
|
|
||||||
return true;
|
return true;
|
||||||
case "false":
|
case "false":
|
||||||
|
return false;
|
||||||
|
case "yes":
|
||||||
|
return true;
|
||||||
|
case "ok":
|
||||||
|
return true;
|
||||||
case "no":
|
case "no":
|
||||||
|
return false;
|
||||||
|
case "1":
|
||||||
|
return true;
|
||||||
case "0":
|
case "0":
|
||||||
case "否":
|
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
@ -585,7 +583,7 @@ public class Convert
|
||||||
* 转换为boolean<br>
|
* 转换为boolean<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -597,7 +595,7 @@ public class Convert
|
||||||
/**
|
/**
|
||||||
* 转换为Enum对象<br>
|
* 转换为Enum对象<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
*
|
*
|
||||||
* @param clazz Enum的Class
|
* @param clazz Enum的Class
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @param defaultValue 默认值
|
* @param defaultValue 默认值
|
||||||
|
|
@ -633,7 +631,7 @@ public class Convert
|
||||||
/**
|
/**
|
||||||
* 转换为Enum对象<br>
|
* 转换为Enum对象<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
*
|
*
|
||||||
* @param clazz Enum的Class
|
* @param clazz Enum的Class
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @return Enum
|
* @return Enum
|
||||||
|
|
@ -647,7 +645,7 @@ public class Convert
|
||||||
* 转换为BigInteger<br>
|
* 转换为BigInteger<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -685,7 +683,7 @@ public class Convert
|
||||||
* 转换为BigInteger<br>
|
* 转换为BigInteger<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -698,7 +696,7 @@ public class Convert
|
||||||
* 转换为BigDecimal<br>
|
* 转换为BigDecimal<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
@ -719,7 +717,7 @@ public class Convert
|
||||||
}
|
}
|
||||||
if (value instanceof Double)
|
if (value instanceof Double)
|
||||||
{
|
{
|
||||||
return BigDecimal.valueOf((Double) value);
|
return new BigDecimal((Double) value);
|
||||||
}
|
}
|
||||||
if (value instanceof Integer)
|
if (value instanceof Integer)
|
||||||
{
|
{
|
||||||
|
|
@ -744,7 +742,7 @@ public class Convert
|
||||||
* 转换为BigDecimal<br>
|
* 转换为BigDecimal<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -756,7 +754,7 @@ public class Convert
|
||||||
/**
|
/**
|
||||||
* 将对象转为字符串<br>
|
* 将对象转为字符串<br>
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
|
|
@ -768,7 +766,7 @@ public class Convert
|
||||||
/**
|
/**
|
||||||
* 将对象转为字符串<br>
|
* 将对象转为字符串<br>
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @param charsetName 字符集
|
* @param charsetName 字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
|
|
@ -781,7 +779,7 @@ public class Convert
|
||||||
/**
|
/**
|
||||||
* 将对象转为字符串<br>
|
* 将对象转为字符串<br>
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @param charset 字符集
|
* @param charset 字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
|
|
@ -799,21 +797,7 @@ public class Convert
|
||||||
}
|
}
|
||||||
else if (obj instanceof byte[] || obj instanceof Byte[])
|
else if (obj instanceof byte[] || obj instanceof Byte[])
|
||||||
{
|
{
|
||||||
if (obj instanceof byte[])
|
return str((Byte[]) obj, charset);
|
||||||
{
|
|
||||||
return str((byte[]) obj, charset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Byte[] bytes = (Byte[]) obj;
|
|
||||||
int length = bytes.length;
|
|
||||||
byte[] dest = new byte[length];
|
|
||||||
for (int i = 0; i < length; i++)
|
|
||||||
{
|
|
||||||
dest[i] = bytes[i];
|
|
||||||
}
|
|
||||||
return str(dest, charset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (obj instanceof ByteBuffer)
|
else if (obj instanceof ByteBuffer)
|
||||||
{
|
{
|
||||||
|
|
@ -824,7 +808,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将byte数组转为字符串
|
* 将byte数组转为字符串
|
||||||
*
|
*
|
||||||
* @param bytes byte数组
|
* @param bytes byte数组
|
||||||
* @param charset 字符集
|
* @param charset 字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
|
|
@ -836,7 +820,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解码字节码
|
* 解码字节码
|
||||||
*
|
*
|
||||||
* @param data 字符串
|
* @param data 字符串
|
||||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||||
* @return 解码后的字符串
|
* @return 解码后的字符串
|
||||||
|
|
@ -857,7 +841,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将编码的byteBuffer数据转换为字符串
|
* 将编码的byteBuffer数据转换为字符串
|
||||||
*
|
*
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @param charset 字符集,如果为空使用当前系统字符集
|
* @param charset 字符集,如果为空使用当前系统字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
|
|
@ -874,7 +858,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将编码的byteBuffer数据转换为字符串
|
* 将编码的byteBuffer数据转换为字符串
|
||||||
*
|
*
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @param charset 字符集,如果为空使用当前系统字符集
|
* @param charset 字符集,如果为空使用当前系统字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
|
|
@ -891,7 +875,7 @@ public class Convert
|
||||||
// ----------------------------------------------------------------------- 全角半角转换
|
// ----------------------------------------------------------------------- 全角半角转换
|
||||||
/**
|
/**
|
||||||
* 半角转全角
|
* 半角转全角
|
||||||
*
|
*
|
||||||
* @param input String.
|
* @param input String.
|
||||||
* @return 全角字符串.
|
* @return 全角字符串.
|
||||||
*/
|
*/
|
||||||
|
|
@ -902,14 +886,14 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 半角转全角
|
* 半角转全角
|
||||||
*
|
*
|
||||||
* @param input String
|
* @param input String
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
* @return 全角字符串.
|
* @return 全角字符串.
|
||||||
*/
|
*/
|
||||||
public static String toSBC(String input, Set<Character> notConvertSet)
|
public static String toSBC(String input, Set<Character> notConvertSet)
|
||||||
{
|
{
|
||||||
char[] c = input.toCharArray();
|
char c[] = input.toCharArray();
|
||||||
for (int i = 0; i < c.length; i++)
|
for (int i = 0; i < c.length; i++)
|
||||||
{
|
{
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
||||||
|
|
@ -933,7 +917,7 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全角转半角
|
* 全角转半角
|
||||||
*
|
*
|
||||||
* @param input String.
|
* @param input String.
|
||||||
* @return 半角字符串
|
* @return 半角字符串
|
||||||
*/
|
*/
|
||||||
|
|
@ -944,14 +928,14 @@ public class Convert
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换全角为半角
|
* 替换全角为半角
|
||||||
*
|
*
|
||||||
* @param text 文本
|
* @param text 文本
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
* @return 替换后的字符
|
* @return 替换后的字符
|
||||||
*/
|
*/
|
||||||
public static String toDBC(String text, Set<Character> notConvertSet)
|
public static String toDBC(String text, Set<Character> notConvertSet)
|
||||||
{
|
{
|
||||||
char[] c = text.toCharArray();
|
char c[] = text.toCharArray();
|
||||||
for (int i = 0; i < c.length; i++)
|
for (int i = 0; i < c.length; i++)
|
||||||
{
|
{
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
||||||
|
|
@ -969,12 +953,14 @@ public class Convert
|
||||||
c[i] = (char) (c[i] - 65248);
|
c[i] = (char) (c[i] - 65248);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new String(c);
|
String returnString = new String(c);
|
||||||
|
|
||||||
|
return returnString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||||
*
|
*
|
||||||
* @param n 数字
|
* @param n 数字
|
||||||
* @return 中文大写数字
|
* @return 中文大写数字
|
||||||
*/
|
*/
|
||||||
|
|
@ -990,12 +976,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,59 +0,0 @@
|
||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
import com.ruoyi.common.utils.DesensitizedUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏类型
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public enum DesensitizedType
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 姓名,第2位星号替换
|
|
||||||
*/
|
|
||||||
USERNAME(s -> s.replaceAll("(\\S)\\S(\\S*)", "$1*$2")),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码,全部字符都用*代替
|
|
||||||
*/
|
|
||||||
PASSWORD(DesensitizedUtil::password),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 身份证,中间10位星号替换
|
|
||||||
*/
|
|
||||||
ID_CARD(s -> s.replaceAll("(\\d{4})\\d{10}(\\d{3}[Xx]|\\d{4})", "$1** **** ****$2")),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号,中间4位星号替换
|
|
||||||
*/
|
|
||||||
PHONE(s -> s.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2")),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电子邮箱,仅显示第一个字母和@后面的地址显示,其他星号替换
|
|
||||||
*/
|
|
||||||
EMAIL(s -> s.replaceAll("(^.)[^@]*(@.*$)", "$1****$2")),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 银行卡号,保留最后4位,其他星号替换
|
|
||||||
*/
|
|
||||||
BANK_CARD(s -> s.replaceAll("\\d{15}(\\d{3})", "**** **** **** **** $1")),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车牌号码,包含普通车辆、新能源车辆
|
|
||||||
*/
|
|
||||||
CAR_LICENSE(DesensitizedUtil::carLicense);
|
|
||||||
|
|
||||||
private final Function<String, String> desensitizer;
|
|
||||||
|
|
||||||
DesensitizedType(Function<String, String> desensitizer)
|
|
||||||
{
|
|
||||||
this.desensitizer = desensitizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Function<String, String> desensitizer()
|
|
||||||
{
|
|
||||||
return desensitizer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
package com.ruoyi.common.enums;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流类型
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum LimitType
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 默认策略全局限流
|
|
||||||
*/
|
|
||||||
DEFAULT,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据请求者IP进行限流
|
|
||||||
*/
|
|
||||||
IP
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ruoyi.common.exception.base;
|
package com.ruoyi.common.exception;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.ruoyi.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义异常
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class CustomException extends RuntimeException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public CustomException(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomException(String message, Integer code)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomException(String message, Throwable e)
|
||||||
|
{
|
||||||
|
super(message, e);
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
package com.ruoyi.common.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局异常
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class GlobalException extends RuntimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 错误提示
|
|
||||||
*/
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 错误明细,内部调试错误
|
|
||||||
*
|
|
||||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
package com.ruoyi.common.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务异常
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public final class ServiceException extends RuntimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 错误码
|
|
||||||
*/
|
|
||||||
private Integer code;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 错误提示
|
|
||||||
*/
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 错误明细,内部调试错误
|
|
||||||
*
|
|
||||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
|
||||||
*/
|
|
||||||
private String detailMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 空构造方法,避免反序列化问题
|
|
||||||
*/
|
|
||||||
public ServiceException()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceException(String message)
|
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceException(String message, Integer code)
|
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDetailMessage()
|
|
||||||
{
|
|
||||||
return detailMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCode()
|
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceException setMessage(String message)
|
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceException setDetailMessage(String detailMessage)
|
|
||||||
{
|
|
||||||
this.detailMessage = detailMessage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.common.exception.file;
|
package com.ruoyi.common.exception.file;
|
||||||
|
|
||||||
import com.ruoyi.common.exception.base.BaseException;
|
import com.ruoyi.common.exception.BaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件信息异常类
|
* 文件信息异常类
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
package com.ruoyi.common.exception.file;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传异常类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class FileUploadException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final Throwable cause;
|
|
||||||
|
|
||||||
public FileUploadException()
|
|
||||||
{
|
|
||||||
this(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileUploadException(final String msg)
|
|
||||||
{
|
|
||||||
this(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileUploadException(String msg, Throwable cause)
|
|
||||||
{
|
|
||||||
super(msg);
|
|
||||||
this.cause = cause;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void printStackTrace(PrintStream stream)
|
|
||||||
{
|
|
||||||
super.printStackTrace(stream);
|
|
||||||
if (cause != null)
|
|
||||||
{
|
|
||||||
stream.println("Caused by:");
|
|
||||||
cause.printStackTrace(stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void printStackTrace(PrintWriter writer)
|
|
||||||
{
|
|
||||||
super.printStackTrace(writer);
|
|
||||||
if (cause != null)
|
|
||||||
{
|
|
||||||
writer.println("Caused by:");
|
|
||||||
cause.printStackTrace(writer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Throwable getCause()
|
|
||||||
{
|
|
||||||
return cause;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package com.ruoyi.common.exception.file;
|
package com.ruoyi.common.exception.file;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import org.apache.commons.fileupload.FileUploadException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传无效扩展名异常类
|
* 文件上传 误异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
|
@ -17,7 +18,7 @@ public class InvalidExtensionException extends FileUploadException
|
||||||
|
|
||||||
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
||||||
{
|
{
|
||||||
super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式");
|
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
||||||
this.allowedExtension = allowedExtension;
|
this.allowedExtension = allowedExtension;
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
|
|
@ -67,14 +68,4 @@ public class InvalidExtensionException extends FileUploadException
|
||||||
super(allowedExtension, extension, filename);
|
super(allowedExtension, extension, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InvalidVideoExtensionException extends InvalidExtensionException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
|
|
||||||
{
|
|
||||||
super(allowedExtension, extension, filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package com.ruoyi.common.exception.user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 黑名单IP异常类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class BlackListException extends UserException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public BlackListException()
|
|
||||||
{
|
|
||||||
super("login.blocked", null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
import com.ruoyi.common.exception.base.BaseException;
|
import com.ruoyi.common.exception.BaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息异常类
|
* 用户信息异常类
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package com.ruoyi.common.exception.user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户不存在异常类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class UserNotExistsException extends UserException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public UserNotExistsException()
|
|
||||||
{
|
|
||||||
super("user.not.exists", null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package com.ruoyi.common.exception.user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户错误最大次数异常类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class UserPasswordRetryLimitExceedException extends UserException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime)
|
|
||||||
{
|
|
||||||
super("user.password.retry.limit.exceed", new Object[] { retryLimitCount, lockTime });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package com.ruoyi.common.filter;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排除JSON敏感属性
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class PropertyPreExcludeFilter extends SimplePropertyPreFilter
|
|
||||||
{
|
|
||||||
public PropertyPreExcludeFilter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public PropertyPreExcludeFilter addExcludes(String... filters)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < filters.length; i++)
|
|
||||||
{
|
|
||||||
this.getExcludes().add(filters[i]);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
package com.ruoyi.common.filter;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
import javax.servlet.FilterChain;
|
|
||||||
import javax.servlet.FilterConfig;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.ServletRequest;
|
|
||||||
import javax.servlet.ServletResponse;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 防盗链过滤器
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class RefererFilter implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 允许的域名列表
|
|
||||||
*/
|
|
||||||
public List<String> allowedDomains;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(FilterConfig filterConfig) throws ServletException
|
|
||||||
{
|
|
||||||
String domains = filterConfig.getInitParameter("allowedDomains");
|
|
||||||
this.allowedDomains = Arrays.asList(domains.split(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
|
||||||
throws IOException, ServletException
|
|
||||||
{
|
|
||||||
HttpServletRequest req = (HttpServletRequest) request;
|
|
||||||
HttpServletResponse resp = (HttpServletResponse) response;
|
|
||||||
|
|
||||||
String referer = req.getHeader("Referer");
|
|
||||||
|
|
||||||
// 如果Referer为空,拒绝访问
|
|
||||||
if (referer == null || referer.isEmpty())
|
|
||||||
{
|
|
||||||
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Access denied: Referer header is required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查Referer是否在允许的域名列表中
|
|
||||||
boolean allowed = false;
|
|
||||||
for (String domain : allowedDomains)
|
|
||||||
{
|
|
||||||
if (referer.contains(domain))
|
|
||||||
{
|
|
||||||
allowed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据检查结果决定是否放行
|
|
||||||
if (allowed)
|
|
||||||
{
|
|
||||||
chain.doFilter(request, response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Access denied: Referer '" + referer + "' is not allowed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -29,8 +29,8 @@ public class RepeatableFilter implements Filter
|
||||||
throws IOException, ServletException
|
throws IOException, ServletException
|
||||||
{
|
{
|
||||||
ServletRequest requestWrapper = null;
|
ServletRequest requestWrapper = null;
|
||||||
if (request instanceof HttpServletRequest
|
if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(),
|
||||||
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
|
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
{
|
{
|
||||||
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequestWrapper;
|
import javax.servlet.http.HttpServletRequestWrapper;
|
||||||
import com.ruoyi.common.utils.http.HttpHelper;
|
import com.ruoyi.common.utils.http.HttpHelper;
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建可重复读取inputStream的request
|
* 构建可重复读取inputStream的request
|
||||||
|
|
@ -24,10 +23,10 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
|
||||||
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
|
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
|
||||||
{
|
{
|
||||||
super(request);
|
super(request);
|
||||||
request.setCharacterEncoding(Constants.UTF8);
|
request.setCharacterEncoding("UTF-8");
|
||||||
response.setCharacterEncoding(Constants.UTF8);
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
|
||||||
body = HttpHelper.getBodyString(request).getBytes(Constants.UTF8);
|
body = HttpHelper.getBodyString(request).getBytes("UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -39,21 +38,18 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
|
||||||
@Override
|
@Override
|
||||||
public ServletInputStream getInputStream() throws IOException
|
public ServletInputStream getInputStream() throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
||||||
|
|
||||||
return new ServletInputStream()
|
return new ServletInputStream()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException
|
public int read() throws IOException
|
||||||
{
|
{
|
||||||
return bais.read();
|
return bais.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int available() throws IOException
|
|
||||||
{
|
|
||||||
return body.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished()
|
public boolean isFinished()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.ruoyi.common.filter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.FilterConfig;
|
import javax.servlet.FilterConfig;
|
||||||
|
|
@ -12,7 +14,6 @@ import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.enums.HttpMethod;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防止XSS攻击的过滤器
|
* 防止XSS攻击的过滤器
|
||||||
|
|
@ -26,18 +27,28 @@ public class XssFilter implements Filter
|
||||||
*/
|
*/
|
||||||
public List<String> excludes = new ArrayList<>();
|
public List<String> excludes = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xss过滤开关
|
||||||
|
*/
|
||||||
|
public boolean enabled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(FilterConfig filterConfig) throws ServletException
|
public void init(FilterConfig filterConfig) throws ServletException
|
||||||
{
|
{
|
||||||
String tempExcludes = filterConfig.getInitParameter("excludes");
|
String tempExcludes = filterConfig.getInitParameter("excludes");
|
||||||
|
String tempEnabled = filterConfig.getInitParameter("enabled");
|
||||||
if (StringUtils.isNotEmpty(tempExcludes))
|
if (StringUtils.isNotEmpty(tempExcludes))
|
||||||
{
|
{
|
||||||
String[] urls = tempExcludes.split(",");
|
String[] url = tempExcludes.split(",");
|
||||||
for (String url : urls)
|
for (int i = 0; url != null && i < url.length; i++)
|
||||||
{
|
{
|
||||||
excludes.add(url);
|
excludes.add(url[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotEmpty(tempEnabled))
|
||||||
|
{
|
||||||
|
enabled = Boolean.valueOf(tempEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -57,14 +68,25 @@ public class XssFilter implements Filter
|
||||||
|
|
||||||
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
|
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
|
||||||
{
|
{
|
||||||
String url = request.getServletPath();
|
if (!enabled)
|
||||||
String method = request.getMethod();
|
|
||||||
// GET DELETE 不过滤
|
|
||||||
if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return StringUtils.matches(url, excludes);
|
if (excludes == null || excludes.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String url = request.getServletPath();
|
||||||
|
for (String pattern : excludes)
|
||||||
|
{
|
||||||
|
Pattern p = Pattern.compile("^" + pattern);
|
||||||
|
Matcher m = p.matcher(url);
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,13 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
||||||
if (values != null)
|
if (values != null)
|
||||||
{
|
{
|
||||||
int length = values.length;
|
int length = values.length;
|
||||||
String[] escapesValues = new String[length];
|
String[] escapseValues = new String[length];
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
// 防xss攻击和过滤前后空格
|
// 防xss攻击和过滤前后空格
|
||||||
escapesValues[i] = EscapeUtil.clean(values[i]).trim();
|
escapseValues[i] = EscapeUtil.clean(values[i]).trim();
|
||||||
}
|
}
|
||||||
return escapesValues;
|
return escapseValues;
|
||||||
}
|
}
|
||||||
return super.getParameterValues(name);
|
return super.getParameterValues(name);
|
||||||
}
|
}
|
||||||
|
|
@ -63,8 +63,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
||||||
|
|
||||||
// xss过滤
|
// xss过滤
|
||||||
json = EscapeUtil.clean(json).trim();
|
json = EscapeUtil.clean(json).trim();
|
||||||
byte[] jsonBytes = json.getBytes("utf-8");
|
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
|
||||||
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
|
|
||||||
return new ServletInputStream()
|
return new ServletInputStream()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -79,12 +78,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int available() throws IOException
|
|
||||||
{
|
|
||||||
return jsonBytes.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setReadListener(ReadListener readListener)
|
public void setReadListener(ReadListener readListener)
|
||||||
{
|
{
|
||||||
|
|
@ -106,6 +99,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
||||||
public boolean isJsonRequest()
|
public boolean isJsonRequest()
|
||||||
{
|
{
|
||||||
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
||||||
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
|
return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header)
|
||||||
|
|| MediaType.APPLICATION_JSON_UTF8_VALUE.equalsIgnoreCase(header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,113 +1,114 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确的浮点数运算
|
* 精确的浮点数运算
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Arith
|
public class Arith
|
||||||
{
|
{
|
||||||
|
|
||||||
/** 默认除法运算精度 */
|
/** 默认除法运算精度 */
|
||||||
private static final int DEF_DIV_SCALE = 10;
|
private static final int DEF_DIV_SCALE = 10;
|
||||||
|
|
||||||
/** 这个类不能实例化 */
|
/** 这个类不能实例化 */
|
||||||
private Arith()
|
private Arith()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的加法运算。
|
* 提供精确的加法运算。
|
||||||
* @param v1 被加数
|
* @param v1 被加数
|
||||||
* @param v2 加数
|
* @param v2 加数
|
||||||
* @return 两个参数的和
|
* @return 两个参数的和
|
||||||
*/
|
*/
|
||||||
public static double add(double v1, double v2)
|
public static double add(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.add(b2).doubleValue();
|
return b1.add(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的减法运算。
|
* 提供精确的减法运算。
|
||||||
* @param v1 被减数
|
* @param v1 被减数
|
||||||
* @param v2 减数
|
* @param v2 减数
|
||||||
* @return 两个参数的差
|
* @return 两个参数的差
|
||||||
*/
|
*/
|
||||||
public static double sub(double v1, double v2)
|
public static double sub(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.subtract(b2).doubleValue();
|
return b1.subtract(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的乘法运算。
|
* 提供精确的乘法运算。
|
||||||
* @param v1 被乘数
|
* @param v1 被乘数
|
||||||
* @param v2 乘数
|
* @param v2 乘数
|
||||||
* @return 两个参数的积
|
* @return 两个参数的积
|
||||||
*/
|
*/
|
||||||
public static double mul(double v1, double v2)
|
public static double mul(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.multiply(b2).doubleValue();
|
return b1.multiply(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
||||||
* 小数点以后10位,以后的数字四舍五入。
|
* 小数点以后10位,以后的数字四舍五入。
|
||||||
* @param v1 被除数
|
* @param v1 被除数
|
||||||
* @param v2 除数
|
* @param v2 除数
|
||||||
* @return 两个参数的商
|
* @return 两个参数的商
|
||||||
*/
|
*/
|
||||||
public static double div(double v1, double v2)
|
public static double div(double v1, double v2)
|
||||||
{
|
{
|
||||||
return div(v1, v2, DEF_DIV_SCALE);
|
return div(v1, v2, DEF_DIV_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
||||||
* 定精度,以后的数字四舍五入。
|
* 定精度,以后的数字四舍五入。
|
||||||
* @param v1 被除数
|
* @param v1 被除数
|
||||||
* @param v2 除数
|
* @param v2 除数
|
||||||
* @param scale 表示表示需要精确到小数点以后几位。
|
* @param scale 表示表示需要精确到小数点以后几位。
|
||||||
* @return 两个参数的商
|
* @return 两个参数的商
|
||||||
*/
|
*/
|
||||||
public static double div(double v1, double v2, int scale)
|
public static double div(double v1, double v2, int scale)
|
||||||
{
|
{
|
||||||
if (scale < 0)
|
if (scale < 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
if (b1.compareTo(BigDecimal.ZERO) == 0)
|
if (b1.compareTo(BigDecimal.ZERO) == 0)
|
||||||
{
|
{
|
||||||
return BigDecimal.ZERO.doubleValue();
|
return BigDecimal.ZERO.doubleValue();
|
||||||
}
|
}
|
||||||
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的小数位四舍五入处理。
|
* 提供精确的小数位四舍五入处理。
|
||||||
* @param v 需要四舍五入的数字
|
* @param v 需要四舍五入的数字
|
||||||
* @param scale 小数点后保留几位
|
* @param scale 小数点后保留几位
|
||||||
* @return 四舍五入后的结果
|
* @return 四舍五入后的结果
|
||||||
*/
|
*/
|
||||||
public static double round(double v, int scale)
|
public static double round(double v, int scale)
|
||||||
{
|
{
|
||||||
if (scale < 0)
|
if (scale < 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b = new BigDecimal(Double.toString(v));
|
BigDecimal b = new BigDecimal(Double.toString(v));
|
||||||
return b.divide(BigDecimal.ONE, scale, RoundingMode.HALF_UP).doubleValue();
|
BigDecimal one = new BigDecimal("1");
|
||||||
}
|
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,6 @@ package com.ruoyi.common.utils;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
|
|
@ -27,7 +22,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||||
|
|
||||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
private static String[] parsePatterns = {
|
private static String[] parsePatterns = {
|
||||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||||
|
|
@ -126,7 +121,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务器启动时间
|
* 获取服务器启动时间
|
||||||
*/
|
*/
|
||||||
|
|
@ -137,28 +132,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算相差天数
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
public static int differentDaysByMillisecond(Date date1, Date date2)
|
public static String getDatePoor(Date endDate, Date nowDate)
|
||||||
{
|
|
||||||
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算时间差
|
|
||||||
*
|
|
||||||
* @param endDate 最后时间
|
|
||||||
* @param startTime 开始时间
|
|
||||||
* @return 时间差(天/小时/分钟)
|
|
||||||
*/
|
|
||||||
public static String timeDistance(Date endDate, Date startTime)
|
|
||||||
{
|
{
|
||||||
long nd = 1000 * 24 * 60 * 60;
|
long nd = 1000 * 24 * 60 * 60;
|
||||||
long nh = 1000 * 60 * 60;
|
long nh = 1000 * 60 * 60;
|
||||||
long nm = 1000 * 60;
|
long nm = 1000 * 60;
|
||||||
// long ns = 1000;
|
// long ns = 1000;
|
||||||
// 获得两个时间的毫秒时间差异
|
// 获得两个时间的毫秒时间差异
|
||||||
long diff = endDate.getTime() - startTime.getTime();
|
long diff = endDate.getTime() - nowDate.getTime();
|
||||||
// 计算差多少天
|
// 计算差多少天
|
||||||
long day = diff / nd;
|
long day = diff / nd;
|
||||||
// 计算差多少小时
|
// 计算差多少小时
|
||||||
|
|
@ -169,23 +152,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
// long sec = diff % nd % nh % nm / ns;
|
// long sec = diff % nd % nh % nm / ns;
|
||||||
return day + "天" + hour + "小时" + min + "分钟";
|
return day + "天" + hour + "小时" + min + "分钟";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加 LocalDateTime ==> Date
|
|
||||||
*/
|
|
||||||
public static Date toDate(LocalDateTime temporalAccessor)
|
|
||||||
{
|
|
||||||
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
|
||||||
return Date.from(zdt.toInstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加 LocalDate ==> Date
|
|
||||||
*/
|
|
||||||
public static Date toDate(LocalDate temporalAccessor)
|
|
||||||
{
|
|
||||||
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
|
||||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
|
||||||
return Date.from(zdt.toInstant());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
package com.ruoyi.common.utils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏工具类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class DesensitizedUtil
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 密码的全部字符都用*代替,比如:******
|
|
||||||
*
|
|
||||||
* @param password 密码
|
|
||||||
* @return 脱敏后的密码
|
|
||||||
*/
|
|
||||||
public static String password(String password)
|
|
||||||
{
|
|
||||||
if (StringUtils.isBlank(password))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
return StringUtils.repeat('*', password.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车牌中间用*代替,如果是错误的车牌,不处理
|
|
||||||
*
|
|
||||||
* @param carLicense 完整的车牌号
|
|
||||||
* @return 脱敏后的车牌
|
|
||||||
*/
|
|
||||||
public static String carLicense(String carLicense)
|
|
||||||
{
|
|
||||||
if (StringUtils.isBlank(carLicense))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
// 普通车牌
|
|
||||||
if (carLicense.length() == 7)
|
|
||||||
{
|
|
||||||
carLicense = StringUtils.hide(carLicense, 3, 6);
|
|
||||||
}
|
|
||||||
else if (carLicense.length() == 8)
|
|
||||||
{
|
|
||||||
// 新能源车牌
|
|
||||||
carLicense = StringUtils.hide(carLicense, 3, 7);
|
|
||||||
}
|
|
||||||
return carLicense;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
|
@ -41,10 +38,11 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static List<SysDictData> getDictCache(String key)
|
public static List<SysDictData> getDictCache(String key)
|
||||||
{
|
{
|
||||||
JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||||
if (StringUtils.isNotNull(arrayCache))
|
if (StringUtils.isNotNull(cacheObj))
|
||||||
{
|
{
|
||||||
return arrayCache.toList(SysDictData.class);
|
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
||||||
|
return dictDatas;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -58,10 +56,6 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static String getDictLabel(String dictType, String dictValue)
|
public static String getDictLabel(String dictType, String dictValue)
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(dictValue))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
return getDictLabel(dictType, dictValue, SEPARATOR);
|
return getDictLabel(dictType, dictValue, SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,10 +68,6 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static String getDictValue(String dictType, String dictLabel)
|
public static String getDictValue(String dictType, String dictLabel)
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(dictLabel))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
return getDictValue(dictType, dictLabel, SEPARATOR);
|
return getDictValue(dictType, dictLabel, SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,25 +81,34 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static String getDictLabel(String dictType, String dictValue, String separator)
|
public static String getDictLabel(String dictType, String dictValue, String separator)
|
||||||
{
|
{
|
||||||
|
StringBuilder propertyString = new StringBuilder();
|
||||||
List<SysDictData> datas = getDictCache(dictType);
|
List<SysDictData> datas = getDictCache(dictType);
|
||||||
if (StringUtils.isNull(datas) || StringUtils.isEmpty(dictValue))
|
|
||||||
|
if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas))
|
||||||
{
|
{
|
||||||
return StringUtils.EMPTY;
|
for (SysDictData dict : datas)
|
||||||
}
|
|
||||||
Map<String, String> dictMap = datas.stream().collect(HashMap::new, (map, dict) -> map.put(dict.getDictValue(), dict.getDictLabel()), Map::putAll);
|
|
||||||
if (!StringUtils.contains(dictValue, separator))
|
|
||||||
{
|
|
||||||
return dictMap.getOrDefault(dictValue, StringUtils.EMPTY);
|
|
||||||
}
|
|
||||||
StringBuilder labelBuilder = new StringBuilder();
|
|
||||||
for (String seperatedValue : dictValue.split(separator))
|
|
||||||
{
|
|
||||||
if (dictMap.containsKey(seperatedValue))
|
|
||||||
{
|
{
|
||||||
labelBuilder.append(dictMap.get(seperatedValue)).append(separator);
|
for (String value : dictValue.split(separator))
|
||||||
|
{
|
||||||
|
if (value.equals(dict.getDictValue()))
|
||||||
|
{
|
||||||
|
propertyString.append(dict.getDictLabel() + separator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.removeEnd(labelBuilder.toString(), separator);
|
else
|
||||||
|
{
|
||||||
|
for (SysDictData dict : datas)
|
||||||
|
{
|
||||||
|
if (dictValue.equals(dict.getDictValue()))
|
||||||
|
{
|
||||||
|
return dict.getDictLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,77 +121,34 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static String getDictValue(String dictType, String dictLabel, String separator)
|
public static String getDictValue(String dictType, String dictLabel, String separator)
|
||||||
{
|
{
|
||||||
|
StringBuilder propertyString = new StringBuilder();
|
||||||
List<SysDictData> datas = getDictCache(dictType);
|
List<SysDictData> datas = getDictCache(dictType);
|
||||||
if (StringUtils.isNull(datas) || StringUtils.isEmpty(dictLabel))
|
|
||||||
|
if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas))
|
||||||
{
|
{
|
||||||
return StringUtils.EMPTY;
|
for (SysDictData dict : datas)
|
||||||
}
|
|
||||||
Map<String, String> dictMap = datas.stream().collect(HashMap::new, (map, dict) -> map.put(dict.getDictLabel(), dict.getDictValue()), Map::putAll);
|
|
||||||
if (!StringUtils.contains(dictLabel, separator))
|
|
||||||
{
|
|
||||||
return dictMap.getOrDefault(dictLabel, StringUtils.EMPTY);
|
|
||||||
}
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for (String seperatedValue : dictLabel.split(separator))
|
|
||||||
{
|
|
||||||
if (dictMap.containsKey(seperatedValue))
|
|
||||||
{
|
{
|
||||||
valueBuilder.append(dictMap.get(seperatedValue)).append(separator);
|
for (String label : dictLabel.split(separator))
|
||||||
|
{
|
||||||
|
if (label.equals(dict.getDictLabel()))
|
||||||
|
{
|
||||||
|
propertyString.append(dict.getDictValue() + separator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.removeEnd(valueBuilder.toString(), separator);
|
else
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典类型获取字典所有值
|
|
||||||
*
|
|
||||||
* @param dictType 字典类型
|
|
||||||
* @return 字典值
|
|
||||||
*/
|
|
||||||
public static String getDictValues(String dictType)
|
|
||||||
{
|
|
||||||
StringBuilder propertyString = new StringBuilder();
|
|
||||||
List<SysDictData> datas = getDictCache(dictType);
|
|
||||||
if (StringUtils.isNull(datas))
|
|
||||||
{
|
{
|
||||||
return StringUtils.EMPTY;
|
for (SysDictData dict : datas)
|
||||||
|
{
|
||||||
|
if (dictLabel.equals(dict.getDictLabel()))
|
||||||
|
{
|
||||||
|
return dict.getDictValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (SysDictData dict : datas)
|
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||||
{
|
|
||||||
propertyString.append(dict.getDictValue()).append(SEPARATOR);
|
|
||||||
}
|
|
||||||
return StringUtils.stripEnd(propertyString.toString(), SEPARATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典类型获取字典所有标签
|
|
||||||
*
|
|
||||||
* @param dictType 字典类型
|
|
||||||
* @return 字典值
|
|
||||||
*/
|
|
||||||
public static String getDictLabels(String dictType)
|
|
||||||
{
|
|
||||||
StringBuilder propertyString = new StringBuilder();
|
|
||||||
List<SysDictData> datas = getDictCache(dictType);
|
|
||||||
if (StringUtils.isNull(datas))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
for (SysDictData dict : datas)
|
|
||||||
{
|
|
||||||
propertyString.append(dict.getDictLabel()).append(SEPARATOR);
|
|
||||||
}
|
|
||||||
return StringUtils.stripEnd(propertyString.toString(), SEPARATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定字典缓存
|
|
||||||
*
|
|
||||||
* @param key 字典键
|
|
||||||
*/
|
|
||||||
public static void removeDictCache(String key)
|
|
||||||
{
|
|
||||||
SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -200,7 +156,7 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static void clearDictCache()
|
public static void clearDictCache()
|
||||||
{
|
{
|
||||||
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*");
|
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
|
||||||
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +168,6 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static String getCacheKey(String configKey)
|
public static String getCacheKey(String configKey)
|
||||||
{
|
{
|
||||||
return CacheConstants.SYS_DICT_KEY + configKey;
|
return Constants.SYS_DICT_KEY + configKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,11 @@ public class ExceptionUtil
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw, true));
|
e.printStackTrace(new PrintWriter(sw, true));
|
||||||
return sw.toString();
|
String str = sw.toString();
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRootErrorMessage(Exception e)
|
public static String getRootErrorMseeage(Exception e)
|
||||||
{
|
{
|
||||||
Throwable root = ExceptionUtils.getRootCause(e);
|
Throwable root = ExceptionUtils.getRootCause(e);
|
||||||
root = (root == null ? e : root);
|
root = (root == null ? e : root);
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
package com.ruoyi.common.utils;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
|
||||||
import com.ruoyi.common.core.page.PageDomain;
|
|
||||||
import com.ruoyi.common.core.page.TableSupport;
|
|
||||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页工具类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class PageUtils extends PageHelper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 设置请求分页数据
|
|
||||||
*/
|
|
||||||
public static void startPage()
|
|
||||||
{
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
||||||
Boolean reasonable = pageDomain.getReasonable();
|
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清理分页的线程变量
|
|
||||||
*/
|
|
||||||
public static void clearPage()
|
|
||||||
{
|
|
||||||
PageHelper.clearPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +1,11 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.util.PatternMatchUtils;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.constant.HttpStatus;
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.CustomException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全服务工具类
|
* 安全服务工具类
|
||||||
|
|
@ -20,37 +14,6 @@ import com.ruoyi.common.exception.ServiceException;
|
||||||
*/
|
*/
|
||||||
public class SecurityUtils
|
public class SecurityUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
**/
|
|
||||||
public static Long getUserId()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getLoginUser().getUserId();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门ID
|
|
||||||
**/
|
|
||||||
public static Long getDeptId()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getLoginUser().getDeptId();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户账户
|
* 获取用户账户
|
||||||
**/
|
**/
|
||||||
|
|
@ -62,7 +25,7 @@ public class SecurityUtils
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
|
throw new CustomException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +40,7 @@ public class SecurityUtils
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
|
throw new CustomException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,16 +77,6 @@ public class SecurityUtils
|
||||||
return passwordEncoder.matches(rawPassword, encodedPassword);
|
return passwordEncoder.matches(rawPassword, encodedPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为管理员
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public static boolean isAdmin()
|
|
||||||
{
|
|
||||||
return isAdmin(getUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为管理员
|
* 是否为管理员
|
||||||
*
|
*
|
||||||
|
|
@ -134,55 +87,4 @@ public class SecurityUtils
|
||||||
{
|
{
|
||||||
return userId != null && 1L == userId;
|
return userId != null && 1L == userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证用户是否具备某权限
|
|
||||||
*
|
|
||||||
* @param permission 权限字符串
|
|
||||||
* @return 用户是否具备某权限
|
|
||||||
*/
|
|
||||||
public static boolean hasPermi(String permission)
|
|
||||||
{
|
|
||||||
return hasPermi(getLoginUser().getPermissions(), permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否包含权限
|
|
||||||
*
|
|
||||||
* @param authorities 权限列表
|
|
||||||
* @param permission 权限字符串
|
|
||||||
* @return 用户是否具备某权限
|
|
||||||
*/
|
|
||||||
public static boolean hasPermi(Collection<String> authorities, String permission)
|
|
||||||
{
|
|
||||||
return authorities.stream().filter(StringUtils::hasText)
|
|
||||||
.anyMatch(x -> Constants.ALL_PERMISSION.equals(x) || PatternMatchUtils.simpleMatch(x, permission));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证用户是否拥有某个角色
|
|
||||||
*
|
|
||||||
* @param role 角色标识
|
|
||||||
* @return 用户是否具备某角色
|
|
||||||
*/
|
|
||||||
public static boolean hasRole(String role)
|
|
||||||
{
|
|
||||||
List<SysRole> roleList = getLoginUser().getUser().getRoles();
|
|
||||||
Collection<String> roles = roleList.stream().map(SysRole::getRoleKey).collect(Collectors.toSet());
|
|
||||||
return hasRole(roles, role);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否包含角色
|
|
||||||
*
|
|
||||||
* @param roles 角色列表
|
|
||||||
* @param role 角色
|
|
||||||
* @return 用户是否具备某角色权限
|
|
||||||
*/
|
|
||||||
public static boolean hasRole(Collection<String> roles, String role)
|
|
||||||
{
|
|
||||||
return roles.stream().filter(StringUtils::hasText)
|
|
||||||
.anyMatch(x -> Constants.SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.servlet.ServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,50 +48,6 @@ public class ServletUtils
|
||||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Boolean参数
|
|
||||||
*/
|
|
||||||
public static Boolean getParameterToBool(String name)
|
|
||||||
{
|
|
||||||
return Convert.toBool(getRequest().getParameter(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Boolean参数
|
|
||||||
*/
|
|
||||||
public static Boolean getParameterToBool(String name, Boolean defaultValue)
|
|
||||||
{
|
|
||||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得所有请求参数
|
|
||||||
*
|
|
||||||
* @param request 请求对象{@link ServletRequest}
|
|
||||||
* @return Map
|
|
||||||
*/
|
|
||||||
public static Map<String, String[]> getParams(ServletRequest request)
|
|
||||||
{
|
|
||||||
final Map<String, String[]> map = request.getParameterMap();
|
|
||||||
return Collections.unmodifiableMap(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得所有请求参数
|
|
||||||
*
|
|
||||||
* @param request 请求对象{@link ServletRequest}
|
|
||||||
* @return Map
|
|
||||||
*/
|
|
||||||
public static Map<String, String> getParamMap(ServletRequest request)
|
|
||||||
{
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet())
|
|
||||||
{
|
|
||||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
|
|
@ -135,8 +83,9 @@ public class ServletUtils
|
||||||
*
|
*
|
||||||
* @param response 渲染对象
|
* @param response 渲染对象
|
||||||
* @param string 待渲染的字符串
|
* @param string 待渲染的字符串
|
||||||
|
* @return null
|
||||||
*/
|
*/
|
||||||
public static void renderString(HttpServletResponse response, String string)
|
public static String renderString(HttpServletResponse response, String string)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -149,6 +98,7 @@ public class ServletUtils
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -159,13 +109,13 @@ public class ServletUtils
|
||||||
public static boolean isAjaxRequest(HttpServletRequest request)
|
public static boolean isAjaxRequest(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
String accept = request.getHeader("accept");
|
String accept = request.getHeader("accept");
|
||||||
if (accept != null && accept.contains("application/json"))
|
if (accept != null && accept.indexOf("application/json") != -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||||
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -177,42 +127,10 @@ public class ServletUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
String ajax = request.getParameter("__ajax");
|
||||||
return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
|
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 内容编码
|
|
||||||
*
|
|
||||||
* @param str 内容
|
|
||||||
* @return 编码后的内容
|
|
||||||
*/
|
|
||||||
public static String urlEncode(String str)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return URLEncoder.encode(str, Constants.UTF8);
|
return true;
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException e)
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 内容解码
|
|
||||||
*
|
|
||||||
* @param str 内容
|
|
||||||
* @return 解码后的内容
|
|
||||||
*/
|
|
||||||
public static String urlDecode(String str)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return URLDecoder.decode(str, Constants.UTF8);
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException e)
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.springframework.util.AntPathMatcher;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.text.StrFormatter;
|
import com.ruoyi.common.core.text.StrFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -23,9 +21,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
/** 下划线 */
|
/** 下划线 */
|
||||||
private static final char SEPARATOR = '_';
|
private static final char SEPARATOR = '_';
|
||||||
|
|
||||||
/** 星号 */
|
|
||||||
private static final char ASTERISK = '*';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取参数不为空值
|
* 获取参数不为空值
|
||||||
*
|
*
|
||||||
|
|
@ -166,49 +161,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
return (str == null ? "" : str.trim());
|
return (str == null ? "" : str.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换指定字符串的指定区间内字符为"*"
|
|
||||||
*
|
|
||||||
* @param str 字符串
|
|
||||||
* @param startInclude 开始位置(包含)
|
|
||||||
* @param endExclude 结束位置(不包含)
|
|
||||||
* @return 替换后的字符串
|
|
||||||
*/
|
|
||||||
public static String hide(CharSequence str, int startInclude, int endExclude)
|
|
||||||
{
|
|
||||||
if (isEmpty(str))
|
|
||||||
{
|
|
||||||
return NULLSTR;
|
|
||||||
}
|
|
||||||
final int strLength = str.length();
|
|
||||||
if (startInclude > strLength)
|
|
||||||
{
|
|
||||||
return NULLSTR;
|
|
||||||
}
|
|
||||||
if (endExclude > strLength)
|
|
||||||
{
|
|
||||||
endExclude = strLength;
|
|
||||||
}
|
|
||||||
if (startInclude > endExclude)
|
|
||||||
{
|
|
||||||
// 如果起始位置大于结束位置,不替换
|
|
||||||
return NULLSTR;
|
|
||||||
}
|
|
||||||
final char[] chars = new char[strLength];
|
|
||||||
for (int i = 0; i < strLength; i++)
|
|
||||||
{
|
|
||||||
if (i >= startInclude && i < endExclude)
|
|
||||||
{
|
|
||||||
chars[i] = ASTERISK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
chars[i] = str.charAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new String(chars);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 截取字符串
|
* 截取字符串
|
||||||
*
|
*
|
||||||
|
|
@ -286,56 +238,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
return str.substring(start, end);
|
return str.substring(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 在字符串中查找第一个出现的 `open` 和最后一个出现的 `close` 之间的子字符串
|
|
||||||
*
|
|
||||||
* @param str 要截取的字符串
|
|
||||||
* @param open 起始字符串
|
|
||||||
* @param close 结束字符串
|
|
||||||
* @return 截取结果
|
|
||||||
*/
|
|
||||||
public static String substringBetweenLast(final String str, final String open, final String close)
|
|
||||||
{
|
|
||||||
if (isEmpty(str) || isEmpty(open) || isEmpty(close))
|
|
||||||
{
|
|
||||||
return NULLSTR;
|
|
||||||
}
|
|
||||||
final int start = str.indexOf(open);
|
|
||||||
if (start != INDEX_NOT_FOUND)
|
|
||||||
{
|
|
||||||
final int end = str.lastIndexOf(close);
|
|
||||||
if (end != INDEX_NOT_FOUND)
|
|
||||||
{
|
|
||||||
return str.substring(start + open.length(), end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULLSTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否为空,并且不是空白字符
|
|
||||||
*
|
|
||||||
* @param str 要判断的value
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public static boolean hasText(String str)
|
|
||||||
{
|
|
||||||
return (str != null && !str.isEmpty() && containsText(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean containsText(CharSequence str)
|
|
||||||
{
|
|
||||||
int strLen = str.length();
|
|
||||||
for (int i = 0; i < strLen; i++)
|
|
||||||
{
|
|
||||||
if (!Character.isWhitespace(str.charAt(i)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化文本, {} 表示占位符<br>
|
* 格式化文本, {} 表示占位符<br>
|
||||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||||
|
|
@ -358,17 +260,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
return StrFormatter.format(template, params);
|
return StrFormatter.format(template, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为http(s)://开头
|
|
||||||
*
|
|
||||||
* @param link 链接
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public static boolean ishttp(String link)
|
|
||||||
{
|
|
||||||
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串转set
|
* 字符串转set
|
||||||
*
|
*
|
||||||
|
|
@ -381,18 +272,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
return new HashSet<String>(str2List(str, sep, true, false));
|
return new HashSet<String>(str2List(str, sep, true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符串转list
|
|
||||||
*
|
|
||||||
* @param str 字符串
|
|
||||||
* @param sep 分隔符
|
|
||||||
* @return list集合
|
|
||||||
*/
|
|
||||||
public static final List<String> str2List(String str, String sep)
|
|
||||||
{
|
|
||||||
return str2List(str, sep, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串转list
|
* 字符串转list
|
||||||
*
|
*
|
||||||
|
|
@ -433,56 +312,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断给定的collection列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value
|
* 下划线转驼峰命名
|
||||||
*
|
|
||||||
* @param collection 给定的集合
|
|
||||||
* @param array 给定的数组
|
|
||||||
* @return boolean 结果
|
|
||||||
*/
|
|
||||||
public static boolean containsAny(Collection<String> collection, String... array)
|
|
||||||
{
|
|
||||||
if (isEmpty(collection) || isEmpty(array))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (String str : array)
|
|
||||||
{
|
|
||||||
if (collection.contains(str))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
|
|
||||||
*
|
|
||||||
* @param cs 指定字符串
|
|
||||||
* @param searchCharSequences 需要检查的字符串数组
|
|
||||||
* @return 是否包含任意一个字符串
|
|
||||||
*/
|
|
||||||
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences)
|
|
||||||
{
|
|
||||||
if (isEmpty(cs) || isEmpty(searchCharSequences))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (CharSequence testStr : searchCharSequences)
|
|
||||||
{
|
|
||||||
if (containsIgnoreCase(cs, testStr))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 驼峰转下划线命名
|
|
||||||
*/
|
*/
|
||||||
public static String toUnderScoreCase(String str)
|
public static String toUnderScoreCase(String str)
|
||||||
{
|
{
|
||||||
|
|
@ -589,8 +419,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驼峰式命名法
|
* 驼峰式命名法 例如:user_name->userName
|
||||||
* 例如:user_name->userName
|
|
||||||
*/
|
*/
|
||||||
public static String toCamelCase(String s)
|
public static String toCamelCase(String s)
|
||||||
{
|
{
|
||||||
|
|
@ -598,10 +427,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (s.indexOf(SEPARATOR) == -1)
|
|
||||||
{
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
StringBuilder sb = new StringBuilder(s.length());
|
StringBuilder sb = new StringBuilder(s.length());
|
||||||
boolean upperCase = false;
|
boolean upperCase = false;
|
||||||
|
|
@ -626,97 +451,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
|
||||||
*
|
|
||||||
* @param str 指定字符串
|
|
||||||
* @param strs 需要检查的字符串数组
|
|
||||||
* @return 是否匹配
|
|
||||||
*/
|
|
||||||
public static boolean matches(String str, List<String> strs)
|
|
||||||
{
|
|
||||||
if (isEmpty(str) || isEmpty(strs))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (String pattern : strs)
|
|
||||||
{
|
|
||||||
if (isMatch(pattern, str))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断url是否与规则配置:
|
|
||||||
* ? 表示单个字符;
|
|
||||||
* * 表示一层路径内的任意字符串,不可跨层级;
|
|
||||||
* ** 表示任意层路径;
|
|
||||||
*
|
|
||||||
* @param pattern 匹配规则
|
|
||||||
* @param url 需要匹配的url
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean isMatch(String pattern, String url)
|
|
||||||
{
|
|
||||||
AntPathMatcher matcher = new AntPathMatcher();
|
|
||||||
return matcher.match(pattern, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T cast(Object obj)
|
public static <T> T cast(Object obj)
|
||||||
{
|
{
|
||||||
return (T) obj;
|
return (T) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
|
|
||||||
*
|
|
||||||
* @param num 数字对象
|
|
||||||
* @param size 字符串指定长度
|
|
||||||
* @return 返回数字的字符串格式,该字符串为指定长度。
|
|
||||||
*/
|
|
||||||
public static final String padl(final Number num, final int size)
|
|
||||||
{
|
|
||||||
return padl(num.toString(), size, '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
|
|
||||||
*
|
|
||||||
* @param s 原始字符串
|
|
||||||
* @param size 字符串指定长度
|
|
||||||
* @param c 用于补齐的字符
|
|
||||||
* @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
|
|
||||||
*/
|
|
||||||
public static final String padl(final String s, final int size, final char c)
|
|
||||||
{
|
|
||||||
final StringBuilder sb = new StringBuilder(size);
|
|
||||||
if (s != null)
|
|
||||||
{
|
|
||||||
final int len = s.length();
|
|
||||||
if (s.length() <= size)
|
|
||||||
{
|
|
||||||
for (int i = size - len; i > 0; i--)
|
|
||||||
{
|
|
||||||
sb.append(c);
|
|
||||||
}
|
|
||||||
sb.append(s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return s.substring(len - size, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = size; i > 0; i--)
|
|
||||||
{
|
|
||||||
sb.append(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue