Compare commits
438 Commits
v3.5.0
...
95542bf4c9
Author | SHA1 | Date | |
---|---|---|---|
95542bf4c9 | |||
3598fafe66 | |||
de1dd3a808 | |||
9c3b53b701 | |||
f2cb431c90 | |||
9facc1b682 | |||
93835778ad | |||
8020eabaa9 | |||
5693bbe1f5 | |||
0055f479cb | |||
1c41b701dd | |||
9476f7f616 | |||
cbe405f6ea | |||
7414bc492e | |||
6f14087a16 | |||
328d4b916d | |||
b42a8176ca | |||
2a9beec31d | |||
910fe6261b | |||
0c820b96d8 | |||
c3c49a05c2 | |||
68a616d7c7 | |||
a0447de061 | |||
46db06a22b | |||
de5ae4a05e | |||
c0d430f4e5 | |||
d910888181 | |||
db2dfee6ae | |||
d311d56bbf | |||
3bc5ef38d3 | |||
bac3b3a0dc | |||
07fded4da9 | |||
a854e0ca8e | |||
de1766abde | |||
01a566c794 | |||
5362a633e6 | |||
b2c3f45141 | |||
d5f9b5b74a | |||
2043d1f439 | |||
61034d4dde | |||
6605bf35a8 | |||
b2b93e5060 | |||
098286fcaf | |||
eaa12de740 | |||
857054179c | |||
0a3fcfd9f4 | |||
0271aa5414 | |||
a0364f0758 | |||
ed693e89c9 | |||
526957e0ac | |||
420a43cdd5 | |||
5e8ccda522 | |||
62fc38078c | |||
bc4f844cd8 | |||
f15f8e3295 | |||
6130bebbb3 | |||
9f944c043f | |||
092b3214c5 | |||
07dfef48be | |||
e9571fc2e2 | |||
22f7ccc11d | |||
4bd5009ec1 | |||
cb8f5de5af | |||
ac030b7275 | |||
9370747479 | |||
45efd9290e | |||
96edba7eec | |||
927b05713a | |||
8f23ff7274 | |||
158e883e47 | |||
e62e8e372c | |||
bb65cd1976 | |||
1086c00929 | |||
9aaa9ce8aa | |||
cb5a6d29e2 | |||
4d8bd8805b | |||
c8c57b545a | |||
d0f7a317e4 | |||
aa9ed2e863 | |||
54c6c4e547 | |||
986b48cf36 | |||
3bb9b03add | |||
f05aa674ab | |||
965bdc9986 | |||
e793138031 | |||
d734bfc34f | |||
84fe0737de | |||
81630a096f | |||
21780d8106 | |||
b7b4364db2 | |||
d9859de756 | |||
5e6fd0d1e1 | |||
a91d7cdd72 | |||
d00dc3b03a | |||
f5c69bae30 | |||
89fe17f419 | |||
c491257359 | |||
dd5e514d92 | |||
2532e40f9c | |||
50236ae4e5 | |||
c99eb98001 | |||
a29201a248 | |||
6f0c59d7be | |||
a6ed5667ab | |||
612c4293d1 | |||
8007b22b85 | |||
35664d818d | |||
1fe08f49c7 | |||
48b007543a | |||
dccb3ac6c6 | |||
89cd2106ed | |||
74f991b8c5 | |||
a966b95a5b | |||
15f05b602f | |||
9e51d3f250 | |||
d7ca248bc8 | |||
3980b2f2ff | |||
bed9fcea46 | |||
b1b82857ba | |||
869dcf73f8 | |||
96a34d1ad7 | |||
766361ac83 | |||
9bd7509e87 | |||
9f7acd4cf9 | |||
eb11337f7d | |||
d2872539e3 | |||
1a5b024df6 | |||
578d65dfb4 | |||
db4c2d3dd5 | |||
47842a1611 | |||
f4f4cd9b1f | |||
b7452cc281 | |||
8ba91fc9dd | |||
c8d9b3f8fc | |||
c9d19cbe56 | |||
10ae0bce65 | |||
7bc15245aa | |||
cb6228800b | |||
6ef899d000 | |||
6353f4ff09 | |||
bb1af390a7 | |||
f65cd6245d | |||
530b2a51d5 | |||
d51e7cbb51 | |||
f244fe1855 | |||
1294f68265 | |||
0e771a6c1b | |||
e4df0c6da1 | |||
7b23b6db6f | |||
be412faf6c | |||
fd3a699ad8 | |||
c28aa299bd | |||
a028b566ed | |||
ca2405c104 | |||
e5647793ce | |||
903b5aebca | |||
7492dcc9e6 | |||
8978012f9d | |||
7cf4a5da87 | |||
47b67331d4 | |||
6e14601c7c | |||
fef7ead0d5 | |||
06aef0587a | |||
bf7c259cdd | |||
43d76e5990 | |||
d365a52cd6 | |||
e1c7115d8c | |||
bb4d75aff0 | |||
2743785aaf | |||
2a235917dc | |||
44ce6774dc | |||
b911d7f78f | |||
4644176e26 | |||
850b98337b | |||
7f2921f26b | |||
836017f2b9 | |||
4de4763baf | |||
965ebd0f03 | |||
2c3f1c28e5 | |||
6bfae2652f | |||
9bc730866f | |||
a2d3f987c0 | |||
bf4ac3ad7a | |||
f28a91969a | |||
ca285f5e53 | |||
34f2552cad | |||
89e7cb19b9 | |||
ea71c9b214 | |||
e5fd1f76db | |||
664192da0b | |||
9fc3e220a7 | |||
64f6a69d9a | |||
16734b1d88 | |||
31106c91fb | |||
026a427103 | |||
bafb1372a7 | |||
b4f032fab4 | |||
4f194aa101 | |||
ef4bfde4a8 | |||
421593c0ba | |||
91ad85aec1 | |||
d1eacc1d1c | |||
e41dd8a0f1 | |||
9a7bb81cd0 | |||
fcf606acde | |||
084907eeca | |||
8de93d35ed | |||
cedd2d1daf | |||
2ab96587ef | |||
cb9c0e79eb | |||
96d2b2d6b8 | |||
b00171366f | |||
4e817a1109 | |||
d185d4e4cc | |||
bbbe83b737 | |||
cc4c52c998 | |||
bd09e5b11c | |||
181f62c15e | |||
3ae5ec92a5 | |||
2fe919b6ce | |||
13c770b6be | |||
2eb55528ec | |||
839f631d6b | |||
8faae71157 | |||
b87e0fa124 | |||
b6596d021b | |||
0628dc9b2f | |||
790aa0d24b | |||
8a7dcf8a80 | |||
0c30ffa11f | |||
0904bf6446 | |||
4583787759 | |||
17550a5f4b | |||
a4558c32b2 | |||
ef4fef3d56 | |||
3dbbc6a223 | |||
d3696f5223 | |||
2d7d137abd | |||
c2a179e9dd | |||
519ea854d5 | |||
e66d0e4f74 | |||
e7afea4cb7 | |||
6d6271d6c9 | |||
eb4376b649 | |||
b1e5ebab8f | |||
8bd6296721 | |||
ae5c68368b | |||
4fdb0f48ec | |||
c4207f640b | |||
f6e477b4f5 | |||
7ae47b50b8 | |||
0b14155a75 | |||
f1fed76273 | |||
48813161f6 | |||
a006904724 | |||
5477ce3c39 | |||
25f50d74c5 | |||
266f4d6806 | |||
ded99502ae | |||
02b95f95a8 | |||
2a6d2d733e | |||
30c89b33fe | |||
7479ff4b06 | |||
821f40882f | |||
02ce9868a7 | |||
a8f2ff4531 | |||
eaa3baab3c | |||
6480282826 | |||
6197ad5090 | |||
b477e40d3c | |||
f8cc7ce328 | |||
1a5881b1d0 | |||
fa124aeb8b | |||
258335cc65 | |||
3b42abef44 | |||
26f0737c60 | |||
ac94242875 | |||
54bfa627f0 | |||
36c058188a | |||
a292cccb63 | |||
5ccd9877b4 | |||
7108ec41b5 | |||
5188d56b4a | |||
8f7ed66544 | |||
aaae404b2a | |||
f3a8b4625f | |||
12ab8b03d9 | |||
23270c60bc | |||
2cb6709323 | |||
917bc03a43 | |||
dbe3446b63 | |||
b84e7013d2 | |||
db193a46e8 | |||
04c340627d | |||
15abd4d053 | |||
a7376b36f8 | |||
d2b61762b7 | |||
a5e38f6f99 | |||
4988b585f8 | |||
b35f708c07 | |||
0e6150720c | |||
44adf03d2c | |||
9ae5edaa74 | |||
14c6c796e8 | |||
5d72f9d224 | |||
e49f0cebf1 | |||
6361e4efdc | |||
cfa86bd4fe | |||
a56bc47a81 | |||
a15bfdfb46 | |||
ee823b8326 | |||
57178e72a4 | |||
b8317a562c | |||
8040ad8c03 | |||
c628aa5be8 | |||
b036e78d85 | |||
4e8c6fb7c0 | |||
134835c870 | |||
5ade90debf | |||
bb0aeb39e3 | |||
098c650655 | |||
e52092c6d4 | |||
89911e7caf | |||
0fc266fe80 | |||
d1ef19f08a | |||
e6e10308ff | |||
cb5ee9c8a1 | |||
1e37f0430b | |||
295173258c | |||
fec90d0487 | |||
aead560227 | |||
8133c60ab3 | |||
5c155f5f11 | |||
03cf98d3c9 | |||
6f51f729ba | |||
57b159eb98 | |||
08da6834a5 | |||
268468fb47 | |||
333e19339c | |||
7b6ccd9b22 | |||
5d6f134609 | |||
f02743bde5 | |||
3003bb0f50 | |||
5139265d32 | |||
8a67af6c26 | |||
8e4802505e | |||
8ee641c1bc | |||
779508989f | |||
d9e805a6a5 | |||
7be17ea89a | |||
1f07641d9b | |||
c0f4f805d0 | |||
b84224d7ba | |||
98a143f1fe | |||
3243428009 | |||
7736097f6b | |||
fc60c003c3 | |||
68ae4df2dc | |||
de33e6ecc8 | |||
a1cc346aca | |||
5397e345ca | |||
8ed7916b61 | |||
2de5cc52d1 | |||
f6bc28000e | |||
6b5dd4d2be | |||
e6becb9337 | |||
8da55fb72a | |||
6a5c86541a | |||
3803ac78e2 | |||
4095a1b6ee | |||
3347ca4d74 | |||
9b1883988b | |||
49c8a007cc | |||
64f6d28441 | |||
c26d87c677 | |||
97ae0eb7c7 | |||
6c1cccd031 | |||
856d1ceba8 | |||
60673b3b64 | |||
0a516e3001 | |||
bb87f35797 | |||
c43f9bc3c2 | |||
46b43b1bd9 | |||
8dbda47174 | |||
cdace51197 | |||
c24fc4282c | |||
b616a2f2e7 | |||
60abdf1dbc | |||
7b894da43c | |||
c8b66f9b04 | |||
25d9edd5c9 | |||
77a21d098f | |||
170cfb356c | |||
5879c2484a | |||
c02dad2ca3 | |||
1bfa14e3c6 | |||
5dec58e7f5 | |||
8321f92d2c | |||
da1095e298 | |||
f56da498ab | |||
e259093e01 | |||
e963a86b15 | |||
e447fb806b | |||
90c41d498c | |||
ce6bea4ba0 | |||
9c7901f526 | |||
04f5a93aa8 | |||
751ca90690 | |||
1dfeae6a03 | |||
1ed60c79c0 | |||
aee1e53140 | |||
253e2b2de1 | |||
b1413f021e | |||
60c22b6a43 | |||
3f05ed6ffa | |||
090ad5323a | |||
3e90fd010d | |||
462862ba65 | |||
7601a72faf | |||
7ab14ff293 | |||
200106df39 | |||
ea66e20282 | |||
a209b39552 | |||
557672ba9f | |||
a3116cd27d | |||
2ace3257f9 | |||
c16ee7fc2c | |||
fd33fe869d | |||
b7446f8d0f | |||
19924cd184 | |||
85470a1549 | |||
2a604c0548 | |||
b7f3c68eca | |||
edd2981076 | |||
c105a63c8b | |||
01fef0b9e1 | |||
af9cfb40a4 | |||
6fa3bfe051 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
custom: http://doc.ruoyi.vip/ruoyi-vue/other/donate.html
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -25,6 +25,9 @@ target/
|
|||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
|
### JRebel ###
|
||||||
|
rebel.xml
|
||||||
|
|
||||||
### NetBeans ###
|
### NetBeans ###
|
||||||
nbproject/private/
|
nbproject/private/
|
||||||
build/*
|
build/*
|
||||||
|
14
README.md
14
README.md
@ -1,3 +1,14 @@
|
|||||||
|
<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.8.2</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.8.2-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>
|
||||||
|
|
||||||
## 平台简介
|
## 平台简介
|
||||||
|
|
||||||
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
||||||
@ -7,6 +18,7 @@
|
|||||||
* 权限认证使用Jwt,支持多终端认证系统。
|
* 权限认证使用Jwt,支持多终端认证系统。
|
||||||
* 支持加载动态权限菜单,多方式轻松权限控制。
|
* 支持加载动态权限菜单,多方式轻松权限控制。
|
||||||
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
||||||
|
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。
|
||||||
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast),Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
|
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast),Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
|
||||||
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
||||||
* 特别鸣谢:[element](https://github.com/ElemeFE/element),[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://github.com/elunez/eladmin-web)。
|
* 特别鸣谢:[element](https://github.com/ElemeFE/element),[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://github.com/elunez/eladmin-web)。
|
||||||
@ -82,4 +94,4 @@
|
|||||||
|
|
||||||
## 若依前后端分离交流群
|
## 若依前后端分离交流群
|
||||||
|
|
||||||
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) 点击按钮入群。
|
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) 点击按钮入群。
|
@ -1,6 +1,6 @@
|
|||||||
@echo off
|
@echo off
|
||||||
echo.
|
echo.
|
||||||
echo [<5B><>Ϣ] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>
|
echo [<5B><>Ϣ] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>target<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
%~d0
|
%~d0
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
@echo off
|
@echo off
|
||||||
echo.
|
echo.
|
||||||
echo [<5B><>Ϣ] <20><><EFBFBD><EFBFBD>Web<65><62><EFBFBD>̡<EFBFBD>
|
echo [<5B><>Ϣ] ʹ<EFBFBD><EFBFBD>Jar<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Web<EFBFBD><EFBFBD><EFBFBD>̡<EFBFBD>
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
cd %~dp0
|
cd %~dp0
|
||||||
|
80
pom.xml
80
pom.xml
@ -6,32 +6,31 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.8.2</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.5.0</ruoyi.version>
|
<ruoyi.version>3.8.2</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>11</java.version>
|
||||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
<druid.version>1.2.6</druid.version>
|
<druid.version>1.2.8</druid.version>
|
||||||
<bitwalker.version>1.21</bitwalker.version>
|
<bitwalker.version>1.21</bitwalker.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.2</kaptcha.version>
|
||||||
<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
|
<mybatis-spring-boot.version>2.2.2</mybatis-spring-boot.version>
|
||||||
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
<pagehelper.boot.version>1.4.1</pagehelper.boot.version>
|
||||||
<fastjson.version>1.2.76</fastjson.version>
|
<fastjson.version>1.2.80</fastjson.version>
|
||||||
<oshi.version>5.6.0</oshi.version>
|
<oshi.version>6.1.6</oshi.version>
|
||||||
<jna.version>5.7.0</jna.version>
|
<commons.io.version>2.11.0</commons.io.version>
|
||||||
<commons.io.version>2.5</commons.io.version>
|
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
|
||||||
<commons.collections.version>3.2.2</commons.collections.version>
|
<commons.collections.version>3.2.2</commons.collections.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<velocity.version>1.7</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<jwt.version>0.9.1</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -43,12 +42,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>2.2.13.RELEASE</version>
|
<version>2.5.13</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--阿里数据库连接池 -->
|
<!-- 阿里数据库连接池 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
@ -83,28 +82,12 @@
|
|||||||
<version>${oshi.version}</version>
|
<version>${oshi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- Swagger3依赖 -->
|
||||||
<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-swagger2</artifactId>
|
<artifactId>springfox-boot-starter</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>
|
||||||
@ -112,21 +95,14 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-UI-->
|
<!-- io常用工具类 -->
|
||||||
<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>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
@ -140,17 +116,11 @@
|
|||||||
<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</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
<version>${velocity.version}</version>
|
<version>${velocity.version}</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-collections</groupId>
|
|
||||||
<artifactId>commons-collections</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- collections工具类 -->
|
<!-- collections工具类 -->
|
||||||
@ -167,14 +137,14 @@
|
|||||||
<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>com.github.penggle</groupId>
|
<groupId>com.github.penggle</groupId>
|
||||||
<artifactId>kaptcha</artifactId>
|
<artifactId>kaptcha</artifactId>
|
||||||
@ -253,7 +223,7 @@
|
|||||||
<repository>
|
<repository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
<name>aliyun nexus</name>
|
<name>aliyun nexus</name>
|
||||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -264,7 +234,7 @@
|
|||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
<name>aliyun nexus</name>
|
<name>aliyun nexus</name>
|
||||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
|
@ -1,108 +1,96 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.5.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<artifactId>ruoyi-admin</artifactId>
|
<artifactId>ruoyi-admin</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
web服务入口
|
web服务入口
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- spring-boot-devtools -->
|
<!-- spring-boot-devtools -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-->
|
<!-- swagger3-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->
|
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-models</artifactId>
|
||||||
<version>1.5.21</version>
|
<version>1.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- Mysql驱动包 -->
|
||||||
<groupId>io.swagger</groupId>
|
<dependency>
|
||||||
<artifactId>swagger-models</artifactId>
|
<groupId>mysql</groupId>
|
||||||
<version>1.5.21</version>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-UI-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>ruoyi-framework</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
<!-- 定时任务-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>ruoyi-quartz</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 代码生成-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-framework</artifactId>
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务-->
|
</dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<build>
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
<plugins>
|
||||||
</dependency>
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
<!-- 代码生成-->
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<dependency>
|
<version>2.1.1.RELEASE</version>
|
||||||
<groupId>com.ruoyi</groupId>
|
<configuration>
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||||
</dependency>
|
</configuration>
|
||||||
|
<executions>
|
||||||
</dependencies>
|
<execution>
|
||||||
|
<goals>
|
||||||
<build>
|
<goal>repackage</goal>
|
||||||
<plugins>
|
</goals>
|
||||||
<plugin>
|
</execution>
|
||||||
<groupId>org.springframework.boot</groupId>
|
</executions>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
</plugin>
|
||||||
<version>2.1.1.RELEASE</version>
|
<plugin>
|
||||||
<configuration>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
</configuration>
|
<version>3.1.0</version>
|
||||||
<executions>
|
<configuration>
|
||||||
<execution>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<goals>
|
<warName>${project.artifactId}</warName>
|
||||||
<goal>repackage</goal>
|
</configuration>
|
||||||
</goals>
|
</plugin>
|
||||||
</execution>
|
</plugins>
|
||||||
</executions>
|
<finalName>${project.artifactId}</finalName>
|
||||||
</plugin>
|
</build>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<version>3.1.0</version>
|
|
||||||
<configuration>
|
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
|
||||||
<warName>${project.artifactId}</warName>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,30 +1,30 @@
|
|||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||||
public class RuoYiApplication
|
public class RuoYiApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
SpringApplication.run(RuoYiApplication.class, args);
|
SpringApplication.run(RuoYiApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
System.out.println("(♥◠‿◠)ノ゙ 我们一起学喵叫 ლ(´ڡ`ლ)゙ \n" +
|
||||||
" .-------. ____ __ \n" +
|
" .-------. ____ __ \n" +
|
||||||
" | _ _ \\ \\ \\ / / \n" +
|
" | _ _ \\ 喵 \\ \\ / / \n" +
|
||||||
" | ( ' ) | \\ _. / ' \n" +
|
" | ( ' ) | 喵 \\ _. / ' \n" +
|
||||||
" |(_ o _) / _( )_ .' \n" +
|
" |(_ o _) / 喵 _( )_ .' \n" +
|
||||||
" | (_,_).' __ ___(_ o _)' \n" +
|
" | (_,_).' __ ___(_ o _)' \n" +
|
||||||
" | |\\ \\ | || |(_,_)' \n" +
|
" | |\\ \\ | || |(_,_)' \n" +
|
||||||
" | | \\ `' /| `-' / \n" +
|
" | | \\ `' /| `-' / \n" +
|
||||||
" | | \\ / \\ / \n" +
|
" | | \\ / \\ / \n" +
|
||||||
" ''-' `'-' `-..-' ");
|
" ''-' `'-' `-..-' ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web容器中进行部署
|
* web容器中进行部署
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class RuoYiServletInitializer extends SpringBootServletInitializer
|
public class RuoYiServletInitializer extends SpringBootServletInitializer
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
|
||||||
{
|
{
|
||||||
return application.sources(RuoYiApplication.class);
|
return application.sources(RuoYiApplication.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 亚大综合监测
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 9:08
|
||||||
|
*/
|
||||||
|
public class AdahTestingController {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大气质量监测
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 10:56
|
||||||
|
*/
|
||||||
|
public class AtmosphereController {
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.system.service.IAustraliaMiddleEastService;
|
||||||
|
import com.ruoyi.system.service.IForestService;
|
||||||
|
import com.ruoyi.system.vo.AustraliaMiddleEastVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 澳大利亚中东部地区
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 9:08
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/business-service/api/orderMng", produces = "application/json;charset=UTF-8")
|
||||||
|
public class AustraliaMiddleEastController
|
||||||
|
{
|
||||||
|
// @Autowired
|
||||||
|
private IAustraliaMiddleEastService australiaMiddleEastService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询方法
|
||||||
|
* @param response
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/SelectAustralia",method = {RequestMethod.POST})
|
||||||
|
public AjaxResult SelectAustralia(HttpServletResponse response, HttpServletRequest request)
|
||||||
|
{
|
||||||
|
List<AustraliaMiddleEastVO> eastVOSList= australiaMiddleEastService.selectAustralia();
|
||||||
|
return AjaxResult.success(eastVOSList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除方法
|
||||||
|
* @param ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/DelAustralia",method = {RequestMethod.POST})
|
||||||
|
public AjaxResult DelAustralia(@Param("ID") String ID)
|
||||||
|
{
|
||||||
|
int NUM = australiaMiddleEastService.DelAustralia(ID);
|
||||||
|
if (NUM>0)
|
||||||
|
{
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
return AjaxResult.error();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增方法
|
||||||
|
* @param eastVOS
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/IntoAustralia",method = {RequestMethod.POST})
|
||||||
|
public AjaxResult IntoAustralia(AustraliaMiddleEastVO eastVOS)
|
||||||
|
{
|
||||||
|
int NUM = australiaMiddleEastService.IntoAustralia(eastVOS);
|
||||||
|
if (NUM>0)
|
||||||
|
{
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ENSO影响监测
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 9:12
|
||||||
|
*/
|
||||||
|
public class ENSOController {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 森林监测
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 9:13
|
||||||
|
*/
|
||||||
|
public class ForestController {
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*全球生态环境监测
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 9:05
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/clobal")
|
||||||
|
public class GlobalEcologyController {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专题报告
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 11:10
|
||||||
|
*/
|
||||||
|
public class SpecialReportController {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.web.controller.RemoteSensing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 城市监测
|
||||||
|
* @Author: JinSheng Song
|
||||||
|
* @Date: 2022/5/11 10:55
|
||||||
|
*/
|
||||||
|
public class UrbanController {
|
||||||
|
}
|
@ -1,86 +1,96 @@
|
|||||||
package com.ruoyi.web.controller.common;
|
package com.ruoyi.web.controller.common;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Resource;
|
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 com.ruoyi.common.config.RuoYiConfig;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.util.FastByteArrayOutputStream;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.util.FastByteArrayOutputStream;
|
||||||
import com.google.code.kaptcha.Producer;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.google.code.kaptcha.Producer;
|
||||||
import com.ruoyi.common.utils.sign.Base64;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
/**
|
import com.ruoyi.common.utils.sign.Base64;
|
||||||
* 验证码操作处理
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
*
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
* @author ruoyi
|
|
||||||
*/
|
/**
|
||||||
@RestController
|
* 验证码操作处理
|
||||||
public class CaptchaController
|
*
|
||||||
{
|
* @author ruoyi
|
||||||
@Resource(name = "captchaProducer")
|
*/
|
||||||
private Producer captchaProducer;
|
@RestController
|
||||||
|
public class CaptchaController
|
||||||
@Resource(name = "captchaProducerMath")
|
{
|
||||||
private Producer captchaProducerMath;
|
@Resource(name = "captchaProducer")
|
||||||
|
private Producer captchaProducer;
|
||||||
@Autowired
|
|
||||||
private RedisCache redisCache;
|
@Resource(name = "captchaProducerMath")
|
||||||
|
private Producer captchaProducerMath;
|
||||||
// 验证码类型
|
|
||||||
@Value("${ruoyi.captchaType}")
|
@Resource
|
||||||
private String captchaType;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
/**
|
@Resource
|
||||||
* 生成验证码
|
private ISysConfigService configService;
|
||||||
*/
|
/**
|
||||||
@GetMapping("/captchaImage")
|
* 生成验证码
|
||||||
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
*/
|
||||||
{
|
@GetMapping("/captchaImage")
|
||||||
// 保存验证码信息
|
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
||||||
String uuid = IdUtils.simpleUUID();
|
{
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||||
String capStr = null, code = null;
|
ajax.put("captchaOnOff", captchaOnOff);
|
||||||
BufferedImage image = null;
|
if (!captchaOnOff)
|
||||||
|
{
|
||||||
// 生成验证码
|
return ajax;
|
||||||
if ("math".equals(captchaType))
|
}
|
||||||
{
|
|
||||||
String capText = captchaProducerMath.createText();
|
// 保存验证码信息
|
||||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
String uuid = IdUtils.simpleUUID();
|
||||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
image = captchaProducerMath.createImage(capStr);
|
|
||||||
}
|
String capStr = null, code = null;
|
||||||
else if ("char".equals(captchaType))
|
BufferedImage image = null;
|
||||||
{
|
|
||||||
capStr = code = captchaProducer.createText();
|
// 生成验证码
|
||||||
image = captchaProducer.createImage(capStr);
|
String captchaType = RuoYiConfig.getCaptchaType();
|
||||||
}
|
if ("math".equals(captchaType))
|
||||||
|
{
|
||||||
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
String capText = captchaProducerMath.createText();
|
||||||
// 转换流信息写出
|
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||||
try
|
image = captchaProducerMath.createImage(capStr);
|
||||||
{
|
}
|
||||||
ImageIO.write(image, "jpg", os);
|
else if ("char".equals(captchaType))
|
||||||
}
|
{
|
||||||
catch (IOException e)
|
capStr = code = captchaProducer.createText();
|
||||||
{
|
image = captchaProducer.createImage(capStr);
|
||||||
return AjaxResult.error(e.getMessage());
|
}
|
||||||
}
|
|
||||||
|
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
// 转换流信息写出
|
||||||
ajax.put("uuid", uuid);
|
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||||
ajax.put("img", Base64.encode(os.toByteArray()));
|
try
|
||||||
return ajax;
|
{
|
||||||
}
|
ImageIO.write(image, "jpg", os);
|
||||||
}
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
ajax.put("uuid", uuid);
|
||||||
|
ajax.put("img", Base64.encode(os.toByteArray()));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,118 +1,163 @@
|
|||||||
package com.ruoyi.web.controller.common;
|
package com.ruoyi.web.controller.common;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import java.util.ArrayList;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.slf4j.LoggerFactory;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.slf4j.Logger;
|
||||||
import org.springframework.http.MediaType;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.utils.file.FileUtils;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.framework.config.ServerConfig;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
/**
|
import com.ruoyi.common.utils.file.FileUtils;
|
||||||
* 通用请求处理
|
import com.ruoyi.framework.config.ServerConfig;
|
||||||
*
|
|
||||||
* @author ruoyi
|
/**
|
||||||
*/
|
* 通用请求处理
|
||||||
@RestController
|
*
|
||||||
public class CommonController
|
* @author ruoyi
|
||||||
{
|
*/
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
@RestController
|
||||||
|
@RequestMapping("/common")
|
||||||
@Autowired
|
public class CommonController
|
||||||
private ServerConfig serverConfig;
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
/**
|
|
||||||
* 通用下载请求
|
@Autowired
|
||||||
*
|
private ServerConfig serverConfig;
|
||||||
* @param fileName 文件名称
|
|
||||||
* @param delete 是否删除
|
private static final String FILE_DELIMETER = ",";
|
||||||
*/
|
|
||||||
@GetMapping("common/download")
|
/**
|
||||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
* 通用下载请求
|
||||||
{
|
*
|
||||||
try
|
* @param fileName 文件名称
|
||||||
{
|
* @param delete 是否删除
|
||||||
if (!FileUtils.checkAllowDownload(fileName))
|
*/
|
||||||
{
|
@GetMapping("/download")
|
||||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||||
}
|
{
|
||||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
try
|
||||||
String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
{
|
||||||
|
if (!FileUtils.checkAllowDownload(fileName))
|
||||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
{
|
||||||
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
}
|
||||||
if (delete)
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||||
{
|
String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
||||||
FileUtils.deleteFile(filePath);
|
|
||||||
}
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
}
|
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
||||||
catch (Exception e)
|
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||||
{
|
if (delete)
|
||||||
log.error("下载文件失败", e);
|
{
|
||||||
}
|
FileUtils.deleteFile(filePath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
catch (Exception e)
|
||||||
* 通用上传请求
|
{
|
||||||
*/
|
log.error("下载文件失败", e);
|
||||||
@PostMapping("/common/upload")
|
}
|
||||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
}
|
||||||
{
|
|
||||||
try
|
/**
|
||||||
{
|
* 通用上传请求(单个)
|
||||||
// 上传文件路径
|
*/
|
||||||
String filePath = RuoYiConfig.getUploadPath();
|
@PostMapping("/upload")
|
||||||
// 上传并返回新文件名称
|
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
{
|
||||||
String url = serverConfig.getUrl() + fileName;
|
try
|
||||||
AjaxResult ajax = AjaxResult.success();
|
{
|
||||||
ajax.put("fileName", fileName);
|
// 上传文件路径
|
||||||
ajax.put("url", url);
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
return ajax;
|
// 上传并返回新文件名称
|
||||||
}
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
catch (Exception e)
|
String url = serverConfig.getUrl() + fileName;
|
||||||
{
|
AjaxResult ajax = AjaxResult.success();
|
||||||
return AjaxResult.error(e.getMessage());
|
ajax.put("url", url);
|
||||||
}
|
ajax.put("fileName", fileName);
|
||||||
}
|
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||||
|
ajax.put("originalFilename", file.getOriginalFilename());
|
||||||
/**
|
return ajax;
|
||||||
* 本地资源通用下载
|
}
|
||||||
*/
|
catch (Exception e)
|
||||||
@GetMapping("/common/download/resource")
|
{
|
||||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
return AjaxResult.error(e.getMessage());
|
||||||
throws Exception
|
}
|
||||||
{
|
}
|
||||||
try
|
|
||||||
{
|
/**
|
||||||
if (!FileUtils.checkAllowDownload(resource))
|
* 通用上传请求(多个)
|
||||||
{
|
*/
|
||||||
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
@PostMapping("/uploads")
|
||||||
}
|
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
|
||||||
// 本地资源路径
|
{
|
||||||
String localPath = RuoYiConfig.getProfile();
|
try
|
||||||
// 数据库资源地址
|
{
|
||||||
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
// 上传文件路径
|
||||||
// 下载名称
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
List<String> urls = new ArrayList<String>();
|
||||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
List<String> fileNames = new ArrayList<String>();
|
||||||
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
List<String> newFileNames = new ArrayList<String>();
|
||||||
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
List<String> originalFilenames = new ArrayList<String>();
|
||||||
}
|
for (MultipartFile file : files)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
// 上传并返回新文件名称
|
||||||
log.error("下载文件失败", e);
|
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_DELIMETER));
|
||||||
|
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
|
||||||
|
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
|
||||||
|
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地资源通用下载
|
||||||
|
*/
|
||||||
|
@GetMapping("/download/resource")
|
||||||
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!FileUtils.checkAllowDownload(resource))
|
||||||
|
{
|
||||||
|
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
||||||
|
}
|
||||||
|
// 本地资源路径
|
||||||
|
String localPath = RuoYiConfig.getProfile();
|
||||||
|
// 数据库资源地址
|
||||||
|
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||||
|
// 下载名称
|
||||||
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
||||||
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("下载文件失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,53 +1,53 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisCallback;
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.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.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存监控
|
* 缓存监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/cache")
|
@RequestMapping("/monitor/cache")
|
||||||
public class CacheController
|
public class CacheController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate<String, String> redisTemplate;
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public AjaxResult getInfo() throws Exception
|
public AjaxResult getInfo() throws Exception
|
||||||
{
|
{
|
||||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
||||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>(3);
|
Map<String, Object> result = new HashMap<>(3);
|
||||||
result.put("info", info);
|
result.put("info", info);
|
||||||
result.put("dbSize", dbSize);
|
result.put("dbSize", dbSize);
|
||||||
|
|
||||||
List<Map<String, String>> pieList = new ArrayList<>();
|
List<Map<String, String>> pieList = new ArrayList<>();
|
||||||
commandStats.stringPropertyNames().forEach(key -> {
|
commandStats.stringPropertyNames().forEach(key -> {
|
||||||
Map<String, String> data = new HashMap<>(2);
|
Map<String, String> data = new HashMap<>(2);
|
||||||
String property = commandStats.getProperty(key);
|
String property = commandStats.getProperty(key);
|
||||||
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
||||||
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
||||||
pieList.add(data);
|
pieList.add(data);
|
||||||
});
|
});
|
||||||
result.put("commandStats", pieList);
|
result.put("commandStats", pieList);
|
||||||
return AjaxResult.success(result);
|
return AjaxResult.success(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
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.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.framework.web.domain.Server;
|
import com.ruoyi.framework.web.domain.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器监控
|
* 服务器监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/server")
|
@RequestMapping("/monitor/server")
|
||||||
public class ServerController
|
public class ServerController
|
||||||
{
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public AjaxResult getInfo() throws Exception
|
public AjaxResult getInfo() throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
server.copyTo();
|
server.copyTo();
|
||||||
return AjaxResult.success(server);
|
return AjaxResult.success(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,67 +1,69 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
/**
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
* 系统访问记录
|
|
||||||
*
|
/**
|
||||||
* @author ruoyi
|
* 系统访问记录
|
||||||
*/
|
*
|
||||||
@RestController
|
* @author ruoyi
|
||||||
@RequestMapping("/monitor/logininfor")
|
*/
|
||||||
public class SysLogininforController extends BaseController
|
@RestController
|
||||||
{
|
@RequestMapping("/monitor/logininfor")
|
||||||
@Autowired
|
public class SysLogininforController extends BaseController
|
||||||
private ISysLogininforService logininforService;
|
{
|
||||||
|
@Autowired
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
private ISysLogininforService logininforService;
|
||||||
@GetMapping("/list")
|
|
||||||
public TableDataInfo list(SysLogininfor logininfor)
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||||
{
|
@GetMapping("/list")
|
||||||
startPage();
|
public TableDataInfo list(SysLogininfor logininfor)
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
{
|
||||||
return getDataTable(list);
|
startPage();
|
||||||
}
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
|
return getDataTable(list);
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
|
||||||
@GetMapping("/export")
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
public AjaxResult export(SysLogininfor logininfor)
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||||
{
|
@PostMapping("/export")
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
public void export(HttpServletResponse response, SysLogininfor logininfor)
|
||||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
{
|
||||||
return util.exportExcel(list, "登录日志");
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
}
|
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||||
|
util.exportExcel(response, list, "登录日志");
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
}
|
||||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{infoIds}")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
public AjaxResult remove(@PathVariable Long[] infoIds)
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
{
|
@DeleteMapping("/{infoIds}")
|
||||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
public AjaxResult remove(@PathVariable Long[] infoIds)
|
||||||
}
|
{
|
||||||
|
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
}
|
||||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
|
||||||
@DeleteMapping("/clean")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
public AjaxResult clean()
|
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||||
{
|
@DeleteMapping("/clean")
|
||||||
logininforService.cleanLogininfor();
|
public AjaxResult clean()
|
||||||
return AjaxResult.success();
|
{
|
||||||
}
|
logininforService.cleanLogininfor();
|
||||||
}
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,67 +1,69 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysOperLog;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
/**
|
import com.ruoyi.system.service.ISysOperLogService;
|
||||||
* 操作日志记录
|
|
||||||
*
|
/**
|
||||||
* @author ruoyi
|
* 操作日志记录
|
||||||
*/
|
*
|
||||||
@RestController
|
* @author ruoyi
|
||||||
@RequestMapping("/monitor/operlog")
|
*/
|
||||||
public class SysOperlogController extends BaseController
|
@RestController
|
||||||
{
|
@RequestMapping("/monitor/operlog")
|
||||||
@Autowired
|
public class SysOperlogController extends BaseController
|
||||||
private ISysOperLogService operLogService;
|
{
|
||||||
|
@Autowired
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
private ISysOperLogService operLogService;
|
||||||
@GetMapping("/list")
|
|
||||||
public TableDataInfo list(SysOperLog operLog)
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||||
{
|
@GetMapping("/list")
|
||||||
startPage();
|
public TableDataInfo list(SysOperLog operLog)
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
{
|
||||||
return getDataTable(list);
|
startPage();
|
||||||
}
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
|
return getDataTable(list);
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
|
||||||
@GetMapping("/export")
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
public AjaxResult export(SysOperLog operLog)
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||||
{
|
@PostMapping("/export")
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
public void export(HttpServletResponse response, SysOperLog operLog)
|
||||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
{
|
||||||
return util.exportExcel(list, "操作日志");
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
}
|
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||||
|
util.exportExcel(response, list, "操作日志");
|
||||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
|
||||||
@DeleteMapping("/{operIds}")
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
{
|
@DeleteMapping("/{operIds}")
|
||||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||||
}
|
{
|
||||||
|
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
|
||||||
@DeleteMapping("/clean")
|
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||||
public AjaxResult clean()
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
{
|
@DeleteMapping("/clean")
|
||||||
operLogService.cleanOperLog();
|
public AjaxResult clean()
|
||||||
return AjaxResult.success();
|
{
|
||||||
}
|
operLogService.cleanOperLog();
|
||||||
}
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,92 +1,92 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
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.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.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;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.SysUserOnline;
|
import com.ruoyi.system.domain.SysUserOnline;
|
||||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
import com.ruoyi.system.service.ISysUserOnlineService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户监控
|
* 在线用户监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/online")
|
@RequestMapping("/monitor/online")
|
||||||
public class SysUserOnlineController extends BaseController
|
public class SysUserOnlineController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserOnlineService userOnlineService;
|
private ISysUserOnlineService userOnlineService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(String ipaddr, String userName)
|
public TableDataInfo list(String ipaddr, String userName)
|
||||||
{
|
{
|
||||||
Collection<String> keys = redisCache.keys(Constants.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))
|
||||||
{
|
{
|
||||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(ipaddr))
|
else if (StringUtils.isNotEmpty(ipaddr))
|
||||||
{
|
{
|
||||||
if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
||||||
{
|
{
|
||||||
if (StringUtils.equals(userName, user.getUsername()))
|
if (StringUtils.equals(userName, user.getUsername()))
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.reverse(userOnlineList);
|
Collections.reverse(userOnlineList);
|
||||||
userOnlineList.removeAll(Collections.singleton(null));
|
userOnlineList.removeAll(Collections.singleton(null));
|
||||||
return getDataTable(userOnlineList);
|
return getDataTable(userOnlineList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强退用户
|
* 强退用户
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public AjaxResult forceLogout(@PathVariable String tokenId)
|
public AjaxResult forceLogout(@PathVariable String tokenId)
|
||||||
{
|
{
|
||||||
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,135 +1,134 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.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;
|
|
||||||
|
/**
|
||||||
/**
|
* 参数配置 信息操作处理
|
||||||
* 参数配置 信息操作处理
|
*
|
||||||
*
|
* @author ruoyi
|
||||||
* @author ruoyi
|
*/
|
||||||
*/
|
@RestController
|
||||||
@RestController
|
@RequestMapping("/system/config")
|
||||||
@RequestMapping("/system/config")
|
public class SysConfigController extends BaseController
|
||||||
public class SysConfigController extends BaseController
|
{
|
||||||
{
|
@Autowired
|
||||||
@Autowired
|
private ISysConfigService configService;
|
||||||
private ISysConfigService configService;
|
|
||||||
|
/**
|
||||||
/**
|
* 获取参数配置列表
|
||||||
* 获取参数配置列表
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
@GetMapping("/list")
|
||||||
@GetMapping("/list")
|
public TableDataInfo list(SysConfig config)
|
||||||
public TableDataInfo list(SysConfig config)
|
{
|
||||||
{
|
startPage();
|
||||||
startPage();
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
return getDataTable(list);
|
||||||
return getDataTable(list);
|
}
|
||||||
}
|
|
||||||
|
@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, "参数数据");
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 根据参数编号获取详细信息
|
||||||
* 根据参数编号获取详细信息
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
@GetMapping(value = "/{configId}")
|
||||||
@GetMapping(value = "/{configId}")
|
public AjaxResult getInfo(@PathVariable Long configId)
|
||||||
public AjaxResult getInfo(@PathVariable Long configId)
|
{
|
||||||
{
|
return AjaxResult.success(configService.selectConfigById(configId));
|
||||||
return AjaxResult.success(configService.selectConfigById(configId));
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 根据参数键名查询参数值
|
||||||
* 根据参数键名查询参数值
|
*/
|
||||||
*/
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
public AjaxResult getConfigKey(@PathVariable String configKey)
|
||||||
public AjaxResult getConfigKey(@PathVariable String configKey)
|
{
|
||||||
{
|
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||||
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 新增参数配置
|
||||||
* 新增参数配置
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@PostMapping
|
||||||
@PostMapping
|
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
||||||
@RepeatSubmit
|
{
|
||||||
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
{
|
}
|
||||||
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
config.setCreateBy(getUsername());
|
||||||
}
|
return toAjax(configService.insertConfig(config));
|
||||||
config.setCreateBy(SecurityUtils.getUsername());
|
}
|
||||||
return toAjax(configService.insertConfig(config));
|
|
||||||
}
|
/**
|
||||||
|
* 修改参数配置
|
||||||
/**
|
*/
|
||||||
* 修改参数配置
|
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||||
*/
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
@PutMapping
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
||||||
@PutMapping
|
{
|
||||||
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
{
|
}
|
||||||
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
config.setUpdateBy(getUsername());
|
||||||
}
|
return toAjax(configService.updateConfig(config));
|
||||||
config.setUpdateBy(SecurityUtils.getUsername());
|
}
|
||||||
return toAjax(configService.updateConfig(config));
|
|
||||||
}
|
/**
|
||||||
|
* 删除参数配置
|
||||||
/**
|
*/
|
||||||
* 删除参数配置
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
*/
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
@DeleteMapping("/{configIds}")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
public AjaxResult remove(@PathVariable Long[] configIds)
|
||||||
@DeleteMapping("/{configIds}")
|
{
|
||||||
public AjaxResult remove(@PathVariable Long[] configIds)
|
configService.deleteConfigByIds(configIds);
|
||||||
{
|
return success();
|
||||||
return toAjax(configService.deleteConfigByIds(configIds));
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 刷新参数缓存
|
||||||
* 清空缓存
|
*/
|
||||||
*/
|
@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 AjaxResult.success();
|
||||||
return AjaxResult.success();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,163 +1,165 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.Iterator;
|
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;
|
||||||
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;
|
||||||
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.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.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.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.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;
|
|
||||||
|
/**
|
||||||
/**
|
* 部门信息
|
||||||
* 部门信息
|
*
|
||||||
*
|
* @author ruoyi
|
||||||
* @author ruoyi
|
*/
|
||||||
*/
|
@RestController
|
||||||
@RestController
|
@RequestMapping("/system/dept")
|
||||||
@RequestMapping("/system/dept")
|
public class SysDeptController extends BaseController
|
||||||
public class SysDeptController extends BaseController
|
{
|
||||||
{
|
@Autowired
|
||||||
@Autowired
|
private ISysDeptService deptService;
|
||||||
private ISysDeptService deptService;
|
|
||||||
|
/**
|
||||||
/**
|
* 获取部门列表
|
||||||
* 获取部门列表
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
@GetMapping("/list")
|
||||||
@GetMapping("/list")
|
public AjaxResult list(SysDept dept)
|
||||||
public AjaxResult list(SysDept dept)
|
{
|
||||||
{
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
return AjaxResult.success(depts);
|
||||||
return AjaxResult.success(depts);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 查询部门列表(排除节点)
|
||||||
* 查询部门列表(排除节点)
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
@GetMapping("/list/exclude/{deptId}")
|
||||||
@GetMapping("/list/exclude/{deptId}")
|
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());
|
Iterator<SysDept> it = depts.iterator();
|
||||||
Iterator<SysDept> it = depts.iterator();
|
while (it.hasNext())
|
||||||
while (it.hasNext())
|
{
|
||||||
{
|
SysDept d = (SysDept) it.next();
|
||||||
SysDept d = (SysDept) it.next();
|
if (d.getDeptId().intValue() == deptId
|
||||||
if (d.getDeptId().intValue() == deptId
|
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
||||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
{
|
||||||
{
|
it.remove();
|
||||||
it.remove();
|
}
|
||||||
}
|
}
|
||||||
}
|
return AjaxResult.success(depts);
|
||||||
return AjaxResult.success(depts);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 根据部门编号获取详细信息
|
||||||
* 根据部门编号获取详细信息
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
@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 AjaxResult.success(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门下拉树列表
|
* 获取部门下拉树列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(SysDept dept)
|
public AjaxResult treeselect(SysDept dept)
|
||||||
{
|
{
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载对应角色部门列表树
|
* 加载对应角色部门列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||||
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
||||||
{
|
{
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(SecurityUtils.getUsername());
|
dept.setCreateBy(getUsername());
|
||||||
return toAjax(deptService.insertDept(dept));
|
return toAjax(deptService.insertDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
Long deptId = dept.getDeptId();
|
||||||
{
|
deptService.checkDeptDataScope(deptId);
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
}
|
{
|
||||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
{
|
}
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
else if (dept.getParentId().equals(deptId))
|
||||||
}
|
{
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
}
|
||||||
{
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
||||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
{
|
||||||
}
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
dept.setUpdateBy(SecurityUtils.getUsername());
|
}
|
||||||
return toAjax(deptService.updateDept(dept));
|
dept.setUpdateBy(getUsername());
|
||||||
}
|
return toAjax(deptService.updateDept(dept));
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 删除部门
|
/**
|
||||||
*/
|
* 删除部门
|
||||||
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
*/
|
||||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||||
@DeleteMapping("/{deptId}")
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||||
public AjaxResult remove(@PathVariable Long deptId)
|
@DeleteMapping("/{deptId}")
|
||||||
{
|
public AjaxResult remove(@PathVariable Long deptId)
|
||||||
if (deptService.hasChildByDeptId(deptId))
|
{
|
||||||
{
|
if (deptService.hasChildByDeptId(deptId))
|
||||||
return AjaxResult.error("存在下级部门,不允许删除");
|
{
|
||||||
}
|
return AjaxResult.error("存在下级部门,不允许删除");
|
||||||
if (deptService.checkDeptExistUser(deptId))
|
}
|
||||||
{
|
if (deptService.checkDeptExistUser(deptId))
|
||||||
return AjaxResult.error("部门存在用户,不允许删除");
|
{
|
||||||
}
|
return AjaxResult.error("部门存在用户,不允许删除");
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
}
|
||||||
}
|
deptService.checkDeptDataScope(deptId);
|
||||||
}
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,120 +1,121 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
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.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/data")
|
@RequestMapping("/system/dict/data")
|
||||||
public class SysDictDataController extends BaseController
|
public class SysDictDataController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictDataService dictDataService;
|
private ISysDictDataService dictDataService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictTypeService dictTypeService;
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysDictData dictData)
|
public TableDataInfo list(SysDictData dictData)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@GetMapping("/export")
|
@PostMapping("/export")
|
||||||
public AjaxResult export(SysDictData dictData)
|
public void export(HttpServletResponse response, 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);
|
||||||
return util.exportExcel(list, "字典数据");
|
util.exportExcel(response, list, "字典数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字典数据详细
|
* 查询字典数据详细
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
@GetMapping(value = "/{dictCode}")
|
@GetMapping(value = "/{dictCode}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictCode)
|
public AjaxResult getInfo(@PathVariable Long dictCode)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字典类型查询字典数据信息
|
* 根据字典类型查询字典数据信息
|
||||||
*/
|
*/
|
||||||
@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);
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
if (StringUtils.isNull(data))
|
if (StringUtils.isNull(data))
|
||||||
{
|
{
|
||||||
data = new ArrayList<SysDictData>();
|
data = new ArrayList<SysDictData>();
|
||||||
}
|
}
|
||||||
return AjaxResult.success(data);
|
return AjaxResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setCreateBy(SecurityUtils.getUsername());
|
dict.setCreateBy(getUsername());
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
dict.setUpdateBy(getUsername());
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictCodes}")
|
@DeleteMapping("/{dictCodes}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
||||||
{
|
{
|
||||||
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
|
dictDataService.deleteDictDataByIds(dictCodes);
|
||||||
}
|
return success();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,131 +1,132 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dict/type")
|
@RequestMapping("/system/dict/type")
|
||||||
public class SysDictTypeController extends BaseController
|
public class SysDictTypeController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictTypeService dictTypeService;
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysDictType dictType)
|
public TableDataInfo list(SysDictType dictType)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
@GetMapping("/export")
|
@PostMapping("/export")
|
||||||
public AjaxResult export(SysDictType dictType)
|
public void export(HttpServletResponse response, 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);
|
||||||
return util.exportExcel(list, "字典类型");
|
util.exportExcel(response, list, "字典类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字典类型详细
|
* 查询字典类型详细
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
@GetMapping(value = "/{dictId}")
|
@GetMapping(value = "/{dictId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictId)
|
public AjaxResult getInfo(@PathVariable Long dictId)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setCreateBy(SecurityUtils.getUsername());
|
dict.setCreateBy(getUsername());
|
||||||
return toAjax(dictTypeService.insertDictType(dict));
|
return toAjax(dictTypeService.insertDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
dict.setUpdateBy(getUsername());
|
||||||
return toAjax(dictTypeService.updateDictType(dict));
|
return toAjax(dictTypeService.updateDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictIds}")
|
@DeleteMapping("/{dictIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictIds)
|
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||||
{
|
{
|
||||||
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||||
}
|
return success();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 清空缓存
|
/**
|
||||||
*/
|
* 刷新字典缓存
|
||||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
*/
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
@DeleteMapping("/clearCache")
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
public AjaxResult clearCache()
|
@DeleteMapping("/refreshCache")
|
||||||
{
|
public AjaxResult refreshCache()
|
||||||
dictTypeService.clearCache();
|
{
|
||||||
return AjaxResult.success();
|
dictTypeService.resetDictCache();
|
||||||
}
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 获取字典选择框列表
|
/**
|
||||||
*/
|
* 获取字典选择框列表
|
||||||
@GetMapping("/optionselect")
|
*/
|
||||||
public AjaxResult optionselect()
|
@GetMapping("/optionselect")
|
||||||
{
|
public AjaxResult optionselect()
|
||||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
{
|
||||||
return AjaxResult.success(dictTypes);
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
}
|
return AjaxResult.success(dictTypes);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
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,94 +1,86 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import 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.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
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.system.service.ISysMenuService;
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
/**
|
||||||
|
* 登录验证
|
||||||
/**
|
*
|
||||||
* 登录验证
|
* @author ruoyi
|
||||||
*
|
*/
|
||||||
* @author ruoyi
|
@RestController
|
||||||
*/
|
public class SysLoginController
|
||||||
@RestController
|
{
|
||||||
public class SysLoginController
|
@Autowired
|
||||||
{
|
private SysLoginService loginService;
|
||||||
@Autowired
|
|
||||||
private SysLoginService loginService;
|
@Autowired
|
||||||
|
private ISysMenuService menuService;
|
||||||
@Autowired
|
|
||||||
private ISysMenuService menuService;
|
@Autowired
|
||||||
|
private SysPermissionService permissionService;
|
||||||
@Autowired
|
|
||||||
private SysPermissionService permissionService;
|
/**
|
||||||
|
* 登录方法
|
||||||
@Autowired
|
*
|
||||||
private TokenService tokenService;
|
* @param loginBody 登录信息
|
||||||
|
* @return 结果
|
||||||
/**
|
*/
|
||||||
* 登录方法
|
@PostMapping("/login")
|
||||||
*
|
public AjaxResult login(@RequestBody LoginBody loginBody)
|
||||||
* @param loginBody 登录信息
|
{
|
||||||
* @return 结果
|
AjaxResult ajax = AjaxResult.success();
|
||||||
*/
|
// 生成令牌
|
||||||
@PostMapping("/login")
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||||
public AjaxResult login(@RequestBody LoginBody loginBody)
|
loginBody.getUuid());
|
||||||
{
|
ajax.put(Constants.TOKEN, token);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
return ajax;
|
||||||
// 生成令牌
|
}
|
||||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
||||||
loginBody.getUuid());
|
/**
|
||||||
ajax.put(Constants.TOKEN, token);
|
* 获取用户信息
|
||||||
return ajax;
|
*
|
||||||
}
|
* @return 用户信息
|
||||||
|
*/
|
||||||
/**
|
@GetMapping("getInfo")
|
||||||
* 获取用户信息
|
public AjaxResult getInfo()
|
||||||
*
|
{
|
||||||
* @return 用户信息
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||||
*/
|
// 角色集合
|
||||||
@GetMapping("getInfo")
|
Set<String> roles = permissionService.getRolePermission(user);
|
||||||
public AjaxResult getInfo()
|
// 权限集合
|
||||||
{
|
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
AjaxResult ajax = AjaxResult.success();
|
||||||
SysUser user = loginUser.getUser();
|
ajax.put("user", user);
|
||||||
// 角色集合
|
ajax.put("roles", roles);
|
||||||
Set<String> roles = permissionService.getRolePermission(user);
|
ajax.put("permissions", permissions);
|
||||||
// 权限集合
|
return ajax;
|
||||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
}
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
ajax.put("user", user);
|
/**
|
||||||
ajax.put("roles", roles);
|
* 获取路由信息
|
||||||
ajax.put("permissions", permissions);
|
*
|
||||||
return ajax;
|
* @return 路由信息
|
||||||
}
|
*/
|
||||||
|
@GetMapping("getRouters")
|
||||||
/**
|
public AjaxResult getRouters()
|
||||||
* 获取路由信息
|
{
|
||||||
*
|
Long userId = SecurityUtils.getUserId();
|
||||||
* @return 路由信息
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||||
*/
|
return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
@GetMapping("getRouters")
|
}
|
||||||
public AjaxResult getRouters()
|
}
|
||||||
{
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
||||||
// 用户信息
|
|
||||||
SysUser user = loginUser.getUser();
|
|
||||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId());
|
|
||||||
return AjaxResult.success(menuService.buildMenus(menus));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,157 +1,142 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
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;
|
||||||
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.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.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.enums.BusinessType;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
/**
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
* 菜单信息
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
*
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
* @author ruoyi
|
||||||
|
*/
|
||||||
/**
|
@RestController
|
||||||
* 菜单信息
|
@RequestMapping("/system/menu")
|
||||||
*
|
public class SysMenuController extends BaseController
|
||||||
* @author ruoyi
|
{
|
||||||
*/
|
@Autowired
|
||||||
@RestController
|
private ISysMenuService menuService;
|
||||||
@RequestMapping("/system/menu")
|
|
||||||
public class SysMenuController extends BaseController
|
/**
|
||||||
{
|
* 获取菜单列表
|
||||||
@Autowired
|
*/
|
||||||
private ISysMenuService menuService;
|
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
@Autowired
|
public AjaxResult list(SysMenu menu)
|
||||||
private TokenService tokenService;
|
{
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
/**
|
return AjaxResult.success(menus);
|
||||||
* 获取菜单列表
|
}
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
/**
|
||||||
@GetMapping("/list")
|
* 根据菜单编号获取详细信息
|
||||||
public AjaxResult list(SysMenu menu)
|
*/
|
||||||
{
|
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
@GetMapping(value = "/{menuId}")
|
||||||
Long userId = loginUser.getUser().getUserId();
|
public AjaxResult getInfo(@PathVariable Long menuId)
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
{
|
||||||
return AjaxResult.success(menus);
|
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单编号获取详细信息
|
* 获取菜单下拉树列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
@GetMapping("/treeselect")
|
||||||
@GetMapping(value = "/{menuId}")
|
public AjaxResult treeselect(SysMenu menu)
|
||||||
public AjaxResult getInfo(@PathVariable Long menuId)
|
{
|
||||||
{
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单下拉树列表
|
* 加载对应角色菜单列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeselect")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public AjaxResult treeselect(SysMenu menu)
|
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
||||||
{
|
{
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||||
Long userId = loginUser.getUser().getUserId();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||||
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||||
}
|
return ajax;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 加载对应角色菜单列表树
|
/**
|
||||||
*/
|
* 新增菜单
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
*/
|
||||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||||
{
|
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
@PostMapping
|
||||||
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
||||||
AjaxResult ajax = AjaxResult.success();
|
{
|
||||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
{
|
||||||
return ajax;
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
}
|
||||||
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||||
/**
|
{
|
||||||
* 新增菜单
|
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
*/
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
menu.setCreateBy(getUsername());
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
return toAjax(menuService.insertMenu(menu));
|
||||||
@PostMapping
|
}
|
||||||
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
|
||||||
{
|
/**
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
* 修改菜单
|
||||||
{
|
*/
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||||
}
|
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
@PutMapping
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||||
}
|
{
|
||||||
menu.setCreateBy(SecurityUtils.getUsername());
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
return toAjax(menuService.insertMenu(menu));
|
}
|
||||||
}
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||||
|
{
|
||||||
/**
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
* 修改菜单
|
}
|
||||||
*/
|
else if (menu.getMenuId().equals(menu.getParentId()))
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
{
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
@PutMapping
|
}
|
||||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
menu.setUpdateBy(getUsername());
|
||||||
{
|
return toAjax(menuService.updateMenu(menu));
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
}
|
||||||
{
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
/**
|
||||||
}
|
* 删除菜单
|
||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
*/
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||||
{
|
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
@DeleteMapping("/{menuId}")
|
||||||
}
|
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
||||||
else if (menu.getMenuId().equals(menu.getParentId()))
|
{
|
||||||
{
|
if (menuService.hasChildByMenuId(menuId))
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
{
|
||||||
}
|
return AjaxResult.error("存在子菜单,不允许删除");
|
||||||
menu.setUpdateBy(SecurityUtils.getUsername());
|
}
|
||||||
return toAjax(menuService.updateMenu(menu));
|
if (menuService.checkMenuExistRole(menuId))
|
||||||
}
|
{
|
||||||
|
return AjaxResult.error("菜单已分配,不允许删除");
|
||||||
/**
|
}
|
||||||
* 删除菜单
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
*/
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{menuId}")
|
|
||||||
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
|
||||||
{
|
|
||||||
if (menuService.hasChildByMenuId(menuId))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("存在子菜单,不允许删除");
|
|
||||||
}
|
|
||||||
if (menuService.checkMenuExistRole(menuId))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("菜单已分配,不允许删除");
|
|
||||||
}
|
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,92 +1,91 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
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;
|
||||||
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.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.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.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.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
|
||||||
|
/**
|
||||||
/**
|
* 公告 信息操作处理
|
||||||
* 公告 信息操作处理
|
*
|
||||||
*
|
* @author ruoyi
|
||||||
* @author ruoyi
|
*/
|
||||||
*/
|
@RestController
|
||||||
@RestController
|
@RequestMapping("/system/notice")
|
||||||
@RequestMapping("/system/notice")
|
public class SysNoticeController extends BaseController
|
||||||
public class SysNoticeController extends BaseController
|
{
|
||||||
{
|
@Autowired
|
||||||
@Autowired
|
private ISysNoticeService noticeService;
|
||||||
private ISysNoticeService noticeService;
|
|
||||||
|
/**
|
||||||
/**
|
* 获取通知公告列表
|
||||||
* 获取通知公告列表
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
@GetMapping("/list")
|
||||||
@GetMapping("/list")
|
public TableDataInfo list(SysNotice notice)
|
||||||
public TableDataInfo list(SysNotice notice)
|
{
|
||||||
{
|
startPage();
|
||||||
startPage();
|
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
return getDataTable(list);
|
||||||
return getDataTable(list);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 根据通知公告编号获取详细信息
|
||||||
* 根据通知公告编号获取详细信息
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
@GetMapping(value = "/{noticeId}")
|
||||||
@GetMapping(value = "/{noticeId}")
|
public AjaxResult getInfo(@PathVariable Long noticeId)
|
||||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
{
|
||||||
{
|
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||||
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 新增通知公告
|
||||||
* 新增通知公告
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@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));
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 修改通知公告
|
||||||
* 修改通知公告
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@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));
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 删除通知公告
|
||||||
* 删除通知公告
|
*/
|
||||||
*/
|
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{noticeIds}")
|
||||||
@DeleteMapping("/{noticeIds}")
|
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
||||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
{
|
||||||
{
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,130 +1,130 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位信息操作处理
|
* 岗位信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/post")
|
@RequestMapping("/system/post")
|
||||||
public class SysPostController extends BaseController
|
public class SysPostController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPostService postService;
|
private ISysPostService postService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取岗位列表
|
* 获取岗位列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysPost post)
|
public TableDataInfo list(SysPost post)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||||
@GetMapping("/export")
|
@PostMapping("/export")
|
||||||
public AjaxResult export(SysPost post)
|
public void export(HttpServletResponse response, 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);
|
||||||
return util.exportExcel(list, "岗位数据");
|
util.exportExcel(response, list, "岗位数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位编号获取详细信息
|
* 根据岗位编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long postId)
|
public AjaxResult getInfo(@PathVariable Long postId)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(postService.selectPostById(postId));
|
return AjaxResult.success(postService.selectPostById(postId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增岗位
|
* 新增岗位
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
public AjaxResult add(@Validated @RequestBody SysPost post)
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setCreateBy(SecurityUtils.getUsername());
|
post.setCreateBy(getUsername());
|
||||||
return toAjax(postService.insertPost(post));
|
return toAjax(postService.insertPost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改岗位
|
* 修改岗位
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setUpdateBy(SecurityUtils.getUsername());
|
post.setUpdateBy(getUsername());
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除岗位
|
* 删除岗位
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{postIds}")
|
@DeleteMapping("/{postIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] postIds)
|
public AjaxResult remove(@PathVariable Long[] postIds)
|
||||||
{
|
{
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取岗位选择框列表
|
* 获取岗位选择框列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect()
|
public AjaxResult optionselect()
|
||||||
{
|
{
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
return AjaxResult.success(posts);
|
return AjaxResult.success(posts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,139 +1,142 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.io.IOException;
|
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;
|
||||||
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
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.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
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.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.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.file.FileUploadUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
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;
|
|
||||||
|
/**
|
||||||
/**
|
* 个人信息 业务处理
|
||||||
* 个人信息 业务处理
|
*
|
||||||
*
|
* @author ruoyi
|
||||||
* @author ruoyi
|
*/
|
||||||
*/
|
@RestController
|
||||||
@RestController
|
@RequestMapping("/system/user/profile")
|
||||||
@RequestMapping("/system/user/profile")
|
public class SysProfileController extends BaseController
|
||||||
public class SysProfileController extends BaseController
|
{
|
||||||
{
|
@Autowired
|
||||||
@Autowired
|
private ISysUserService userService;
|
||||||
private ISysUserService userService;
|
|
||||||
|
@Autowired
|
||||||
@Autowired
|
private TokenService tokenService;
|
||||||
private TokenService tokenService;
|
|
||||||
|
/**
|
||||||
/**
|
* 个人信息
|
||||||
* 个人信息
|
*/
|
||||||
*/
|
@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()));
|
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||||
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
return ajax;
|
||||||
return ajax;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 修改用户
|
||||||
* 修改用户
|
*/
|
||||||
*/
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@PutMapping
|
||||||
@PutMapping
|
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
{
|
||||||
{
|
LoginUser loginUser = getLoginUser();
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
SysUser sysUser = loginUser.getUser();
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
user.setUserName(sysUser.getUserName());
|
||||||
{
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
}
|
{
|
||||||
if (StringUtils.isNotEmpty(user.getEmail())
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
}
|
||||||
{
|
if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
}
|
{
|
||||||
if (userService.updateUserProfile(user) > 0)
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
{
|
}
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
user.setUserId(sysUser.getUserId());
|
||||||
// 更新缓存用户信息
|
user.setPassword(null);
|
||||||
loginUser.getUser().setNickName(user.getNickName());
|
if (userService.updateUserProfile(user) > 0)
|
||||||
loginUser.getUser().setPhonenumber(user.getPhonenumber());
|
{
|
||||||
loginUser.getUser().setEmail(user.getEmail());
|
// 更新缓存用户信息
|
||||||
loginUser.getUser().setSex(user.getSex());
|
sysUser.setNickName(user.getNickName());
|
||||||
tokenService.setLoginUser(loginUser);
|
sysUser.setPhonenumber(user.getPhonenumber());
|
||||||
return AjaxResult.success();
|
sysUser.setEmail(user.getEmail());
|
||||||
}
|
sysUser.setSex(user.getSex());
|
||||||
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
tokenService.setLoginUser(loginUser);
|
||||||
}
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
/**
|
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||||
* 重置密码
|
}
|
||||||
*/
|
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
/**
|
||||||
@PutMapping("/updatePwd")
|
* 重置密码
|
||||||
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
*/
|
||||||
{
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
@PutMapping("/updatePwd")
|
||||||
String userName = loginUser.getUsername();
|
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
||||||
String password = loginUser.getPassword();
|
{
|
||||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
LoginUser loginUser = getLoginUser();
|
||||||
{
|
String userName = loginUser.getUsername();
|
||||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
String password = loginUser.getPassword();
|
||||||
}
|
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||||
if (SecurityUtils.matchesPassword(newPassword, password))
|
{
|
||||||
{
|
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||||
return AjaxResult.error("新密码不能与旧密码相同");
|
}
|
||||||
}
|
if (SecurityUtils.matchesPassword(newPassword, password))
|
||||||
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
{
|
||||||
{
|
return AjaxResult.error("新密码不能与旧密码相同");
|
||||||
// 更新缓存用户密码
|
}
|
||||||
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
||||||
tokenService.setLoginUser(loginUser);
|
{
|
||||||
return AjaxResult.success();
|
// 更新缓存用户密码
|
||||||
}
|
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
tokenService.setLoginUser(loginUser);
|
||||||
}
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
/**
|
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||||
* 头像上传
|
}
|
||||||
*/
|
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
/**
|
||||||
@PostMapping("/avatar")
|
* 头像上传
|
||||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
*/
|
||||||
{
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
if (!file.isEmpty())
|
@PostMapping("/avatar")
|
||||||
{
|
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
{
|
||||||
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
if (!file.isEmpty())
|
||||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
{
|
||||||
{
|
LoginUser loginUser = getLoginUser();
|
||||||
AjaxResult ajax = AjaxResult.success();
|
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
||||||
ajax.put("imgUrl", avatar);
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
||||||
// 更新缓存用户头像
|
{
|
||||||
loginUser.getUser().setAvatar(avatar);
|
AjaxResult ajax = AjaxResult.success();
|
||||||
tokenService.setLoginUser(loginUser);
|
ajax.put("imgUrl", avatar);
|
||||||
return ajax;
|
// 更新缓存用户头像
|
||||||
}
|
loginUser.getUser().setAvatar(avatar);
|
||||||
}
|
tokenService.setLoginUser(loginUser);
|
||||||
return AjaxResult.error("上传图片异常,请联系管理员");
|
return ajax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return AjaxResult.error("上传图片异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
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,182 +1,245 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
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.service.ISysRoleService;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
/**
|
|
||||||
* 角色信息
|
/**
|
||||||
*
|
* 角色信息
|
||||||
* @author ruoyi
|
*
|
||||||
*/
|
* @author ruoyi
|
||||||
@RestController
|
*/
|
||||||
@RequestMapping("/system/role")
|
@RestController
|
||||||
public class SysRoleController extends BaseController
|
@RequestMapping("/system/role")
|
||||||
{
|
public class SysRoleController extends BaseController
|
||||||
@Autowired
|
{
|
||||||
private ISysRoleService roleService;
|
@Autowired
|
||||||
|
private ISysRoleService roleService;
|
||||||
@Autowired
|
|
||||||
private TokenService tokenService;
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
@Autowired
|
|
||||||
private SysPermissionService permissionService;
|
@Autowired
|
||||||
|
private SysPermissionService permissionService;
|
||||||
@Autowired
|
|
||||||
private ISysUserService userService;
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
|
||||||
@GetMapping("/list")
|
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||||
public TableDataInfo list(SysRole role)
|
@GetMapping("/list")
|
||||||
{
|
public TableDataInfo list(SysRole role)
|
||||||
startPage();
|
{
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
startPage();
|
||||||
return getDataTable(list);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
}
|
return getDataTable(list);
|
||||||
|
}
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||||
public AjaxResult export(SysRole role)
|
@PostMapping("/export")
|
||||||
{
|
public void export(HttpServletResponse response, SysRole role)
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
{
|
||||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
return util.exportExcel(list, "角色数据");
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||||
}
|
util.exportExcel(response, list, "角色数据");
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 根据角色编号获取详细信息
|
/**
|
||||||
*/
|
* 根据角色编号获取详细信息
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
*/
|
||||||
@GetMapping(value = "/{roleId}")
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
public AjaxResult getInfo(@PathVariable Long roleId)
|
@GetMapping(value = "/{roleId}")
|
||||||
{
|
public AjaxResult getInfo(@PathVariable Long roleId)
|
||||||
return AjaxResult.success(roleService.selectRoleById(roleId));
|
{
|
||||||
}
|
roleService.checkRoleDataScope(roleId);
|
||||||
|
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||||
/**
|
}
|
||||||
* 新增角色
|
|
||||||
*/
|
/**
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
* 新增角色
|
||||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
*/
|
||||||
@PostMapping
|
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||||
public AjaxResult add(@Validated @RequestBody SysRole role)
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||||
{
|
@PostMapping
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
public AjaxResult add(@Validated @RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
}
|
{
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
{
|
}
|
||||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||||
}
|
{
|
||||||
role.setCreateBy(SecurityUtils.getUsername());
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
return toAjax(roleService.insertRole(role));
|
}
|
||||||
|
role.setCreateBy(getUsername());
|
||||||
}
|
return toAjax(roleService.insertRole(role));
|
||||||
|
|
||||||
/**
|
}
|
||||||
* 修改保存角色
|
|
||||||
*/
|
/**
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
* 修改保存角色
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
*/
|
||||||
@PutMapping
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
{
|
@PutMapping
|
||||||
roleService.checkRoleAllowed(role);
|
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
{
|
||||||
{
|
roleService.checkRoleAllowed(role);
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
}
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
{
|
||||||
{
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
}
|
||||||
}
|
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||||
role.setUpdateBy(SecurityUtils.getUsername());
|
{
|
||||||
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
if (roleService.updateRole(role) > 0)
|
}
|
||||||
{
|
role.setUpdateBy(getUsername());
|
||||||
// 更新缓存用户权限
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
if (roleService.updateRole(role) > 0)
|
||||||
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
{
|
||||||
{
|
// 更新缓存用户权限
|
||||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
LoginUser loginUser = getLoginUser();
|
||||||
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
||||||
tokenService.setLoginUser(loginUser);
|
{
|
||||||
}
|
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||||
return AjaxResult.success();
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||||
}
|
tokenService.setLoginUser(loginUser);
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
}
|
||||||
}
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
/**
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||||
* 修改保存数据权限
|
}
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
/**
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
* 修改保存数据权限
|
||||||
@PutMapping("/dataScope")
|
*/
|
||||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
{
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
roleService.checkRoleAllowed(role);
|
@PutMapping("/dataScope")
|
||||||
return toAjax(roleService.authDataScope(role));
|
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||||
}
|
{
|
||||||
|
roleService.checkRoleAllowed(role);
|
||||||
/**
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
* 状态修改
|
return toAjax(roleService.authDataScope(role));
|
||||||
*/
|
}
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
/**
|
||||||
@PutMapping("/changeStatus")
|
* 状态修改
|
||||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
*/
|
||||||
{
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
roleService.checkRoleAllowed(role);
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
role.setUpdateBy(SecurityUtils.getUsername());
|
@PutMapping("/changeStatus")
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||||
}
|
{
|
||||||
|
roleService.checkRoleAllowed(role);
|
||||||
/**
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
* 删除角色
|
role.setUpdateBy(getUsername());
|
||||||
*/
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
}
|
||||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{roleIds}")
|
/**
|
||||||
public AjaxResult remove(@PathVariable Long[] roleIds)
|
* 删除角色
|
||||||
{
|
*/
|
||||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||||
}
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{roleIds}")
|
||||||
/**
|
public AjaxResult remove(@PathVariable Long[] roleIds)
|
||||||
* 获取角色选择框列表
|
{
|
||||||
*/
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
}
|
||||||
@GetMapping("/optionselect")
|
|
||||||
public AjaxResult optionselect()
|
/**
|
||||||
{
|
* 获取角色选择框列表
|
||||||
return AjaxResult.success(roleService.selectRoleAll());
|
*/
|
||||||
}
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
}
|
@GetMapping("/optionselect")
|
||||||
|
public AjaxResult optionselect()
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,205 +1,237 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
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 org.springframework.beans.factory.annotation.Autowired;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.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;
|
|
||||||
|
/**
|
||||||
/**
|
* 用户信息
|
||||||
* 用户信息
|
*
|
||||||
*
|
* @author ruoyi
|
||||||
* @author ruoyi
|
*/
|
||||||
*/
|
@RestController
|
||||||
@RestController
|
@RequestMapping("/system/user")
|
||||||
@RequestMapping("/system/user")
|
public class SysUserController extends BaseController
|
||||||
public class SysUserController extends BaseController
|
{
|
||||||
{
|
@Autowired
|
||||||
@Autowired
|
private ISysUserService userService;
|
||||||
private ISysUserService userService;
|
|
||||||
|
@Autowired
|
||||||
@Autowired
|
private ISysRoleService roleService;
|
||||||
private ISysRoleService roleService;
|
|
||||||
|
@Autowired
|
||||||
@Autowired
|
private ISysPostService postService;
|
||||||
private ISysPostService postService;
|
|
||||||
|
/**
|
||||||
@Autowired
|
* 获取用户列表
|
||||||
private TokenService tokenService;
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||||
/**
|
@GetMapping("/list")
|
||||||
* 获取用户列表
|
public TableDataInfo list(SysUser user)
|
||||||
*/
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
startPage();
|
||||||
@GetMapping("/list")
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
public TableDataInfo list(SysUser user)
|
return getDataTable(list);
|
||||||
{
|
}
|
||||||
startPage();
|
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
return getDataTable(list);
|
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||||
}
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysUser user)
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
@GetMapping("/export")
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
public AjaxResult export(SysUser user)
|
util.exportExcel(response, list, "用户数据");
|
||||||
{
|
}
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
return util.exportExcel(list, "用户数据");
|
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||||
}
|
@PostMapping("/importData")
|
||||||
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
@PostMapping("/importData")
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
String operName = getUsername();
|
||||||
{
|
String message = userService.importUser(userList, updateSupport, operName);
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
return AjaxResult.success(message);
|
||||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
}
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
||||||
String operName = loginUser.getUsername();
|
@PostMapping("/importTemplate")
|
||||||
String message = userService.importUser(userList, updateSupport, operName);
|
public void importTemplate(HttpServletResponse response)
|
||||||
return AjaxResult.success(message);
|
{
|
||||||
}
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
|
util.importTemplateExcel(response, "用户数据");
|
||||||
@GetMapping("/importTemplate")
|
}
|
||||||
public AjaxResult importTemplate()
|
|
||||||
{
|
/**
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
* 根据用户编号获取详细信息
|
||||||
return util.importTemplateExcel("用户数据");
|
*/
|
||||||
}
|
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||||
|
@GetMapping(value = { "/", "/{userId}" })
|
||||||
/**
|
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||||
* 根据用户编号获取详细信息
|
{
|
||||||
*/
|
userService.checkUserDataScope(userId);
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
AjaxResult ajax = AjaxResult.success();
|
||||||
@GetMapping(value = { "/", "/{userId}" })
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
{
|
ajax.put("posts", postService.selectPostAll());
|
||||||
AjaxResult ajax = AjaxResult.success();
|
if (StringUtils.isNotNull(userId))
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
{
|
||||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
SysUser sysUser = userService.selectUserById(userId);
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||||
if (StringUtils.isNotNull(userId))
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
{
|
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
}
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
return ajax;
|
||||||
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
}
|
||||||
}
|
|
||||||
return ajax;
|
/**
|
||||||
}
|
* 新增用户
|
||||||
|
*/
|
||||||
/**
|
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||||
* 新增用户
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
*/
|
@PostMapping
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
{
|
||||||
@PostMapping
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
||||||
public AjaxResult add(@Validated @RequestBody SysUser user)
|
{
|
||||||
{
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
}
|
||||||
{
|
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
}
|
{
|
||||||
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
}
|
||||||
{
|
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
}
|
{
|
||||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
}
|
||||||
{
|
user.setCreateBy(getUsername());
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
}
|
return toAjax(userService.insertUser(user));
|
||||||
user.setCreateBy(SecurityUtils.getUsername());
|
}
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
||||||
return toAjax(userService.insertUser(user));
|
/**
|
||||||
}
|
* 修改用户
|
||||||
|
*/
|
||||||
/**
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
* 修改用户
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
*/
|
@PutMapping
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
{
|
||||||
@PutMapping
|
userService.checkUserAllowed(user);
|
||||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
userService.checkUserDataScope(user.getUserId());
|
||||||
{
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
userService.checkUserAllowed(user);
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
{
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
{
|
}
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
}
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
{
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
{
|
}
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
user.setUpdateBy(getUsername());
|
||||||
}
|
return toAjax(userService.updateUser(user));
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
}
|
||||||
return toAjax(userService.updateUser(user));
|
|
||||||
}
|
/**
|
||||||
|
* 删除用户
|
||||||
/**
|
*/
|
||||||
* 删除用户
|
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||||
*/
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
@DeleteMapping("/{userIds}")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||||
@DeleteMapping("/{userIds}")
|
{
|
||||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
if (ArrayUtils.contains(userIds, getUserId()))
|
||||||
{
|
{
|
||||||
return toAjax(userService.deleteUserByIds(userIds));
|
return error("当前用户不能删除");
|
||||||
}
|
}
|
||||||
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
/**
|
}
|
||||||
* 重置密码
|
|
||||||
*/
|
/**
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
* 重置密码
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
*/
|
||||||
@PutMapping("/resetPwd")
|
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
{
|
@PutMapping("/resetPwd")
|
||||||
userService.checkUserAllowed(user);
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
{
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
userService.checkUserAllowed(user);
|
||||||
return toAjax(userService.resetPwd(user));
|
userService.checkUserDataScope(user.getUserId());
|
||||||
}
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
|
user.setUpdateBy(getUsername());
|
||||||
/**
|
return toAjax(userService.resetPwd(user));
|
||||||
* 状态修改
|
}
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
/**
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
* 状态修改
|
||||||
@PutMapping("/changeStatus")
|
*/
|
||||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
{
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
userService.checkUserAllowed(user);
|
@PutMapping("/changeStatus")
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||||
return toAjax(userService.updateUserStatus(user));
|
{
|
||||||
}
|
userService.checkUserAllowed(user);
|
||||||
}
|
userService.checkUserDataScope(user.getUserId());
|
||||||
|
user.setUpdateBy(getUsername());
|
||||||
|
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", SysUser.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);
|
||||||
|
userService.insertUserAuth(userId, roleIds);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
package com.ruoyi.web.controller.tool;
|
package com.ruoyi.web.controller.tool;
|
||||||
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
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 com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swagger 接口
|
* swagger 接口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/tool/swagger")
|
@RequestMapping("/tool/swagger")
|
||||||
public class SwaggerController extends BaseController
|
public class SwaggerController extends BaseController
|
||||||
{
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String index()
|
public String index()
|
||||||
{
|
{
|
||||||
return redirect("/swagger-ui.html");
|
return redirect("/swagger-ui.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,175 +1,181 @@
|
|||||||
package com.ruoyi.web.controller.tool;
|
package com.ruoyi.web.controller.tool;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import io.swagger.annotations.Api;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
/**
|
import io.swagger.annotations.ApiOperation;
|
||||||
* swagger 用户测试方法
|
|
||||||
*
|
/**
|
||||||
* @author ruoyi
|
* swagger 用户测试方法
|
||||||
*/
|
*
|
||||||
@Api("用户信息管理")
|
* @author ruoyi
|
||||||
@RestController
|
*/
|
||||||
@RequestMapping("/test/user")
|
@Api("用户信息管理")
|
||||||
public class TestController extends BaseController
|
@RestController
|
||||||
{
|
@RequestMapping("/test/user")
|
||||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
public class TestController extends BaseController
|
||||||
{
|
{
|
||||||
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||||
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
{
|
||||||
}
|
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
||||||
|
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
||||||
@ApiOperation("获取用户列表")
|
}
|
||||||
@GetMapping("/list")
|
|
||||||
public AjaxResult userList()
|
@ApiOperation("获取用户列表")
|
||||||
{
|
@GetMapping("/list")
|
||||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
public AjaxResult userList()
|
||||||
return AjaxResult.success(userList);
|
{
|
||||||
}
|
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||||
|
return AjaxResult.success(userList);
|
||||||
@ApiOperation("获取用户详细")
|
}
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
|
||||||
@GetMapping("/{userId}")
|
@ApiOperation("获取用户详细")
|
||||||
public AjaxResult getUser(@PathVariable Integer userId)
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||||
{
|
@GetMapping("/{userId}")
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
public AjaxResult getUser(@PathVariable Integer userId)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(users.get(userId));
|
if (!users.isEmpty() && users.containsKey(userId))
|
||||||
}
|
{
|
||||||
else
|
return AjaxResult.success(users.get(userId));
|
||||||
{
|
}
|
||||||
return AjaxResult.error("用户不存在");
|
else
|
||||||
}
|
{
|
||||||
}
|
return error("用户不存在");
|
||||||
|
}
|
||||||
@ApiOperation("新增用户")
|
}
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
|
||||||
@PostMapping("/save")
|
@ApiOperation("新增用户")
|
||||||
public AjaxResult save(UserEntity user)
|
@ApiImplicitParams({
|
||||||
{
|
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
|
||||||
{
|
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
|
||||||
return AjaxResult.error("用户ID不能为空");
|
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
||||||
}
|
})
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
@PostMapping("/save")
|
||||||
}
|
public AjaxResult save(UserEntity user)
|
||||||
|
{
|
||||||
@ApiOperation("更新用户")
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
{
|
||||||
@PutMapping("/update")
|
return error("用户ID不能为空");
|
||||||
public AjaxResult update(UserEntity user)
|
}
|
||||||
{
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
}
|
||||||
{
|
|
||||||
return AjaxResult.error("用户ID不能为空");
|
@ApiOperation("更新用户")
|
||||||
}
|
@PutMapping("/update")
|
||||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
public AjaxResult update(@RequestBody UserEntity user)
|
||||||
{
|
{
|
||||||
return AjaxResult.error("用户不存在");
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||||
}
|
{
|
||||||
users.remove(user.getUserId());
|
return error("用户ID不能为空");
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
}
|
||||||
}
|
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
||||||
|
{
|
||||||
@ApiOperation("删除用户信息")
|
return error("用户不存在");
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
}
|
||||||
@DeleteMapping("/{userId}")
|
users.remove(user.getUserId());
|
||||||
public AjaxResult delete(@PathVariable Integer userId)
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
{
|
}
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
|
||||||
{
|
@ApiOperation("删除用户信息")
|
||||||
users.remove(userId);
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||||
return AjaxResult.success();
|
@DeleteMapping("/{userId}")
|
||||||
}
|
public AjaxResult delete(@PathVariable Integer userId)
|
||||||
else
|
{
|
||||||
{
|
if (!users.isEmpty() && users.containsKey(userId))
|
||||||
return AjaxResult.error("用户不存在");
|
{
|
||||||
}
|
users.remove(userId);
|
||||||
}
|
return success();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
@ApiModel("用户实体")
|
{
|
||||||
class UserEntity
|
return error("用户不存在");
|
||||||
{
|
}
|
||||||
@ApiModelProperty("用户ID")
|
}
|
||||||
private Integer userId;
|
}
|
||||||
|
|
||||||
@ApiModelProperty("用户名称")
|
@ApiModel(value = "UserEntity", description = "用户实体")
|
||||||
private String username;
|
class UserEntity
|
||||||
|
{
|
||||||
@ApiModelProperty("用户密码")
|
@ApiModelProperty("用户ID")
|
||||||
private String password;
|
private Integer userId;
|
||||||
|
|
||||||
@ApiModelProperty("用户手机")
|
@ApiModelProperty("用户名称")
|
||||||
private String mobile;
|
private String username;
|
||||||
|
|
||||||
public UserEntity()
|
@ApiModelProperty("用户密码")
|
||||||
{
|
private String password;
|
||||||
|
|
||||||
}
|
@ApiModelProperty("用户手机")
|
||||||
|
private String mobile;
|
||||||
public UserEntity(Integer userId, String username, String password, String mobile)
|
|
||||||
{
|
public UserEntity()
|
||||||
this.userId = userId;
|
{
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
}
|
||||||
this.mobile = mobile;
|
|
||||||
}
|
public UserEntity(Integer userId, String username, String password, String mobile)
|
||||||
|
{
|
||||||
public Integer getUserId()
|
this.userId = userId;
|
||||||
{
|
this.username = username;
|
||||||
return userId;
|
this.password = password;
|
||||||
}
|
this.mobile = mobile;
|
||||||
|
}
|
||||||
public void setUserId(Integer userId)
|
|
||||||
{
|
public Integer getUserId()
|
||||||
this.userId = userId;
|
{
|
||||||
}
|
return userId;
|
||||||
|
}
|
||||||
public String getUsername()
|
|
||||||
{
|
public void setUserId(Integer userId)
|
||||||
return username;
|
{
|
||||||
}
|
this.userId = userId;
|
||||||
|
}
|
||||||
public void setUsername(String username)
|
|
||||||
{
|
public String getUsername()
|
||||||
this.username = username;
|
{
|
||||||
}
|
return username;
|
||||||
|
}
|
||||||
public String getPassword()
|
|
||||||
{
|
public void setUsername(String username)
|
||||||
return password;
|
{
|
||||||
}
|
this.username = username;
|
||||||
|
}
|
||||||
public void setPassword(String password)
|
|
||||||
{
|
public String getPassword()
|
||||||
this.password = password;
|
{
|
||||||
}
|
return password;
|
||||||
|
}
|
||||||
public String getMobile()
|
|
||||||
{
|
public void setPassword(String password)
|
||||||
return mobile;
|
{
|
||||||
}
|
this.password = password;
|
||||||
|
}
|
||||||
public void setMobile(String mobile)
|
|
||||||
{
|
public String getMobile()
|
||||||
this.mobile = mobile;
|
{
|
||||||
}
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMobile(String mobile)
|
||||||
|
{
|
||||||
|
this.mobile = mobile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,125 +1,125 @@
|
|||||||
package com.ruoyi.web.core.config;
|
package com.ruoyi.web.core.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import io.swagger.models.auth.In;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.service.ApiInfo;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
import springfox.documentation.service.ApiKey;
|
import springfox.documentation.service.ApiInfo;
|
||||||
import springfox.documentation.service.AuthorizationScope;
|
import springfox.documentation.service.ApiKey;
|
||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.AuthorizationScope;
|
||||||
import springfox.documentation.service.SecurityReference;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.service.SecurityReference;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.service.SecurityScheme;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
/**
|
|
||||||
* Swagger2的接口配置
|
/**
|
||||||
*
|
* Swagger2的接口配置
|
||||||
* @author ruoyi
|
*
|
||||||
*/
|
* @author ruoyi
|
||||||
@Configuration
|
*/
|
||||||
@EnableSwagger2
|
@Configuration
|
||||||
public class SwaggerConfig
|
public class SwaggerConfig
|
||||||
{
|
{
|
||||||
/** 系统基础配置 */
|
/** 系统基础配置 */
|
||||||
@Autowired
|
@Autowired
|
||||||
private RuoYiConfig ruoyiConfig;
|
private RuoYiConfig ruoyiConfig;
|
||||||
|
|
||||||
/** 是否开启swagger */
|
/** 是否开启swagger */
|
||||||
@Value("${swagger.enabled}")
|
@Value("${swagger.enabled}")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
/** 设置请求的统一前缀 */
|
/** 设置请求的统一前缀 */
|
||||||
@Value("${swagger.pathMapping}")
|
@Value("${swagger.pathMapping}")
|
||||||
private String pathMapping;
|
private String pathMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建API
|
* 创建API
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi()
|
public Docket createRestApi()
|
||||||
{
|
{
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.OAS_30)
|
||||||
// 是否启用Swagger
|
// 是否启用Swagger
|
||||||
.enable(enabled)
|
.enable(enabled)
|
||||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
// 设置哪些接口暴露给Swagger展示
|
// 设置哪些接口暴露给Swagger展示
|
||||||
.select()
|
.select()
|
||||||
// 扫描所有有注解的api,用这种方式更灵活
|
// 扫描所有有注解的api,用这种方式更灵活
|
||||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
// 扫描指定包中的swagger注解
|
// 扫描指定包中的swagger注解
|
||||||
// .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
|
// .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
|
||||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build()
|
.build()
|
||||||
/* 设置安全模式,swagger可以设置访问token */
|
/* 设置安全模式,swagger可以设置访问token */
|
||||||
.securitySchemes(securitySchemes())
|
.securitySchemes(securitySchemes())
|
||||||
.securityContexts(securityContexts())
|
.securityContexts(securityContexts())
|
||||||
.pathMapping(pathMapping);
|
.pathMapping(pathMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||||
*/
|
*/
|
||||||
private List<ApiKey> securitySchemes()
|
private List<SecurityScheme> securitySchemes()
|
||||||
{
|
{
|
||||||
List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
|
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
|
||||||
return apiKeyList;
|
return apiKeyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全上下文
|
* 安全上下文
|
||||||
*/
|
*/
|
||||||
private List<SecurityContext> securityContexts()
|
private List<SecurityContext> securityContexts()
|
||||||
{
|
{
|
||||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||||
securityContexts.add(
|
securityContexts.add(
|
||||||
SecurityContext.builder()
|
SecurityContext.builder()
|
||||||
.securityReferences(defaultAuth())
|
.securityReferences(defaultAuth())
|
||||||
.forPaths(PathSelectors.regex("^(?!auth).*$"))
|
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
||||||
.build());
|
.build());
|
||||||
return securityContexts;
|
return securityContexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认的安全上引用
|
* 默认的安全上引用
|
||||||
*/
|
*/
|
||||||
private List<SecurityReference> defaultAuth()
|
private List<SecurityReference> defaultAuth()
|
||||||
{
|
{
|
||||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||||
authorizationScopes[0] = authorizationScope;
|
authorizationScopes[0] = authorizationScope;
|
||||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||||
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
|
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
|
||||||
return securityReferences;
|
return securityReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加摘要信息
|
* 添加摘要信息
|
||||||
*/
|
*/
|
||||||
private ApiInfo apiInfo()
|
private ApiInfo apiInfo()
|
||||||
{
|
{
|
||||||
// 用ApiInfoBuilder进行定制
|
// 用ApiInfoBuilder进行定制
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
||||||
// 设置标题
|
// 设置标题
|
||||||
.title("标题:若依管理系统_接口文档")
|
.title("标题:若依管理系统_接口文档")
|
||||||
// 描述
|
// 描述
|
||||||
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
||||||
// 作者信息
|
// 作者信息
|
||||||
.contact(new Contact(ruoyiConfig.getName(), null, null))
|
.contact(new Contact(ruoyiConfig.getName(), null, null))
|
||||||
// 版本
|
// 版本
|
||||||
.version("版本号:" + ruoyiConfig.getVersion())
|
.version("版本号:" + ruoyiConfig.getVersion())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,57 @@
|
|||||||
# 数据源配置
|
# 数据源配置
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
druid:
|
druid:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://192.168.2.9:3306/nuoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
username: root
|
username: saas
|
||||||
password: password
|
password: XKrs123.
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
# 从数据源开关/默认关闭
|
# 从数据源开关/默认关闭
|
||||||
enabled: false
|
enabled: false
|
||||||
url:
|
url:
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
initialSize: 5
|
initialSize: 5
|
||||||
# 最小连接池数量
|
# 最小连接池数量
|
||||||
minIdle: 10
|
minIdle: 10
|
||||||
# 最大连接池数量
|
# 最大连接池数量
|
||||||
maxActive: 20
|
maxActive: 20
|
||||||
# 配置获取连接等待超时的时间
|
# 配置获取连接等待超时的时间
|
||||||
maxWait: 60000
|
maxWait: 60000
|
||||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
timeBetweenEvictionRunsMillis: 60000
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
minEvictableIdleTimeMillis: 300000
|
minEvictableIdleTimeMillis: 300000
|
||||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
maxEvictableIdleTimeMillis: 900000
|
maxEvictableIdleTimeMillis: 900000
|
||||||
# 配置检测连接是否有效
|
# 配置检测连接是否有效
|
||||||
validationQuery: SELECT 1 FROM DUAL
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
testWhileIdle: true
|
testWhileIdle: true
|
||||||
testOnBorrow: false
|
testOnBorrow: false
|
||||||
testOnReturn: false
|
testOnReturn: false
|
||||||
webStatFilter:
|
webStatFilter:
|
||||||
enabled: true
|
enabled: true
|
||||||
statViewServlet:
|
statViewServlet:
|
||||||
enabled: true
|
enabled: true
|
||||||
# 设置白名单,不填则允许所有访问
|
# 设置白名单,不填则允许所有访问
|
||||||
allow:
|
allow:
|
||||||
url-pattern: /druid/*
|
url-pattern: /druid/*
|
||||||
# 控制台管理用户名和密码
|
# 控制台管理用户名和密码
|
||||||
login-username: ruoyi
|
login-username: ruoyi
|
||||||
login-password: 123456
|
login-password: 123456
|
||||||
filter:
|
filter:
|
||||||
stat:
|
stat:
|
||||||
enabled: true
|
enabled: true
|
||||||
# 慢SQL记录
|
# 慢SQL记录
|
||||||
log-slow-sql: true
|
log-slow-sql: true
|
||||||
slow-sql-millis: 1000
|
slow-sql-millis: 1000
|
||||||
merge-sql: true
|
merge-sql: true
|
||||||
wall:
|
wall:
|
||||||
config:
|
config:
|
||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
@ -1,121 +1,126 @@
|
|||||||
# 项目相关配置
|
# 项目相关配置
|
||||||
ruoyi:
|
ruoyi:
|
||||||
# 名称
|
# 名称
|
||||||
name: RuoYi
|
name: RuoYi
|
||||||
# 版本
|
# 版本
|
||||||
version: 3.5.0
|
version: 3.8.2
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2021
|
copyrightYear: 2022
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
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
|
||||||
|
|
||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
server:
|
server:
|
||||||
# 服务器的HTTP端口,默认为8080
|
# 服务器的HTTP端口,默认为8080
|
||||||
port: 8080
|
port: 8080
|
||||||
servlet:
|
servlet:
|
||||||
# 应用的访问路径
|
# 应用的访问路径
|
||||||
context-path: /
|
context-path: /
|
||||||
tomcat:
|
tomcat:
|
||||||
# tomcat的URI编码
|
# tomcat的URI编码
|
||||||
uri-encoding: UTF-8
|
uri-encoding: UTF-8
|
||||||
# tomcat最大线程数,默认为200
|
# 连接数满后的排队数,默认为100
|
||||||
max-threads: 800
|
accept-count: 1000
|
||||||
# Tomcat启动初始化的线程数,默认值25
|
threads:
|
||||||
min-spare-threads: 30
|
# tomcat最大线程数,默认为200
|
||||||
|
max: 800
|
||||||
# 日志配置
|
# Tomcat启动初始化的线程数,默认值10
|
||||||
logging:
|
min-spare: 100
|
||||||
level:
|
|
||||||
com.ruoyi: debug
|
# 日志配置
|
||||||
org.springframework: warn
|
logging:
|
||||||
|
level:
|
||||||
# Spring配置
|
com.ruoyi: debug
|
||||||
spring:
|
org.springframework: warn
|
||||||
# 资源信息
|
|
||||||
messages:
|
# Spring配置
|
||||||
# 国际化资源文件路径
|
spring:
|
||||||
basename: i18n/messages
|
# config:
|
||||||
profiles:
|
# activate:
|
||||||
active: druid
|
# on-profile: druid
|
||||||
# 文件上传
|
profiles:
|
||||||
servlet:
|
active: druid
|
||||||
multipart:
|
# 资源信息
|
||||||
# 单个文件大小
|
messages:
|
||||||
max-file-size: 10MB
|
# 国际化资源文件路径
|
||||||
# 设置总上传的文件大小
|
basename: i18n/messages
|
||||||
max-request-size: 20MB
|
# 文件上传
|
||||||
# 服务模块
|
servlet:
|
||||||
devtools:
|
multipart:
|
||||||
restart:
|
# 单个文件大小
|
||||||
# 热部署开关
|
max-file-size: 10MB
|
||||||
enabled: true
|
# 设置总上传的文件大小
|
||||||
# redis 配置
|
max-request-size: 20MB
|
||||||
redis:
|
# 服务模块
|
||||||
# 地址
|
devtools:
|
||||||
host: localhost
|
restart:
|
||||||
# 端口,默认为6379
|
# 热部署开关
|
||||||
port: 6379
|
enabled: true
|
||||||
# 数据库索引
|
# redis 配置
|
||||||
database: 0
|
redis:
|
||||||
# 密码
|
# 地址
|
||||||
password:
|
host: localhost
|
||||||
# 连接超时时间
|
# 端口,默认为6379
|
||||||
timeout: 10s
|
port: 6379
|
||||||
lettuce:
|
# 数据库索引
|
||||||
pool:
|
database: 3
|
||||||
# 连接池中的最小空闲连接
|
# 密码
|
||||||
min-idle: 0
|
password: yhy_app
|
||||||
# 连接池中的最大空闲连接
|
# 连接超时时间
|
||||||
max-idle: 8
|
timeout: 10s
|
||||||
# 连接池的最大数据库连接数
|
lettuce:
|
||||||
max-active: 8
|
pool:
|
||||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
# 连接池中的最小空闲连接
|
||||||
max-wait: -1ms
|
min-idle: 0
|
||||||
|
# 连接池中的最大空闲连接
|
||||||
# token配置
|
max-idle: 8
|
||||||
token:
|
# 连接池的最大数据库连接数
|
||||||
# 令牌自定义标识
|
max-active: 8
|
||||||
header: Authorization
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
# 令牌密钥
|
max-wait: -1ms
|
||||||
secret: abcdefghijklmnopqrstuvwxyz
|
|
||||||
# 令牌有效期(默认30分钟)
|
# token配置
|
||||||
expireTime: 30
|
token:
|
||||||
|
# 令牌自定义标识
|
||||||
# MyBatis配置
|
header: Authorization
|
||||||
mybatis:
|
# 令牌密钥
|
||||||
# 搜索指定包别名
|
secret: abcdefghijklmnopqrstuvwxyz
|
||||||
typeAliasesPackage: com.ruoyi.**.domain
|
# 令牌有效期(默认30分钟)
|
||||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
expireTime: 30
|
||||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
|
||||||
# 加载全局的配置文件
|
# MyBatis配置
|
||||||
configLocation: classpath:mybatis/mybatis-config.xml
|
mybatis:
|
||||||
|
# 搜索指定包别名
|
||||||
# PageHelper分页插件
|
typeAliasesPackage: com.ruoyi.**.domain
|
||||||
pagehelper:
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
helperDialect: mysql
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
reasonable: true
|
# 加载全局的配置文件
|
||||||
supportMethodsArguments: true
|
configLocation: classpath:mybatis/mybatis-config.xml
|
||||||
params: count=countSql
|
|
||||||
|
# PageHelper分页插件
|
||||||
# Swagger配置
|
pagehelper:
|
||||||
swagger:
|
helperDialect: mysql
|
||||||
# 是否开启swagger
|
supportMethodsArguments: true
|
||||||
enabled: true
|
params: count=countSql
|
||||||
# 请求前缀
|
|
||||||
pathMapping: /dev-api
|
# Swagger配置
|
||||||
|
swagger:
|
||||||
# 防止XSS攻击
|
# 是否开启swagger
|
||||||
xss:
|
enabled: true
|
||||||
# 过滤开关
|
# 请求前缀
|
||||||
enabled: true
|
pathMapping: /dev-api
|
||||||
# 排除链接(多个用逗号分隔)
|
|
||||||
excludes: /system/notice/*
|
# 防止XSS攻击
|
||||||
# 匹配链接
|
xss:
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
# 过滤开关
|
||||||
|
enabled: true
|
||||||
|
# 排除链接(多个用逗号分隔)
|
||||||
|
excludes: /system/notice
|
||||||
|
# 匹配链接
|
||||||
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
Application Version: ${ruoyi.version}
|
Application Version: ${ruoyi.version}
|
||||||
Spring Boot Version: ${spring-boot.version}
|
Spring Boot Version: ${spring-boot.version}
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// _ooOoo_ //
|
// _ooOoo_ //
|
||||||
// o8888888o //
|
// o6666666o //
|
||||||
// 88" . "88 //
|
// 88" . "88 //
|
||||||
// (| ^_^ |) //
|
// (| ^_^ |) //
|
||||||
// O\ = /O //
|
// O\ = /O //
|
||||||
// ____/`---'\____ //
|
// ____/`---'\____ //
|
||||||
// .' \\| |// `. //
|
// .' \\| |// `. //
|
||||||
// / \\||| : |||// \ //
|
// / \\||| : |||// \ //
|
||||||
// / _||||| -:- |||||- \ //
|
// / _||||| -:- |||||- \ //
|
||||||
// | | \\\ - /// | | //
|
// | | \\\ - /// | | //
|
||||||
// | \_| ''\---/'' | | //
|
// | \_| ''\---/'' | | //
|
||||||
// \ .-\__ `-` ___/-. / //
|
// \ .-\__ `-` ___/-. / //
|
||||||
// ___`. .' /--.--\ `. . ___ //
|
// ___`. .' /--.--\ `. . ___ //
|
||||||
// ."" '< `.___\_<|>_/___.' >'"". //
|
// ."" '< `.___\_<|>_/___.' >'"". //
|
||||||
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
|
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
|
||||||
// \ \ `-. \_ __\ /__ _/ .-` / / //
|
// \ \ `-. \_ __\ /__ _/ .-` / / //
|
||||||
// ========`-.____`-.___\_____/___.-`____.-'======== //
|
// ========`-.____`-.___\_____/___.-`____.-'======== //
|
||||||
// `=---=' //
|
// `=---=' //
|
||||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||||
// 佛祖保佑 永不宕机 永无BUG //
|
// 佛祖保佑 永不宕机 永无BUG //
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
@ -1,36 +1,37 @@
|
|||||||
#错误消息
|
#错误消息
|
||||||
not.null=* 必须填写
|
not.null=* 必须填写
|
||||||
user.jcaptcha.error=验证码错误
|
user.jcaptcha.error=验证码错误
|
||||||
user.jcaptcha.expire=验证码已失效
|
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}次,帐户锁定10分钟
|
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟
|
||||||
user.password.delete=对不起,您的账号已被删除
|
user.password.delete=对不起,您的账号已被删除
|
||||||
user.blocked=用户已封禁,请联系管理员
|
user.blocked=用户已封禁,请联系管理员
|
||||||
role.blocked=角色已封禁,请联系管理员
|
role.blocked=角色已封禁,请联系管理员
|
||||||
user.logout.success=退出成功
|
user.logout.success=退出成功
|
||||||
|
|
||||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||||
|
|
||||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||||
user.password.not.valid=* 5-50个字符
|
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.notfound=请重新登录
|
user.register.success=注册成功
|
||||||
user.forcelogout=管理员强制退出,请重新登录
|
user.notfound=请重新登录
|
||||||
user.unknown.error=未知错误,请重新登录
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
|
user.unknown.error=未知错误,请重新登录
|
||||||
##文件上传消息
|
|
||||||
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
##文件上传消息
|
||||||
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||||
|
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||||
##权限
|
|
||||||
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
##权限
|
||||||
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
@ -1,93 +1,93 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="/home/ruoyi/logs" />
|
<property name="log.path" value="/home/ruoyi/logs" />
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
<!-- 控制台输出 -->
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
<!-- 系统日志输出 -->
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/sys-info.log</file>
|
<file>${log.path}/sys-info.log</file>
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志文件名格式 -->
|
<!-- 日志文件名格式 -->
|
||||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
<!-- 日志最大的历史 60天 -->
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<!-- 过滤的级别 -->
|
<!-- 过滤的级别 -->
|
||||||
<level>INFO</level>
|
<level>INFO</level>
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/sys-error.log</file>
|
<file>${log.path}/sys-error.log</file>
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志文件名格式 -->
|
<!-- 日志文件名格式 -->
|
||||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
<!-- 日志最大的历史 60天 -->
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<!-- 过滤的级别 -->
|
<!-- 过滤的级别 -->
|
||||||
<level>ERROR</level>
|
<level>ERROR</level>
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- 用户访问日志输出 -->
|
<!-- 用户访问日志输出 -->
|
||||||
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/sys-user.log</file>
|
<file>${log.path}/sys-user.log</file>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 按天回滚 daily -->
|
<!-- 按天回滚 daily -->
|
||||||
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
<!-- 日志最大的历史 60天 -->
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
<!-- 系统模块日志级别控制 -->
|
||||||
<logger name="com.ruoyi" level="info" />
|
<logger name="com.ruoyi" level="info" />
|
||||||
<!-- Spring日志级别控制 -->
|
<!-- Spring日志级别控制 -->
|
||||||
<logger name="org.springframework" level="warn" />
|
<logger name="org.springframework" level="warn" />
|
||||||
|
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="console" />
|
<appender-ref ref="console" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
<!--系统操作日志-->
|
<!--系统操作日志-->
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="file_info" />
|
<appender-ref ref="file_info" />
|
||||||
<appender-ref ref="file_error" />
|
<appender-ref ref="file_error" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
<!--系统用户操作日志-->
|
<!--系统用户操作日志-->
|
||||||
<logger name="sys-user" level="info">
|
<logger name="sys-user" level="info">
|
||||||
<appender-ref ref="sys-user"/>
|
<appender-ref ref="sys-user"/>
|
||||||
</logger>
|
</logger>
|
||||||
</configuration>
|
</configuration>
|
@ -1,15 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE configuration
|
<!DOCTYPE configuration
|
||||||
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="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 -->
|
<setting name="cacheEnabled" value="true" />
|
||||||
<setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 -->
|
<!-- 允许JDBC 支持自动生成主键 -->
|
||||||
<setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 -->
|
<setting name="useGeneratedKeys" value="true" />
|
||||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
|
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
||||||
</settings>
|
<setting name="defaultExecutorType" value="SIMPLE" />
|
||||||
|
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||||
</configuration>
|
<setting name="logImpl" value="SLF4J" />
|
||||||
|
<!-- 使用驼峰命名法转换字段 -->
|
||||||
|
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
||||||
|
</settings>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.5.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -43,8 +43,8 @@
|
|||||||
|
|
||||||
<!-- 自定义验证注解 -->
|
<!-- 自定义验证注解 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>validation-api</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--常用工具类 -->
|
<!--常用工具类 -->
|
||||||
@ -89,12 +89,18 @@
|
|||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--Token生成与解析-->
|
<!-- 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>
|
||||||
|
@ -5,6 +5,9 @@ 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数据注解
|
||||||
@ -55,11 +58,6 @@ public @interface Excel
|
|||||||
*/
|
*/
|
||||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出类型(0数字 1字符串)
|
|
||||||
*/
|
|
||||||
public ColumnType cellType() default ColumnType.STRING;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度 单位为字符
|
* 导出时在excel中每个列的高度 单位为字符
|
||||||
*/
|
*/
|
||||||
@ -106,9 +104,29 @@ public @interface Excel
|
|||||||
public boolean isStatistics() default false;
|
public boolean isStatistics() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
|
* 导出类型(0数字 1字符串)
|
||||||
*/
|
*/
|
||||||
Align align() default Align.AUTO;
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字体颜色
|
||||||
|
*/
|
||||||
|
public IndexedColors color() default IndexedColors.BLACK;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字段对齐方式
|
||||||
|
*/
|
||||||
|
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义数据处理器
|
||||||
|
*/
|
||||||
|
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义数据处理器参数
|
||||||
|
*/
|
||||||
|
public String[] args() default {};
|
||||||
|
|
||||||
public enum Align
|
public enum Align
|
||||||
{
|
{
|
||||||
|
@ -14,5 +14,5 @@ import java.lang.annotation.Target;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Excels
|
public @interface Excels
|
||||||
{
|
{
|
||||||
Excel[] value();
|
public Excel[] value();
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,9 @@ public @interface Log
|
|||||||
* 是否保存请求的参数
|
* 是否保存请求的参数
|
||||||
*/
|
*/
|
||||||
public boolean isSaveRequestData() default true;
|
public boolean isSaveRequestData() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否保存响应的参数
|
||||||
|
*/
|
||||||
|
public boolean isSaveResponseData() default true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
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.Constants;
|
||||||
|
import com.ruoyi.common.enums.LimitType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流注解
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface RateLimiter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 限流key
|
||||||
|
*/
|
||||||
|
public String key() default Constants.RATE_LIMIT_KEY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流时间,单位秒
|
||||||
|
*/
|
||||||
|
public int time() default 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流次数
|
||||||
|
*/
|
||||||
|
public int count() default 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流类型
|
||||||
|
*/
|
||||||
|
public LimitType limitType() default LimitType.DEFAULT;
|
||||||
|
}
|
@ -19,5 +19,13 @@ import java.lang.annotation.Target;
|
|||||||
@Documented
|
@Documented
|
||||||
public @interface RepeatSubmit
|
public @interface RepeatSubmit
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 间隔时间(ms),小于此时间视为重复提交
|
||||||
|
*/
|
||||||
|
public int interval() default 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示消息
|
||||||
|
*/
|
||||||
|
public String message() default "不允许重复提交,请稍候再试";
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ public class RuoYiConfig
|
|||||||
/** 获取地址开关 */
|
/** 获取地址开关 */
|
||||||
private static boolean addressEnabled;
|
private static boolean addressEnabled;
|
||||||
|
|
||||||
|
/** 验证码类型 */
|
||||||
|
private static String captchaType;
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
@ -90,6 +93,22 @@ 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,5 +1,7 @@
|
|||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用常量信息
|
* 通用常量信息
|
||||||
*
|
*
|
||||||
@ -47,6 +49,11 @@ public class Constants
|
|||||||
*/
|
*/
|
||||||
public static final String LOGOUT = "Logout";
|
public static final String LOGOUT = "Logout";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册
|
||||||
|
*/
|
||||||
|
public static final String REGISTER = "Register";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录失败
|
* 登录失败
|
||||||
*/
|
*/
|
||||||
@ -61,12 +68,17 @@ public class Constants
|
|||||||
* 登录用户 redis key
|
* 登录用户 redis key
|
||||||
*/
|
*/
|
||||||
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防重提交 redis key
|
* 防重提交 redis key
|
||||||
*/
|
*/
|
||||||
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流 redis key
|
||||||
|
*/
|
||||||
|
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码有效期(分钟)
|
* 验证码有效期(分钟)
|
||||||
*/
|
*/
|
||||||
@ -95,7 +107,7 @@ public class Constants
|
|||||||
/**
|
/**
|
||||||
* 用户名称
|
* 用户名称
|
||||||
*/
|
*/
|
||||||
public static final String JWT_USERNAME = "sub";
|
public static final String JWT_USERNAME = Claims.SUBJECT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户头像
|
* 用户头像
|
||||||
@ -126,4 +138,30 @@ public class Constants
|
|||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
public static final String RESOURCE_PREFIX = "/profile";
|
public static final String RESOURCE_PREFIX = "/profile";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RMI 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_RMI = "rmi:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAP 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAP = "ldap:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAPS 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务违规的字符
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||||
|
"org.springframework", "org.apache", "com.ruoyi.common.utils.file" };
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,9 @@ 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";
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,26 @@ public class UserConstants
|
|||||||
|
|
||||||
/** Layout组件标识 */
|
/** Layout组件标识 */
|
||||||
public final static String LAYOUT = "Layout";
|
public final static String LAYOUT = "Layout";
|
||||||
|
|
||||||
/** ParentView组件标识 */
|
/** ParentView组件标识 */
|
||||||
public final static String PARENT_VIEW = "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 UNIQUE = "0";
|
||||||
public final static String NOT_UNIQUE = "1";
|
public final static String NOT_UNIQUE = "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名长度限制
|
||||||
|
*/
|
||||||
|
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,10 +11,13 @@ 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;
|
||||||
|
|
||||||
@ -48,17 +51,31 @@ public class BaseController
|
|||||||
* 设置请求分页数据
|
* 设置请求分页数据
|
||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage()
|
||||||
|
{
|
||||||
|
PageUtils.startPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置请求排序数据
|
||||||
|
*/
|
||||||
|
protected void startOrderBy()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
|
||||||
{
|
{
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
PageHelper.orderBy(orderBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理分页的线程变量
|
||||||
|
*/
|
||||||
|
protected void clearPage()
|
||||||
|
{
|
||||||
|
PageUtils.clearPage();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
@ -73,28 +90,6 @@ public class BaseController
|
|||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应返回结果
|
|
||||||
*
|
|
||||||
* @param rows 影响行数
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
protected AjaxResult toAjax(int rows)
|
|
||||||
{
|
|
||||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应返回结果
|
|
||||||
*
|
|
||||||
* @param result 结果
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
protected AjaxResult toAjax(boolean result)
|
|
||||||
{
|
|
||||||
return result ? success() : error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功
|
* 返回成功
|
||||||
*/
|
*/
|
||||||
@ -127,6 +122,28 @@ public class BaseController
|
|||||||
return AjaxResult.error(message);
|
return AjaxResult.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应返回结果
|
||||||
|
*
|
||||||
|
* @param rows 影响行数
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
protected AjaxResult toAjax(int rows)
|
||||||
|
{
|
||||||
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应返回结果
|
||||||
|
*
|
||||||
|
* @param result 结果
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
protected AjaxResult toAjax(boolean result)
|
||||||
|
{
|
||||||
|
return result ? success() : error();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
@ -134,4 +151,36 @@ 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,4 +145,18 @@ public class AjaxResult extends HashMap<String, Object>
|
|||||||
{
|
{
|
||||||
return new AjaxResult(code, msg, null);
|
return new AjaxResult(code, msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方便链式调用
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return 数据对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult put(String key, Object value)
|
||||||
|
{
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ 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;
|
||||||
@ -31,7 +32,7 @@ public class SysDept extends BaseEntity
|
|||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
/** 显示顺序 */
|
/** 显示顺序 */
|
||||||
private String orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/** 负责人 */
|
/** 负责人 */
|
||||||
private String leader;
|
private String leader;
|
||||||
@ -96,13 +97,13 @@ public class SysDept extends BaseEntity
|
|||||||
this.deptName = deptName;
|
this.deptName = deptName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotNull(message = "显示顺序不能为空")
|
||||||
public String getOrderNum()
|
public Integer getOrderNum()
|
||||||
{
|
{
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNum(String orderNum)
|
public void setOrderNum(Integer orderNum)
|
||||||
{
|
{
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
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;
|
||||||
@ -57,6 +58,7 @@ 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,6 +3,7 @@ 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;
|
||||||
@ -30,7 +31,7 @@ public class SysMenu extends BaseEntity
|
|||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/** 显示顺序 */
|
/** 显示顺序 */
|
||||||
private String orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/** 路由地址 */
|
/** 路由地址 */
|
||||||
private String path;
|
private String path;
|
||||||
@ -38,6 +39,9 @@ public class SysMenu extends BaseEntity
|
|||||||
/** 组件路径 */
|
/** 组件路径 */
|
||||||
private String component;
|
private String component;
|
||||||
|
|
||||||
|
/** 路由参数 */
|
||||||
|
private String query;
|
||||||
|
|
||||||
/** 是否为外链(0是 1否) */
|
/** 是否为外链(0是 1否) */
|
||||||
private String isFrame;
|
private String isFrame;
|
||||||
|
|
||||||
@ -104,13 +108,13 @@ public class SysMenu extends BaseEntity
|
|||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotNull(message = "显示顺序不能为空")
|
||||||
public String getOrderNum()
|
public Integer getOrderNum()
|
||||||
{
|
{
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNum(String orderNum)
|
public void setOrderNum(Integer orderNum)
|
||||||
{
|
{
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
}
|
}
|
||||||
@ -137,6 +141,16 @@ 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 getIsFrame()
|
public String getIsFrame()
|
||||||
{
|
{
|
||||||
return isFrame;
|
return isFrame;
|
||||||
|
@ -33,8 +33,8 @@ public class SysRole extends BaseEntity
|
|||||||
@Excel(name = "角色排序")
|
@Excel(name = "角色排序")
|
||||||
private String roleSort;
|
private String roleSort;
|
||||||
|
|
||||||
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */
|
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */
|
||||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
||||||
private String dataScope;
|
private String dataScope;
|
||||||
|
|
||||||
/** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
|
/** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
|
||||||
|
@ -2,9 +2,7 @@ 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.Email;
|
import javax.validation.constraints.*;
|
||||||
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.JsonIgnore;
|
||||||
@ -14,6 +12,7 @@ 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.xss.Xss;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户对象 sys_user
|
* 用户对象 sys_user
|
||||||
@ -92,6 +91,9 @@ public class SysUser extends BaseEntity
|
|||||||
/** 岗位组 */
|
/** 岗位组 */
|
||||||
private Long[] postIds;
|
private Long[] postIds;
|
||||||
|
|
||||||
|
/** 角色ID */
|
||||||
|
private Long roleId;
|
||||||
|
|
||||||
public SysUser()
|
public SysUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -132,6 +134,7 @@ 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()
|
||||||
{
|
{
|
||||||
@ -143,6 +146,7 @@ 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()
|
||||||
@ -198,7 +202,7 @@ public class SysUser extends BaseEntity
|
|||||||
this.avatar = avatar;
|
this.avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
@ -300,6 +304,16 @@ 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)
|
||||||
|
@ -25,7 +25,7 @@ public class LoginBody
|
|||||||
/**
|
/**
|
||||||
* 唯一标识
|
* 唯一标识
|
||||||
*/
|
*/
|
||||||
private String uuid = "";
|
private String uuid;
|
||||||
|
|
||||||
public String getUsername()
|
public String getUsername()
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ import java.util.Collection;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,6 +16,16 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户唯一标识
|
* 用户唯一标识
|
||||||
*/
|
*/
|
||||||
@ -61,6 +71,26 @@ public class LoginUser implements UserDetails
|
|||||||
*/
|
*/
|
||||||
private SysUser user;
|
private SysUser user;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -81,7 +111,15 @@ public class LoginUser implements UserDetails
|
|||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
this.deptId = deptId;
|
||||||
|
this.user = user;
|
||||||
|
this.permissions = permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSONField(serialize = false)
|
||||||
@Override
|
@Override
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
@ -97,7 +135,7 @@ public class LoginUser implements UserDetails
|
|||||||
/**
|
/**
|
||||||
* 账户是否未过期,过期无法验证
|
* 账户是否未过期,过期无法验证
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JSONField(serialize = false)
|
||||||
@Override
|
@Override
|
||||||
public boolean isAccountNonExpired()
|
public boolean isAccountNonExpired()
|
||||||
{
|
{
|
||||||
@ -109,7 +147,7 @@ public class LoginUser implements UserDetails
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JSONField(serialize = false)
|
||||||
@Override
|
@Override
|
||||||
public boolean isAccountNonLocked()
|
public boolean isAccountNonLocked()
|
||||||
{
|
{
|
||||||
@ -121,7 +159,7 @@ public class LoginUser implements UserDetails
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JSONField(serialize = false)
|
||||||
@Override
|
@Override
|
||||||
public boolean isCredentialsNonExpired()
|
public boolean isCredentialsNonExpired()
|
||||||
{
|
{
|
||||||
@ -133,7 +171,7 @@ public class LoginUser implements UserDetails
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JSONField(serialize = false)
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册对象
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class RegisterBody extends LoginBody
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -1,72 +1,101 @@
|
|||||||
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 "";
|
||||||
|
}
|
||||||
public Integer getPageNum()
|
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||||
{
|
}
|
||||||
return pageNum;
|
|
||||||
}
|
public Integer getPageNum()
|
||||||
|
{
|
||||||
public void setPageNum(Integer pageNum)
|
return pageNum;
|
||||||
{
|
}
|
||||||
this.pageNum = pageNum;
|
|
||||||
}
|
public void setPageNum(Integer pageNum)
|
||||||
|
{
|
||||||
public Integer getPageSize()
|
this.pageNum = pageNum;
|
||||||
{
|
}
|
||||||
return pageSize;
|
|
||||||
}
|
public Integer getPageSize()
|
||||||
|
{
|
||||||
public void setPageSize(Integer pageSize)
|
return pageSize;
|
||||||
{
|
}
|
||||||
this.pageSize = pageSize;
|
|
||||||
}
|
public void setPageSize(Integer pageSize)
|
||||||
|
{
|
||||||
public String getOrderByColumn()
|
this.pageSize = pageSize;
|
||||||
{
|
}
|
||||||
return orderByColumn;
|
|
||||||
}
|
public String getOrderByColumn()
|
||||||
|
{
|
||||||
public void setOrderByColumn(String orderByColumn)
|
return orderByColumn;
|
||||||
{
|
}
|
||||||
this.orderByColumn = orderByColumn;
|
|
||||||
}
|
public void setOrderByColumn(String orderByColumn)
|
||||||
|
{
|
||||||
public String getIsAsc()
|
this.orderByColumn = orderByColumn;
|
||||||
{
|
}
|
||||||
return isAsc;
|
|
||||||
}
|
public String getIsAsc()
|
||||||
|
{
|
||||||
public void setIsAsc(String isAsc)
|
return 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,16 +30,22 @@ 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(ServletUtils.getParameterToInt(PAGE_NUM));
|
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
|
||||||
pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE));
|
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +209,18 @@ public class RedisCache
|
|||||||
return opsForHash.get(key, hKey);
|
return opsForHash.get(key, hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除Hash中的数据
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param hKey
|
||||||
|
*/
|
||||||
|
public void delCacheMapValue(final String key, final String hKey)
|
||||||
|
{
|
||||||
|
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||||
|
hashOperations.delete(key, hKey);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取多个Hash中的数据
|
* 获取多个Hash中的数据
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流类型
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
|
||||||
|
public enum LimitType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 默认策略全局限流
|
||||||
|
*/
|
||||||
|
DEFAULT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据请求者IP进行限流
|
||||||
|
*/
|
||||||
|
IP
|
||||||
|
}
|
@ -1,43 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,58 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalException setMessage(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,4 +1,4 @@
|
|||||||
package com.ruoyi.common.exception;
|
package com.ruoyi.common.exception.base;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.common.exception.file;
|
package com.ruoyi.common.exception.file;
|
||||||
|
|
||||||
import com.ruoyi.common.exception.BaseException;
|
import com.ruoyi.common.exception.base.BaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件信息异常类
|
* 文件信息异常类
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
import com.ruoyi.common.exception.BaseException;
|
import com.ruoyi.common.exception.base.BaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息异常类
|
* 用户信息异常类
|
||||||
|
@ -3,8 +3,6 @@ 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;
|
||||||
@ -27,16 +25,10 @@ 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[] url = tempExcludes.split(",");
|
String[] url = tempExcludes.split(",");
|
||||||
@ -45,10 +37,6 @@ public class XssFilter implements Filter
|
|||||||
excludes.add(url[i]);
|
excludes.add(url[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(tempEnabled))
|
|
||||||
{
|
|
||||||
enabled = Boolean.valueOf(tempEnabled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,25 +56,14 @@ public class XssFilter implements Filter
|
|||||||
|
|
||||||
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
|
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
|
||||||
{
|
{
|
||||||
if (!enabled)
|
String url = request.getServletPath();
|
||||||
|
String method = request.getMethod();
|
||||||
|
// GET DELETE 不过滤
|
||||||
|
if (method == null || method.matches("GET") || method.matches("DELETE"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (excludes == null || excludes.isEmpty())
|
return StringUtils.matches(url, excludes);
|
||||||
{
|
|
||||||
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
|
||||||
|
@ -63,7 +63,8 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
|||||||
|
|
||||||
// xss过滤
|
// xss过滤
|
||||||
json = EscapeUtil.clean(json).trim();
|
json = EscapeUtil.clean(json).trim();
|
||||||
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
|
byte[] jsonBytes = json.getBytes("utf-8");
|
||||||
|
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
|
||||||
return new ServletInputStream()
|
return new ServletInputStream()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -78,6 +79,12 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,11 @@ 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;
|
||||||
|
|
||||||
@ -22,7 +27,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",
|
||||||
@ -121,7 +126,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务器启动时间
|
* 获取服务器启动时间
|
||||||
*/
|
*/
|
||||||
@ -131,6 +136,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算相差天数
|
||||||
|
*/
|
||||||
|
public static int differentDaysByMillisecond(Date date1, Date date2)
|
||||||
|
{
|
||||||
|
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个时间差
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
@ -152,4 +165,23 @@ 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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,7 @@ public class DictUtils
|
|||||||
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||||
if (StringUtils.isNotNull(cacheObj))
|
if (StringUtils.isNotNull(cacheObj))
|
||||||
{
|
{
|
||||||
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
return StringUtils.cast(cacheObj);
|
||||||
return dictDatas;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -92,7 +91,7 @@ public class DictUtils
|
|||||||
{
|
{
|
||||||
if (value.equals(dict.getDictValue()))
|
if (value.equals(dict.getDictValue()))
|
||||||
{
|
{
|
||||||
propertyString.append(dict.getDictLabel() + separator);
|
propertyString.append(dict.getDictLabel()).append(separator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +131,7 @@ public class DictUtils
|
|||||||
{
|
{
|
||||||
if (label.equals(dict.getDictLabel()))
|
if (label.equals(dict.getDictLabel()))
|
||||||
{
|
{
|
||||||
propertyString.append(dict.getDictValue() + separator);
|
propertyString.append(dict.getDictValue()).append(separator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,6 +150,16 @@ public class DictUtils
|
|||||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除指定字典缓存
|
||||||
|
*
|
||||||
|
* @param key 字典键
|
||||||
|
*/
|
||||||
|
public static void removeDictCache(String key)
|
||||||
|
{
|
||||||
|
SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空字典缓存
|
* 清空字典缓存
|
||||||
*/
|
*/
|
||||||
|
@ -18,8 +18,7 @@ public class ExceptionUtil
|
|||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw, true));
|
e.printStackTrace(new PrintWriter(sw, true));
|
||||||
String str = sw.toString();
|
return sw.toString();
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRootErrorMessage(Exception e)
|
public static String getRootErrorMessage(Exception e)
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import com.ruoyi.common.constant.HttpStatus;
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.exception.CustomException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全服务工具类
|
* 安全服务工具类
|
||||||
@ -14,6 +14,36 @@ import com.ruoyi.common.exception.CustomException;
|
|||||||
*/
|
*/
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户账户
|
* 获取用户账户
|
||||||
**/
|
**/
|
||||||
@ -25,7 +55,7 @@ public class SecurityUtils
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new CustomException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
|
throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +70,7 @@ public class SecurityUtils
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new CustomException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
|
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,22 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
@ -83,9 +99,8 @@ public class ServletUtils
|
|||||||
*
|
*
|
||||||
* @param response 渲染对象
|
* @param response 渲染对象
|
||||||
* @param string 待渲染的字符串
|
* @param string 待渲染的字符串
|
||||||
* @return null
|
|
||||||
*/
|
*/
|
||||||
public static String renderString(HttpServletResponse response, String string)
|
public static void renderString(HttpServletResponse response, String string)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -98,7 +113,6 @@ public class ServletUtils
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,13 +123,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.indexOf("application/json") != -1)
|
if (accept != null && accept.contains("application/json"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||||
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
|
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -127,10 +141,6 @@ public class ServletUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
String ajax = request.getParameter("__ajax");
|
||||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,6 +262,17 @@ 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
|
||||||
*
|
*
|
||||||
@ -311,6 +324,29 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驼峰转下划线命名
|
* 驼峰转下划线命名
|
||||||
*/
|
*/
|
||||||
@ -451,9 +487,97 @@ 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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -36,7 +36,7 @@ public class Threads
|
|||||||
* 停止线程池
|
* 停止线程池
|
||||||
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
||||||
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
|
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
|
||||||
* 如果仍人超時,則強制退出.
|
* 如果仍然超時,則強制退出.
|
||||||
* 另对在shutdown时线程本身被调用中断做了处理.
|
* 另对在shutdown时线程本身被调用中断做了处理.
|
||||||
*/
|
*/
|
||||||
public static void shutdownAndAwaitTermination(ExecutorService pool)
|
public static void shutdownAndAwaitTermination(ExecutorService pool)
|
||||||
|
@ -1,228 +0,0 @@
|
|||||||
package com.ruoyi.common.utils;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Random;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码工具类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class VerifyCodeUtils
|
|
||||||
{
|
|
||||||
// 使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符
|
|
||||||
public static final String VERIFY_CODES = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
||||||
|
|
||||||
private static Random random = new SecureRandom();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用系统默认字符源生成验证码
|
|
||||||
*
|
|
||||||
* @param verifySize 验证码长度
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String generateVerifyCode(int verifySize)
|
|
||||||
{
|
|
||||||
return generateVerifyCode(verifySize, VERIFY_CODES);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用指定源生成验证码
|
|
||||||
*
|
|
||||||
* @param verifySize 验证码长度
|
|
||||||
* @param sources 验证码字符源
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String generateVerifyCode(int verifySize, String sources)
|
|
||||||
{
|
|
||||||
if (sources == null || sources.length() == 0)
|
|
||||||
{
|
|
||||||
sources = VERIFY_CODES;
|
|
||||||
}
|
|
||||||
int codesLen = sources.length();
|
|
||||||
Random rand = new Random(System.currentTimeMillis());
|
|
||||||
StringBuilder verifyCode = new StringBuilder(verifySize);
|
|
||||||
for (int i = 0; i < verifySize; i++)
|
|
||||||
{
|
|
||||||
verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1)));
|
|
||||||
}
|
|
||||||
return verifyCode.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输出指定验证码图片流
|
|
||||||
*
|
|
||||||
* @param w
|
|
||||||
* @param h
|
|
||||||
* @param os
|
|
||||||
* @param code
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static void outputImage(int w, int h, OutputStream os, String code) throws IOException
|
|
||||||
{
|
|
||||||
int verifySize = code.length();
|
|
||||||
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
|
||||||
Random rand = new Random();
|
|
||||||
Graphics2D g2 = image.createGraphics();
|
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
Color[] colors = new Color[5];
|
|
||||||
Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA,
|
|
||||||
Color.ORANGE, Color.PINK, Color.YELLOW };
|
|
||||||
float[] fractions = new float[colors.length];
|
|
||||||
for (int i = 0; i < colors.length; i++)
|
|
||||||
{
|
|
||||||
colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)];
|
|
||||||
fractions[i] = rand.nextFloat();
|
|
||||||
}
|
|
||||||
Arrays.sort(fractions);
|
|
||||||
|
|
||||||
g2.setColor(Color.GRAY);// 设置边框色
|
|
||||||
g2.fillRect(0, 0, w, h);
|
|
||||||
|
|
||||||
Color c = getRandColor(200, 250);
|
|
||||||
g2.setColor(c);// 设置背景色
|
|
||||||
g2.fillRect(0, 2, w, h - 4);
|
|
||||||
|
|
||||||
// 绘制干扰线
|
|
||||||
Random random = new Random();
|
|
||||||
g2.setColor(getRandColor(160, 200));// 设置线条的颜色
|
|
||||||
for (int i = 0; i < 20; i++)
|
|
||||||
{
|
|
||||||
int x = random.nextInt(w - 1);
|
|
||||||
int y = random.nextInt(h - 1);
|
|
||||||
int xl = random.nextInt(6) + 1;
|
|
||||||
int yl = random.nextInt(12) + 1;
|
|
||||||
g2.drawLine(x, y, x + xl + 40, y + yl + 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加噪点
|
|
||||||
float yawpRate = 0.05f;// 噪声率
|
|
||||||
int area = (int) (yawpRate * w * h);
|
|
||||||
for (int i = 0; i < area; i++)
|
|
||||||
{
|
|
||||||
int x = random.nextInt(w);
|
|
||||||
int y = random.nextInt(h);
|
|
||||||
int rgb = getRandomIntColor();
|
|
||||||
image.setRGB(x, y, rgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
shear(g2, w, h, c);// 使图片扭曲
|
|
||||||
|
|
||||||
g2.setColor(getRandColor(100, 160));
|
|
||||||
int fontSize = h - 4;
|
|
||||||
Font font = new Font("Algerian", Font.ITALIC, fontSize);
|
|
||||||
g2.setFont(font);
|
|
||||||
char[] chars = code.toCharArray();
|
|
||||||
for (int i = 0; i < verifySize; i++)
|
|
||||||
{
|
|
||||||
AffineTransform affine = new AffineTransform();
|
|
||||||
affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1),
|
|
||||||
(w / verifySize) * i + fontSize / 2, h / 2);
|
|
||||||
g2.setTransform(affine);
|
|
||||||
g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
g2.dispose();
|
|
||||||
ImageIO.write(image, "jpg", os);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color getRandColor(int fc, int bc)
|
|
||||||
{
|
|
||||||
if (fc > 255) {
|
|
||||||
fc = 255;
|
|
||||||
}
|
|
||||||
if (bc > 255) {
|
|
||||||
bc = 255;
|
|
||||||
}
|
|
||||||
int r = fc + random.nextInt(bc - fc);
|
|
||||||
int g = fc + random.nextInt(bc - fc);
|
|
||||||
int b = fc + random.nextInt(bc - fc);
|
|
||||||
return new Color(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getRandomIntColor()
|
|
||||||
{
|
|
||||||
int[] rgb = getRandomRgb();
|
|
||||||
int color = 0;
|
|
||||||
for (int c : rgb)
|
|
||||||
{
|
|
||||||
color = color << 8;
|
|
||||||
color = color | c;
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int[] getRandomRgb()
|
|
||||||
{
|
|
||||||
int[] rgb = new int[3];
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
rgb[i] = random.nextInt(255);
|
|
||||||
}
|
|
||||||
return rgb;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void shear(Graphics g, int w1, int h1, Color color)
|
|
||||||
{
|
|
||||||
shearX(g, w1, h1, color);
|
|
||||||
shearY(g, w1, h1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void shearX(Graphics g, int w1, int h1, Color color)
|
|
||||||
{
|
|
||||||
|
|
||||||
int period = random.nextInt(2);
|
|
||||||
|
|
||||||
boolean borderGap = true;
|
|
||||||
int frames = 1;
|
|
||||||
int phase = random.nextInt(2);
|
|
||||||
|
|
||||||
for (int i = 0; i < h1; i++)
|
|
||||||
{
|
|
||||||
double d = (double) (period >> 1)
|
|
||||||
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
|
|
||||||
g.copyArea(0, i, w1, 1, (int) d, 0);
|
|
||||||
if (borderGap)
|
|
||||||
{
|
|
||||||
g.setColor(color);
|
|
||||||
g.drawLine((int) d, i, 0, i);
|
|
||||||
g.drawLine((int) d + w1, i, w1, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void shearY(Graphics g, int w1, int h1, Color color)
|
|
||||||
{
|
|
||||||
|
|
||||||
int period = random.nextInt(40) + 10; // 50;
|
|
||||||
|
|
||||||
boolean borderGap = true;
|
|
||||||
int frames = 20;
|
|
||||||
int phase = 7;
|
|
||||||
for (int i = 0; i < w1; i++)
|
|
||||||
{
|
|
||||||
double d = (double) (period >> 1)
|
|
||||||
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
|
|
||||||
g.copyArea(i, 0, 1, h1, 0, (int) d);
|
|
||||||
if (borderGap)
|
|
||||||
{
|
|
||||||
g.setColor(color);
|
|
||||||
g.drawLine(i, (int) d, i, 0);
|
|
||||||
g.drawLine(i, (int) d + h1, i, h1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.common.utils.bean;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import javax.validation.Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bean对象属性验证
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class BeanValidators
|
||||||
|
{
|
||||||
|
public static void validateWithException(Validator validator, Object object, Class<?>... groups)
|
||||||
|
throws ConstraintViolationException
|
||||||
|
{
|
||||||
|
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
||||||
|
if (!constraintViolations.isEmpty())
|
||||||
|
{
|
||||||
|
throw new ConstraintViolationException(constraintViolations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,8 @@ package com.ruoyi.common.utils.file;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Objects;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
@ -11,7 +13,7 @@ import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
|
|||||||
import com.ruoyi.common.exception.file.InvalidExtensionException;
|
import com.ruoyi.common.exception.file.InvalidExtensionException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.common.utils.uuid.Seq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传工具类
|
* 文件上传工具类
|
||||||
@ -100,7 +102,7 @@ public class FileUploadUtils
|
|||||||
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
||||||
InvalidExtensionException
|
InvalidExtensionException
|
||||||
{
|
{
|
||||||
int fileNamelength = file.getOriginalFilename().length();
|
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
|
||||||
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
||||||
{
|
{
|
||||||
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
||||||
@ -110,10 +112,9 @@ public class FileUploadUtils
|
|||||||
|
|
||||||
String fileName = extractFilename(file);
|
String fileName = extractFilename(file);
|
||||||
|
|
||||||
File desc = getAbsoluteFile(baseDir, fileName);
|
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
||||||
file.transferTo(desc);
|
file.transferTo(Paths.get(absPath));
|
||||||
String pathFileName = getPathFileName(baseDir, fileName);
|
return getPathFileName(baseDir, fileName);
|
||||||
return pathFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,13 +122,11 @@ public class FileUploadUtils
|
|||||||
*/
|
*/
|
||||||
public static final String extractFilename(MultipartFile file)
|
public static final String extractFilename(MultipartFile file)
|
||||||
{
|
{
|
||||||
String fileName = file.getOriginalFilename();
|
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
||||||
String extension = getExtension(file);
|
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
|
||||||
fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
|
||||||
return fileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
||||||
{
|
{
|
||||||
File desc = new File(uploadDir + File.separator + fileName);
|
File desc = new File(uploadDir + File.separator + fileName);
|
||||||
|
|
||||||
@ -141,12 +140,11 @@ public class FileUploadUtils
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
public static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
||||||
{
|
{
|
||||||
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
||||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||||
String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
||||||
return pathFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +159,7 @@ public class FileUploadUtils
|
|||||||
throws FileSizeLimitExceededException, InvalidExtensionException
|
throws FileSizeLimitExceededException, InvalidExtensionException
|
||||||
{
|
{
|
||||||
long size = file.getSize();
|
long size = file.getSize();
|
||||||
if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
|
if (size > DEFAULT_MAX_SIZE)
|
||||||
{
|
{
|
||||||
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
||||||
}
|
}
|
||||||
@ -228,7 +226,7 @@ public class FileUploadUtils
|
|||||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||||
if (StringUtils.isEmpty(extension))
|
if (StringUtils.isEmpty(extension))
|
||||||
{
|
{
|
||||||
extension = MimeTypeUtils.getExtension(file.getContentType());
|
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
||||||
}
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.ruoyi.common.utils.file;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -10,15 +11,20 @@ import java.net.URLEncoder;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件处理工具类
|
* 文件处理工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileUtils extends org.apache.commons.io.FileUtils
|
public class FileUtils
|
||||||
{
|
{
|
||||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||||
|
|
||||||
@ -53,31 +59,50 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (os != null)
|
IOUtils.close(os);
|
||||||
{
|
IOUtils.close(fis);
|
||||||
try
|
|
||||||
{
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
catch (IOException e1)
|
|
||||||
{
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fis != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
catch (IOException e1)
|
|
||||||
{
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写数据到文件中
|
||||||
|
*
|
||||||
|
* @param data 数据
|
||||||
|
* @return 目标文件
|
||||||
|
* @throws IOException IO异常
|
||||||
|
*/
|
||||||
|
public static String writeImportBytes(byte[] data) throws IOException
|
||||||
|
{
|
||||||
|
return writeBytes(data, RuoYiConfig.getImportPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写数据到文件中
|
||||||
|
*
|
||||||
|
* @param data 数据
|
||||||
|
* @param uploadDir 目标文件
|
||||||
|
* @return 目标文件
|
||||||
|
* @throws IOException IO异常
|
||||||
|
*/
|
||||||
|
public static String writeBytes(byte[] data, String uploadDir) throws IOException
|
||||||
|
{
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
String pathName = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String extension = getFileExtendName(data);
|
||||||
|
pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
||||||
|
File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
|
||||||
|
fos = new FileOutputStream(file);
|
||||||
|
fos.write(data);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtils.close(fos);
|
||||||
|
}
|
||||||
|
return FileUploadUtils.getPathFileName(uploadDir, pathName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文件
|
* 删除文件
|
||||||
*
|
*
|
||||||
@ -172,7 +197,6 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
*
|
*
|
||||||
* @param response 响应对象
|
* @param response 响应对象
|
||||||
* @param realFileName 真实文件名
|
* @param realFileName 真实文件名
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
@ -186,7 +210,9 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
.append("utf-8''")
|
.append("utf-8''")
|
||||||
.append(percentEncodedFileName);
|
.append(percentEncodedFileName);
|
||||||
|
|
||||||
|
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
||||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||||
|
response.setHeader("download-filename", percentEncodedFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,4 +226,68 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
|
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
|
||||||
return encode.replaceAll("\\+", "%20");
|
return encode.replaceAll("\\+", "%20");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图像后缀
|
||||||
|
*
|
||||||
|
* @param photoByte 图像数据
|
||||||
|
* @return 后缀名
|
||||||
|
*/
|
||||||
|
public static String getFileExtendName(byte[] photoByte)
|
||||||
|
{
|
||||||
|
String strFileExtendName = "jpg";
|
||||||
|
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||||
|
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
|
||||||
|
{
|
||||||
|
strFileExtendName = "gif";
|
||||||
|
}
|
||||||
|
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
|
||||||
|
{
|
||||||
|
strFileExtendName = "jpg";
|
||||||
|
}
|
||||||
|
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
|
||||||
|
{
|
||||||
|
strFileExtendName = "bmp";
|
||||||
|
}
|
||||||
|
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
|
||||||
|
{
|
||||||
|
strFileExtendName = "png";
|
||||||
|
}
|
||||||
|
return strFileExtendName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png
|
||||||
|
*
|
||||||
|
* @param fileName 路径名称
|
||||||
|
* @return 没有文件路径的名称
|
||||||
|
*/
|
||||||
|
public static String getName(String fileName)
|
||||||
|
{
|
||||||
|
if (fileName == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int lastUnixPos = fileName.lastIndexOf('/');
|
||||||
|
int lastWindowsPos = fileName.lastIndexOf('\\');
|
||||||
|
int index = Math.max(lastUnixPos, lastWindowsPos);
|
||||||
|
return fileName.substring(index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取不带后缀文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi
|
||||||
|
*
|
||||||
|
* @param fileName 路径名称
|
||||||
|
* @return 没有文件路径和后缀的名称
|
||||||
|
*/
|
||||||
|
public static String getNameNotSuffix(String fileName)
|
||||||
|
{
|
||||||
|
if (fileName == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String baseName = FilenameUtils.getBaseName(fileName);
|
||||||
|
return baseName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.common.utils.file;
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -59,13 +58,12 @@ public class ImageUtils
|
|||||||
/**
|
/**
|
||||||
* 读取文件为字节数据
|
* 读取文件为字节数据
|
||||||
*
|
*
|
||||||
* @param key 地址
|
* @param url 地址
|
||||||
* @return 字节数据
|
* @return 字节数据
|
||||||
*/
|
*/
|
||||||
public static byte[] readFile(String url)
|
public static byte[] readFile(String url)
|
||||||
{
|
{
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
ByteArrayOutputStream baos = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (url.startsWith("http"))
|
if (url.startsWith("http"))
|
||||||
@ -94,7 +92,7 @@ public class ImageUtils
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtils.closeQuietly(baos);
|
IOUtils.closeQuietly(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,26 +69,37 @@ public class EscapeUtil
|
|||||||
*/
|
*/
|
||||||
private static String encode(String text)
|
private static String encode(String text)
|
||||||
{
|
{
|
||||||
int len;
|
if (StringUtils.isEmpty(text))
|
||||||
if ((text == null) || ((len = text.length()) == 0))
|
|
||||||
{
|
{
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
StringBuilder buffer = new StringBuilder(len + (len >> 2));
|
|
||||||
|
final StringBuilder tmp = new StringBuilder(text.length() * 6);
|
||||||
char c;
|
char c;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < text.length(); i++)
|
||||||
{
|
{
|
||||||
c = text.charAt(i);
|
c = text.charAt(i);
|
||||||
if (c < 64)
|
if (c < 256)
|
||||||
{
|
{
|
||||||
buffer.append(TEXT[c]);
|
tmp.append("%");
|
||||||
|
if (c < 16)
|
||||||
|
{
|
||||||
|
tmp.append("0");
|
||||||
|
}
|
||||||
|
tmp.append(Integer.toString(c, 16));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer.append(c);
|
tmp.append("%u");
|
||||||
|
if (c <= 0xfff)
|
||||||
|
{
|
||||||
|
// issue#I49JU8@Gitee
|
||||||
|
tmp.append("0");
|
||||||
|
}
|
||||||
|
tmp.append(Integer.toString(c, 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return tmp.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,11 +156,12 @@ public class EscapeUtil
|
|||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
String html = "<script>alert(1);</script>";
|
String html = "<script>alert(1);</script>";
|
||||||
|
String escape = EscapeUtil.escape(html);
|
||||||
// String html = "<scr<script>ipt>alert(\"XSS\")</scr<script>ipt>";
|
// String html = "<scr<script>ipt>alert(\"XSS\")</scr<script>ipt>";
|
||||||
// String html = "<123";
|
// String html = "<123";
|
||||||
// String html = "123>";
|
// String html = "123>";
|
||||||
System.out.println(EscapeUtil.clean(html));
|
System.out.println("clean: " + EscapeUtil.clean(html));
|
||||||
System.out.println(EscapeUtil.escape(html));
|
System.out.println("escape: " + escape);
|
||||||
System.out.println(EscapeUtil.unescape(html));
|
System.out.println("unescape: " + EscapeUtil.unescape(escape));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ public final class HTMLFilter
|
|||||||
final String name = m.group(1).toLowerCase();
|
final String name = m.group(1).toLowerCase();
|
||||||
if (allowed(name))
|
if (allowed(name))
|
||||||
{
|
{
|
||||||
if (false == inArray(name, vSelfClosingTags))
|
if (!inArray(name, vSelfClosingTags))
|
||||||
{
|
{
|
||||||
if (vTagCounts.containsKey(name))
|
if (vTagCounts.containsKey(name))
|
||||||
{
|
{
|
||||||
@ -387,7 +387,7 @@ public final class HTMLFilter
|
|||||||
{
|
{
|
||||||
paramValue = processParamProtocol(paramValue);
|
paramValue = processParamProtocol(paramValue);
|
||||||
}
|
}
|
||||||
params.append(' ').append(paramName).append("=\"").append(paramValue).append("\"");
|
params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -25,7 +25,7 @@ public class HttpHelper
|
|||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try (InputStream inputStream = request.getInputStream())
|
try (InputStream inputStream = request.getInputStream())
|
||||||
{
|
{
|
||||||
reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||||
String line = "";
|
String line = "";
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ import java.net.ConnectException;
|
|||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
@ -19,6 +20,7 @@ import javax.net.ssl.X509TrustManager;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用http发送方法
|
* 通用http发送方法
|
||||||
@ -29,6 +31,17 @@ public class HttpUtils
|
|||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向指定 URL 发送GET方法的请求
|
||||||
|
*
|
||||||
|
* @param url 发送请求的 URL
|
||||||
|
* @return 所代表远程资源的响应结果
|
||||||
|
*/
|
||||||
|
public static String sendGet(String url)
|
||||||
|
{
|
||||||
|
return sendGet(url, StringUtils.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向指定 URL 发送GET方法的请求
|
* 向指定 URL 发送GET方法的请求
|
||||||
*
|
*
|
||||||
@ -55,7 +68,7 @@ public class HttpUtils
|
|||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String urlNameString = url + "?" + param;
|
String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
|
||||||
log.info("sendGet - {}", urlNameString);
|
log.info("sendGet - {}", urlNameString);
|
||||||
URL realUrl = new URL(urlNameString);
|
URL realUrl = new URL(urlNameString);
|
||||||
URLConnection connection = realUrl.openConnection();
|
URLConnection connection = realUrl.openConnection();
|
||||||
@ -118,9 +131,8 @@ public class HttpUtils
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String urlNameString = url;
|
log.info("sendPost - {}", url);
|
||||||
log.info("sendPost - {}", urlNameString);
|
URL realUrl = new URL(url);
|
||||||
URL realUrl = new URL(urlNameString);
|
|
||||||
URLConnection conn = realUrl.openConnection();
|
URLConnection conn = realUrl.openConnection();
|
||||||
conn.setRequestProperty("accept", "*/*");
|
conn.setRequestProperty("accept", "*/*");
|
||||||
conn.setRequestProperty("connection", "Keep-Alive");
|
conn.setRequestProperty("connection", "Keep-Alive");
|
||||||
@ -132,7 +144,7 @@ public class HttpUtils
|
|||||||
out = new PrintWriter(conn.getOutputStream());
|
out = new PrintWriter(conn.getOutputStream());
|
||||||
out.print(param);
|
out.print(param);
|
||||||
out.flush();
|
out.flush();
|
||||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
|
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
||||||
String line;
|
String line;
|
||||||
while ((line = in.readLine()) != null)
|
while ((line = in.readLine()) != null)
|
||||||
{
|
{
|
||||||
@ -206,7 +218,7 @@ public class HttpUtils
|
|||||||
{
|
{
|
||||||
if (ret != null && !"".equals(ret.trim()))
|
if (ret != null && !"".equals(ret.trim()))
|
||||||
{
|
{
|
||||||
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
|
result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("recv - {}", result);
|
log.info("recv - {}", result);
|
||||||
|
@ -25,7 +25,6 @@ public class AddressUtils
|
|||||||
|
|
||||||
public static String getRealAddressByIP(String ip)
|
public static String getRealAddressByIP(String ip)
|
||||||
{
|
{
|
||||||
String address = UNKNOWN;
|
|
||||||
// 内网不查询
|
// 内网不查询
|
||||||
if (IpUtils.internalIp(ip))
|
if (IpUtils.internalIp(ip))
|
||||||
{
|
{
|
||||||
@ -51,6 +50,6 @@ public class AddressUtils
|
|||||||
log.error("获取地理位置异常 {}", ip);
|
log.error("获取地理位置异常 {}", ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return address;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.html.EscapeUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取IP方法
|
* 获取IP方法
|
||||||
@ -13,6 +12,12 @@ import com.ruoyi.common.utils.html.EscapeUtil;
|
|||||||
*/
|
*/
|
||||||
public class IpUtils
|
public class IpUtils
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 获取客户端IP
|
||||||
|
*
|
||||||
|
* @param request 请求对象
|
||||||
|
* @return IP地址
|
||||||
|
*/
|
||||||
public static String getIpAddr(HttpServletRequest request)
|
public static String getIpAddr(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
if (request == null)
|
if (request == null)
|
||||||
@ -41,15 +46,28 @@ public class IpUtils
|
|||||||
{
|
{
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip);
|
|
||||||
|
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否为内部IP地址
|
||||||
|
*
|
||||||
|
* @param ip IP地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
public static boolean internalIp(String ip)
|
public static boolean internalIp(String ip)
|
||||||
{
|
{
|
||||||
byte[] addr = textToNumericFormatV4(ip);
|
byte[] addr = textToNumericFormatV4(ip);
|
||||||
return internalIp(addr) || "127.0.0.1".equals(ip);
|
return internalIp(addr) || "127.0.0.1".equals(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否为内部IP地址
|
||||||
|
*
|
||||||
|
* @param addr byte地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
private static boolean internalIp(byte[] addr)
|
private static boolean internalIp(byte[] addr)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(addr) || addr.length < 2)
|
if (StringUtils.isNull(addr) || addr.length < 2)
|
||||||
@ -110,7 +128,8 @@ public class IpUtils
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
l = Long.parseLong(elements[0]);
|
l = Long.parseLong(elements[0]);
|
||||||
if ((l < 0L) || (l > 4294967295L)) {
|
if ((l < 0L) || (l > 4294967295L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
||||||
@ -120,12 +139,14 @@ public class IpUtils
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
l = Integer.parseInt(elements[0]);
|
l = Integer.parseInt(elements[0]);
|
||||||
if ((l < 0L) || (l > 255L)) {
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[0] = (byte) (int) (l & 0xFF);
|
bytes[0] = (byte) (int) (l & 0xFF);
|
||||||
l = Integer.parseInt(elements[1]);
|
l = Integer.parseInt(elements[1]);
|
||||||
if ((l < 0L) || (l > 16777215L)) {
|
if ((l < 0L) || (l > 16777215L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
||||||
@ -136,13 +157,15 @@ public class IpUtils
|
|||||||
for (i = 0; i < 2; ++i)
|
for (i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
l = Integer.parseInt(elements[i]);
|
l = Integer.parseInt(elements[i]);
|
||||||
if ((l < 0L) || (l > 255L)) {
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[i] = (byte) (int) (l & 0xFF);
|
bytes[i] = (byte) (int) (l & 0xFF);
|
||||||
}
|
}
|
||||||
l = Integer.parseInt(elements[2]);
|
l = Integer.parseInt(elements[2]);
|
||||||
if ((l < 0L) || (l > 65535L)) {
|
if ((l < 0L) || (l > 65535L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
||||||
@ -152,7 +175,8 @@ public class IpUtils
|
|||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
l = Integer.parseInt(elements[i]);
|
l = Integer.parseInt(elements[i]);
|
||||||
if ((l < 0L) || (l > 255L)) {
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[i] = (byte) (int) (l & 0xFF);
|
bytes[i] = (byte) (int) (l & 0xFF);
|
||||||
@ -169,6 +193,11 @@ public class IpUtils
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IP地址
|
||||||
|
*
|
||||||
|
* @return 本地IP地址
|
||||||
|
*/
|
||||||
public static String getHostIp()
|
public static String getHostIp()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -181,6 +210,11 @@ public class IpUtils
|
|||||||
return "127.0.0.1";
|
return "127.0.0.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主机名
|
||||||
|
*
|
||||||
|
* @return 本地主机名
|
||||||
|
*/
|
||||||
public static String getHostName()
|
public static String getHostName()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -192,4 +226,39 @@ public class IpUtils
|
|||||||
}
|
}
|
||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从多级反向代理中获得第一个非unknown IP地址
|
||||||
|
*
|
||||||
|
* @param ip 获得的IP地址
|
||||||
|
* @return 第一个非unknown IP地址
|
||||||
|
*/
|
||||||
|
public static String getMultistageReverseProxyIp(String ip)
|
||||||
|
{
|
||||||
|
// 多级反向代理检测
|
||||||
|
if (ip != null && ip.indexOf(",") > 0)
|
||||||
|
{
|
||||||
|
final String[] ips = ip.trim().split(",");
|
||||||
|
for (String subIp : ips)
|
||||||
|
{
|
||||||
|
if (false == isUnknown(subIp))
|
||||||
|
{
|
||||||
|
ip = subIp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测给定字符串是否为未知,多用于检测HTTP请求相关
|
||||||
|
*
|
||||||
|
* @param checkString 被检测的字符串
|
||||||
|
* @return 是否未知
|
||||||
|
*/
|
||||||
|
public static boolean isUnknown(String checkString)
|
||||||
|
{
|
||||||
|
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.common.utils.poi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel数据格式处理适配器
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public interface ExcelHandlerAdapter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 格式化
|
||||||
|
*
|
||||||
|
* @param value 单元格数据值
|
||||||
|
* @param args excel注解args参数组
|
||||||
|
*
|
||||||
|
* @return 处理后的值
|
||||||
|
*/
|
||||||
|
Object format(Object value, String[] args);
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user