mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-27 04:01:56 +08:00
Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87009e72bf | ||
|
|
d6a2028ec3 | ||
|
|
ef28473992 | ||
|
|
1543fb801b | ||
|
|
e753cea03e | ||
|
|
78332c2786 | ||
|
|
4b1351ef21 | ||
|
|
f12baad00c | ||
|
|
81d3c90bbc | ||
|
|
0d58ecb09c | ||
|
|
1e16852a3c | ||
|
|
57e63a184d | ||
|
|
20476e9dd1 | ||
|
|
95aa343805 | ||
|
|
a573c4b10d | ||
|
|
5964dc81ab | ||
|
|
721701274b | ||
|
|
78c356a9f3 | ||
|
|
b622675522 | ||
|
|
912f607062 | ||
|
|
1297d094cb | ||
|
|
ccfc4f7ad7 | ||
|
|
8ee702e4a2 | ||
|
|
5945537ade | ||
|
|
2051819d2d | ||
|
|
570d468814 | ||
|
|
5fd16ff806 | ||
|
|
17246d8a27 | ||
|
|
6d404a1f3b | ||
|
|
7417c1d473 | ||
|
|
9b35679ba6 | ||
|
|
7af84cb923 | ||
|
|
8242cec9ac | ||
|
|
5b8cf9701f | ||
|
|
a52d455032 | ||
|
|
d28f81dc68 | ||
|
|
7475cff47d | ||
|
|
d6e6b99316 | ||
|
|
5a48c5dba7 | ||
|
|
ad7133f39d | ||
|
|
fca189fa73 | ||
|
|
6cda8cb28f | ||
|
|
9c29907d57 | ||
|
|
b3d462e873 | ||
|
|
cdcc466300 | ||
|
|
12ca164c44 | ||
|
|
1d1b9501b7 | ||
|
|
24376681b8 | ||
|
|
386f3eb016 | ||
|
|
2a6a74ead5 | ||
|
|
01e4e619e6 | ||
|
|
f6f07f255a | ||
|
|
2eaa52c7aa | ||
|
|
86b9e675b5 | ||
|
|
b76cd4d0e2 | ||
|
|
a4ad2b8b3c | ||
|
|
103bf66f77 | ||
|
|
5dbed46552 | ||
|
|
97500fbccb | ||
|
|
70f306418f | ||
|
|
6bc77169fe | ||
|
|
742f3106a2 | ||
|
|
9ec4d19384 | ||
|
|
68040827e2 | ||
|
|
75d91c7d1d | ||
|
|
95c1286f06 | ||
|
|
f63a76f661 | ||
|
|
6644d3077d | ||
|
|
54d1c58338 | ||
|
|
9da3b34b9c | ||
|
|
1ec806ae80 | ||
|
|
4df2b72b30 | ||
|
|
a0ce434163 | ||
|
|
5053510236 | ||
|
|
d14f27e5eb | ||
|
|
72cf2edf03 | ||
|
|
8c6035c8f9 | ||
|
|
f7b761275c | ||
|
|
6f7b02372e | ||
|
|
0b6166663c | ||
|
|
723583a3b8 | ||
|
|
6a017dddd1 | ||
|
|
6f5c149ba0 | ||
|
|
5d44d2b5a6 | ||
|
|
7c3425ee9b | ||
|
|
6133563bf3 | ||
|
|
2d67d7c8e2 | ||
|
|
55a7a90bab | ||
|
|
a70d5ee2ab | ||
|
|
e5c938c64a | ||
|
|
ccf84377f8 | ||
|
|
dc8938ab2f | ||
|
|
bc05b453df | ||
|
|
368a9044be | ||
|
|
242101ae6e | ||
|
|
0b08933a8c | ||
|
|
99932d91c0 | ||
|
|
59387216b4 | ||
|
|
66f5f11069 | ||
|
|
33694c860f | ||
|
|
4c5c1d1f78 | ||
|
|
14cd3e2c6a | ||
|
|
34487865f3 | ||
|
|
2444fcc646 | ||
|
|
8b3d75a6a0 | ||
|
|
4feb0adb6e | ||
|
|
82535c82d3 | ||
|
|
7a09412ecb | ||
|
|
a30622b460 | ||
|
|
df0813089e | ||
|
|
e059ed9c7f | ||
|
|
105c9d99c8 | ||
|
|
a65eaf880d | ||
|
|
04706403d3 | ||
|
|
c43565ef43 | ||
|
|
089ebaf9c5 | ||
|
|
6f3c3f1b7e | ||
|
|
2dc5e7319a | ||
|
|
b5d2628b71 | ||
|
|
9460acd91b | ||
|
|
480d49f2b3 | ||
|
|
1358b21c3a | ||
|
|
480bba4f9d | ||
|
|
a14c06a1f1 | ||
|
|
2e1ef93aa6 | ||
|
|
14c412113f | ||
|
|
642cfbda0a | ||
|
|
0e13296752 | ||
|
|
8fac26edca | ||
|
|
b0b16e1fc5 | ||
|
|
297193b6ce | ||
|
|
99e14d0e29 | ||
|
|
dbca691746 | ||
|
|
e66f65b257 | ||
|
|
5f60a37d8a | ||
|
|
d30e136c1d | ||
|
|
9c122a4bfe | ||
|
|
1761a4f588 | ||
|
|
b60fa5c920 | ||
|
|
4191f5ca5c | ||
|
|
a00482d5d7 | ||
|
|
2610869e9c | ||
|
|
155eb55953 | ||
|
|
8541ca99af | ||
|
|
9cb15ec2ae | ||
|
|
27d46fc0a4 | ||
|
|
5800ac6b9e | ||
|
|
c57ec64e63 | ||
|
|
1a1d6562d2 | ||
|
|
255101f6f7 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -25,6 +25,8 @@ target/
|
|||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
|
### JRebel ###
|
||||||
|
rebel.xml
|
||||||
### NetBeans ###
|
### NetBeans ###
|
||||||
nbproject/private/
|
nbproject/private/
|
||||||
build/*
|
build/*
|
||||||
@@ -37,6 +39,7 @@ nbdist/
|
|||||||
# Others
|
# Others
|
||||||
*.log
|
*.log
|
||||||
*.xml.versionsBackup
|
*.xml.versionsBackup
|
||||||
|
*.swp
|
||||||
|
|
||||||
!*/build/*.java
|
!*/build/*.java
|
||||||
!*/build/*.html
|
!*/build/*.html
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
|
||||||
</p>
|
</p>
|
||||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.4.0</h1>
|
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.0</h1>
|
||||||
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Cloud/stargazers"><img src="https://gitee.com/y_project/RuoYi-Cloud/badge/star.svg?theme=dark"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud/stargazers"><img src="https://gitee.com/y_project/RuoYi-Cloud/badge/star.svg?theme=dark"></a>
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.4.0-brightgreen.svg"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.6.0-brightgreen.svg"></a>
|
||||||
<a href="https://gitee.com/y_project/RuoYi-Cloud/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
<a href="https://gitee.com/y_project/RuoYi-Cloud/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -127,4 +127,4 @@ com.ruoyi
|
|||||||
|
|
||||||
## 若依微服务交流群
|
## 若依微服务交流群
|
||||||
|
|
||||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) 点击按钮入群。
|
QQ群: [](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) [](https://jq.qq.com/?_wv=1027&k=nw3OiyXs) [](https://jq.qq.com/?_wv=1027&k=kiU5WDls) 点击按钮入群。
|
||||||
@@ -10,7 +10,7 @@ usage() {
|
|||||||
# copy sql
|
# copy sql
|
||||||
echo "begin copy sql "
|
echo "begin copy sql "
|
||||||
cp ../sql/ry_20210908.sql ./mysql/db
|
cp ../sql/ry_20210908.sql ./mysql/db
|
||||||
cp ../sql/ry_config_20211118.sql ./mysql/db
|
cp ../sql/ry_config_20220114.sql ./mysql/db
|
||||||
|
|
||||||
# copy html
|
# copy html
|
||||||
echo "begin copy html "
|
echo "begin copy html "
|
||||||
|
|||||||
68
pom.xml
68
pom.xml
@@ -6,39 +6,40 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</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.4.0</ruoyi.version>
|
<ruoyi.version>3.6.0</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<spring-boot.version>2.6.3</spring-boot.version>
|
<spring-boot.version>2.7.1</spring-boot.version>
|
||||||
<spring-cloud.version>2021.0.0</spring-cloud.version>
|
<spring-cloud.version>2021.0.3</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2021.0.1.0</spring-cloud-alibaba.version>
|
||||||
<alibaba.nacos.version>2.0.4</alibaba.nacos.version>
|
<alibaba.nacos.version>2.0.4</alibaba.nacos.version>
|
||||||
<spring-boot-admin.version>2.6.2</spring-boot-admin.version>
|
<alibaba.seata.version>1.5.1</alibaba.seata.version>
|
||||||
<spring-boot.mybatis>2.2.0</spring-boot.mybatis>
|
<spring-boot-admin.version>2.7.2</spring-boot-admin.version>
|
||||||
|
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
|
||||||
<swagger.fox.version>3.0.0</swagger.fox.version>
|
<swagger.fox.version>3.0.0</swagger.fox.version>
|
||||||
<swagger.core.version>1.6.2</swagger.core.version>
|
<swagger.core.version>1.6.2</swagger.core.version>
|
||||||
<tobato.version>1.27.2</tobato.version>
|
<tobato.version>1.27.2</tobato.version>
|
||||||
<kaptcha.version>2.3.2</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<pagehelper.boot.version>1.4.1</pagehelper.boot.version>
|
<pagehelper.boot.version>1.4.3</pagehelper.boot.version>
|
||||||
<druid.version>1.2.8</druid.version>
|
<druid.version>1.2.11</druid.version>
|
||||||
<dynamic-ds.version>3.5.0</dynamic-ds.version>
|
<dynamic-ds.version>3.5.1</dynamic-ds.version>
|
||||||
<commons.io.version>2.11.0</commons.io.version>
|
<commons.io.version>2.11.0</commons.io.version>
|
||||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<fastjson.version>1.2.79</fastjson.version>
|
<fastjson.version>2.0.9</fastjson.version>
|
||||||
<jjwt.version>0.9.1</jjwt.version>
|
<jjwt.version>0.9.1</jjwt.version>
|
||||||
<minio.version>8.2.2</minio.version>
|
<minio.version>8.2.2</minio.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<commons-collections.version>3.2.2</commons-collections.version>
|
<commons-collections.version>3.2.2</commons-collections.version>
|
||||||
<transmittable-thread-local.version>2.12.2</transmittable-thread-local.version>
|
<transmittable-thread-local.version>2.13.2</transmittable-thread-local.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
@@ -70,6 +71,13 @@
|
|||||||
<version>${alibaba.nacos.version}</version>
|
<version>${alibaba.nacos.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Alibaba Seata 配置 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.seata</groupId>
|
||||||
|
<artifactId>seata-spring-boot-starter</artifactId>
|
||||||
|
<version>${alibaba.seata.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringBoot 依赖配置 -->
|
<!-- SpringBoot 依赖配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -79,13 +87,6 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringBoot 监控客户端 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.codecentric</groupId>
|
|
||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
|
||||||
<version>${spring-boot-admin.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- FastDFS 分布式文件系统 -->
|
<!-- FastDFS 分布式文件系统 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tobato</groupId>
|
<groupId>com.github.tobato</groupId>
|
||||||
@@ -163,8 +164,8 @@
|
|||||||
|
|
||||||
<!-- JSON 解析器和生成器 -->
|
<!-- JSON 解析器和生成器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson2</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -273,4 +274,29 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-api</artifactId>
|
<artifactId>ruoyi-api</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.List;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
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.JsonProperty;
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
||||||
import com.ruoyi.common.core.annotation.Excel.Type;
|
import com.ruoyi.common.core.annotation.Excel.Type;
|
||||||
@@ -198,7 +197,6 @@ public class SysUser extends BaseEntity
|
|||||||
this.avatar = avatar;
|
this.avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
return password;
|
return password;
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.system.api.factory.RemoteUserFallbackFactory,\
|
|
||||||
com.ruoyi.system.api.factory.RemoteLogFallbackFactory, \
|
|
||||||
com.ruoyi.system.api.factory.RemoteFileFallbackFactory
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
com.ruoyi.system.api.factory.RemoteUserFallbackFactory
|
||||||
|
com.ruoyi.system.api.factory.RemoteLogFallbackFactory
|
||||||
|
com.ruoyi.system.api.factory.RemoteFileFallbackFactory
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -148,11 +148,11 @@ public class SysLoginService
|
|||||||
// 日志状态
|
// 日志状态
|
||||||
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
|
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
|
||||||
{
|
{
|
||||||
logininfor.setStatus("0");
|
logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
|
||||||
}
|
}
|
||||||
else if (Constants.LOGIN_FAIL.equals(status))
|
else if (Constants.LOGIN_FAIL.equals(status))
|
||||||
{
|
{
|
||||||
logininfor.setStatus("1");
|
logininfor.setStatus(Constants.LOGIN_FAIL_STATUS);
|
||||||
}
|
}
|
||||||
remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
|
remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@
|
|||||||
|
|
||||||
<!-- Alibaba Fastjson -->
|
<!-- Alibaba Fastjson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson2</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Jwt -->
|
<!-- Jwt -->
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ 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.core.utils.poi.ExcelHandlerAdapter;
|
import com.ruoyi.common.core.utils.poi.ExcelHandlerAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,11 +53,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中每个列的高度 单位为字符
|
||||||
*/
|
*/
|
||||||
@@ -102,9 +99,19 @@ public @interface Excel
|
|||||||
public boolean isStatistics() default false;
|
public boolean isStatistics() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
|
* 导出类型(0数字 1字符串)
|
||||||
*/
|
*/
|
||||||
public Align align() default Align.AUTO;
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字体颜色
|
||||||
|
*/
|
||||||
|
public IndexedColors color() default IndexedColors.BLACK;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字段对齐方式
|
||||||
|
*/
|
||||||
|
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义数据处理器
|
* 自定义数据处理器
|
||||||
@@ -116,22 +123,6 @@ public @interface Excel
|
|||||||
*/
|
*/
|
||||||
public String[] args() default {};
|
public String[] args() default {};
|
||||||
|
|
||||||
public enum Align
|
|
||||||
{
|
|
||||||
AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
Align(int value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int value()
|
|
||||||
{
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ public class Constants
|
|||||||
*/
|
*/
|
||||||
public static final Integer FAIL = 500;
|
public static final Integer FAIL = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录成功状态
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_SUCCESS_STATUS = "0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录失败状态
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_FAIL_STATUS = "1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录成功
|
* 登录成功
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -561,17 +561,12 @@ public class Convert
|
|||||||
switch (valueStr)
|
switch (valueStr)
|
||||||
{
|
{
|
||||||
case "true":
|
case "true":
|
||||||
return true;
|
|
||||||
case "false":
|
|
||||||
return false;
|
|
||||||
case "yes":
|
case "yes":
|
||||||
return true;
|
|
||||||
case "ok":
|
case "ok":
|
||||||
return true;
|
|
||||||
case "no":
|
|
||||||
return false;
|
|
||||||
case "1":
|
case "1":
|
||||||
return true;
|
return true;
|
||||||
|
case "false":
|
||||||
|
case "no":
|
||||||
case "0":
|
case "0":
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
@@ -907,7 +902,7 @@ public class Convert
|
|||||||
*/
|
*/
|
||||||
public static String toSBC(String input, Set<Character> notConvertSet)
|
public static String toSBC(String input, Set<Character> notConvertSet)
|
||||||
{
|
{
|
||||||
char c[] = input.toCharArray();
|
char[] c = input.toCharArray();
|
||||||
for (int i = 0; i < c.length; i++)
|
for (int i = 0; i < c.length; i++)
|
||||||
{
|
{
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
||||||
@@ -949,7 +944,7 @@ public class Convert
|
|||||||
*/
|
*/
|
||||||
public static String toDBC(String text, Set<Character> notConvertSet)
|
public static String toDBC(String text, Set<Character> notConvertSet)
|
||||||
{
|
{
|
||||||
char c[] = text.toCharArray();
|
char[] c = text.toCharArray();
|
||||||
for (int i = 0; i < c.length; i++)
|
for (int i = 0; i < c.length; i++)
|
||||||
{
|
{
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
||||||
|
|||||||
@@ -3,12 +3,17 @@ package com.ruoyi.common.core.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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间工具类
|
* 时间工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
@@ -22,15 +27,15 @@ 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",
|
||||||
"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"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前Date型日期
|
* 获取当前Date型日期
|
||||||
*
|
*
|
||||||
* @return Date() 当前日期
|
* @return Date() 当前日期
|
||||||
*/
|
*/
|
||||||
public static Date getNowDate()
|
public static Date getNowDate()
|
||||||
@@ -40,7 +45,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static String getDate()
|
public static String getDate()
|
||||||
@@ -121,7 +126,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务器启动时间
|
* 获取服务器启动时间
|
||||||
*/
|
*/
|
||||||
@@ -152,4 +157,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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -20,11 +20,16 @@ public class PageUtils extends PageHelper
|
|||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
{
|
Boolean reasonable = pageDomain.getReasonable();
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
||||||
Boolean reasonable = pageDomain.getReasonable();
|
}
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
|
||||||
}
|
/**
|
||||||
|
* 清理分页的线程变量
|
||||||
|
*/
|
||||||
|
public static void clearPage()
|
||||||
|
{
|
||||||
|
PageHelper.clearPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
package com.ruoyi.common.core.utils;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
|
|
||||||
public class ReUtil
|
|
||||||
{
|
|
||||||
public final static Pattern GROUP_VAR = Pattern.compile("\\$(\\d+)");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则中需要被转义的关键字
|
|
||||||
*/
|
|
||||||
public final static Set<Character> RE_KEYS = new HashSet<>(
|
|
||||||
Arrays.asList('$', '(', ')', '*', '+', '.', '[', ']', '?', '\\', '^', '{', '}', '|'));;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则替换指定值<br>
|
|
||||||
* 通过正则查找到字符串,然后把匹配到的字符串加入到replacementTemplate中,$1表示分组1的字符串
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* 例如:原字符串是:中文1234,我想把1234换成(1234),则可以:
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* ReUtil.replaceAll("中文1234", "(\\d+)", "($1)"))
|
|
||||||
*
|
|
||||||
* 结果:中文(1234)
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @param content 文本
|
|
||||||
* @param regex 正则
|
|
||||||
* @param replacementTemplate 替换的文本模板,可以使用$1类似的变量提取正则匹配出的内容
|
|
||||||
* @return 处理后的文本
|
|
||||||
*/
|
|
||||||
public static String replaceAll(CharSequence content, String regex, String replacementTemplate)
|
|
||||||
{
|
|
||||||
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
|
|
||||||
return replaceAll(content, pattern, replacementTemplate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则替换指定值<br>
|
|
||||||
* 通过正则查找到字符串,然后把匹配到的字符串加入到replacementTemplate中,$1表示分组1的字符串
|
|
||||||
*
|
|
||||||
* @param content 文本
|
|
||||||
* @param pattern {@link Pattern}
|
|
||||||
* @param replacementTemplate 替换的文本模板,可以使用$1类似的变量提取正则匹配出的内容
|
|
||||||
* @return 处理后的文本
|
|
||||||
* @since 3.0.4
|
|
||||||
*/
|
|
||||||
public static String replaceAll(CharSequence content, Pattern pattern, String replacementTemplate)
|
|
||||||
{
|
|
||||||
if (StringUtils.isEmpty(content))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Matcher matcher = pattern.matcher(content);
|
|
||||||
boolean result = matcher.find();
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
final Set<String> varNums = findAll(GROUP_VAR, replacementTemplate, 1, new HashSet<>());
|
|
||||||
final StringBuffer sb = new StringBuffer();
|
|
||||||
do
|
|
||||||
{
|
|
||||||
String replacement = replacementTemplate;
|
|
||||||
for (String var : varNums)
|
|
||||||
{
|
|
||||||
int group = Integer.parseInt(var);
|
|
||||||
replacement = replacement.replace("$" + var, matcher.group(group));
|
|
||||||
}
|
|
||||||
matcher.appendReplacement(sb, escape(replacement));
|
|
||||||
result = matcher.find();
|
|
||||||
}
|
|
||||||
while (result);
|
|
||||||
matcher.appendTail(sb);
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
return Convert.toStr(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取得内容中匹配的所有结果
|
|
||||||
*
|
|
||||||
* @param <T> 集合类型
|
|
||||||
* @param pattern 编译后的正则模式
|
|
||||||
* @param content 被查找的内容
|
|
||||||
* @param group 正则的分组
|
|
||||||
* @param collection 返回的集合类型
|
|
||||||
* @return 结果集
|
|
||||||
*/
|
|
||||||
public static <T extends Collection<String>> T findAll(Pattern pattern, CharSequence content, int group,
|
|
||||||
T collection)
|
|
||||||
{
|
|
||||||
if (null == pattern || null == content)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null == collection)
|
|
||||||
{
|
|
||||||
throw new NullPointerException("Null collection param provided!");
|
|
||||||
}
|
|
||||||
|
|
||||||
final Matcher matcher = pattern.matcher(content);
|
|
||||||
while (matcher.find())
|
|
||||||
{
|
|
||||||
collection.add(matcher.group(group));
|
|
||||||
}
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 转义字符,将正则的关键字转义
|
|
||||||
*
|
|
||||||
* @param c 字符
|
|
||||||
* @return 转义后的文本
|
|
||||||
*/
|
|
||||||
public static String escape(char c)
|
|
||||||
{
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
if (RE_KEYS.contains(c))
|
|
||||||
{
|
|
||||||
builder.append('\\');
|
|
||||||
}
|
|
||||||
builder.append(c);
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 转义字符串,将正则的关键字转义
|
|
||||||
*
|
|
||||||
* @param content 文本
|
|
||||||
* @return 转义后的文本
|
|
||||||
*/
|
|
||||||
public static String escape(CharSequence content)
|
|
||||||
{
|
|
||||||
if (StringUtils.isBlank(content))
|
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
int len = content.length();
|
|
||||||
char current;
|
|
||||||
for (int i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
current = content.charAt(i);
|
|
||||||
if (RE_KEYS.contains(current))
|
|
||||||
{
|
|
||||||
builder.append('\\');
|
|
||||||
}
|
|
||||||
builder.append(current);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -15,10 +14,11 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
|
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
@@ -142,7 +142,7 @@ public class ServletUtils
|
|||||||
|
|
||||||
public static Map<String, String> getHeaders(HttpServletRequest request)
|
public static Map<String, String> getHeaders(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
Map<String, String> map = new LinkedHashMap<>();
|
Map<String, String> map = new LinkedCaseInsensitiveMap<>();
|
||||||
Enumeration<String> enumeration = request.getHeaderNames();
|
Enumeration<String> enumeration = request.getHeaderNames();
|
||||||
if (enumeration != null)
|
if (enumeration != null)
|
||||||
{
|
{
|
||||||
@@ -161,9 +161,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
|
||||||
{
|
{
|
||||||
@@ -176,7 +175,6 @@ public class ServletUtils
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,13 +185,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;
|
||||||
}
|
}
|
||||||
@@ -205,11 +203,7 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,7 +296,7 @@ public class ServletUtils
|
|||||||
response.setStatusCode(status);
|
response.setStatusCode(status);
|
||||||
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, contentType);
|
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, contentType);
|
||||||
R<?> result = R.fail(code, value.toString());
|
R<?> result = R.fail(code, value.toString());
|
||||||
DataBuffer dataBuffer = response.bufferFactory().wrap(JSONObject.toJSONString(result).getBytes());
|
DataBuffer dataBuffer = response.bufferFactory().wrap(JSON.toJSONString(result).getBytes());
|
||||||
return response.writeWith(Mono.just(dataBuffer));
|
return response.writeWith(Mono.just(dataBuffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -478,4 +478,53 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
{
|
{
|
||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.ruoyi.common.core.utils.file;
|
package com.ruoyi.common.core.utils.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件类型工具类
|
* 文件类型工具类
|
||||||
@@ -45,6 +48,22 @@ public class FileTypeUtils
|
|||||||
return fileName.substring(separatorIndex + 1).toLowerCase();
|
return fileName.substring(separatorIndex + 1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件名的后缀
|
||||||
|
*
|
||||||
|
* @param file 表单文件
|
||||||
|
* @return 后缀名
|
||||||
|
*/
|
||||||
|
public static final String getExtension(MultipartFile file)
|
||||||
|
{
|
||||||
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||||
|
if (StringUtils.isEmpty(extension))
|
||||||
|
{
|
||||||
|
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
||||||
|
}
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件类型
|
* 获取文件类型
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.common.core.utils.file;
|
package com.ruoyi.common.core.utils.file;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@@ -55,13 +54,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
|
||||||
{
|
{
|
||||||
// 网络地址
|
// 网络地址
|
||||||
@@ -81,7 +79,6 @@ public class ImageUtils
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtils.closeQuietly(in);
|
IOUtils.closeQuietly(in);
|
||||||
IOUtils.closeQuietly(baos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,58 +12,62 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|||||||
*/
|
*/
|
||||||
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)
|
||||||
{
|
{
|
||||||
return null;
|
return "unknown";
|
||||||
|
}
|
||||||
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("X-Forwarded-For");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
{
|
||||||
|
ip = request.getHeader("X-Real-IP");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ip = null;
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
|
|
||||||
// X-Forwarded-For:Squid 服务代理
|
|
||||||
String ipAddresses = request.getHeader("X-Forwarded-For");
|
|
||||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses))
|
|
||||||
{
|
|
||||||
// Proxy-Client-IP:apache 服务代理
|
|
||||||
ipAddresses = request.getHeader("Proxy-Client-IP");
|
|
||||||
}
|
|
||||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses))
|
|
||||||
{
|
|
||||||
// WL-Proxy-Client-IP:weblogic 服务代理
|
|
||||||
ipAddresses = request.getHeader("WL-Proxy-Client-IP");
|
|
||||||
}
|
|
||||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses))
|
|
||||||
{
|
|
||||||
// HTTP_CLIENT_IP:有些代理服务器
|
|
||||||
ipAddresses = request.getHeader("HTTP_CLIENT_IP");
|
|
||||||
}
|
|
||||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses))
|
|
||||||
{
|
|
||||||
// X-Real-IP:nginx服务代理
|
|
||||||
ipAddresses = request.getHeader("X-Real-IP");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
|
|
||||||
if (ipAddresses != null && ipAddresses.length() != 0)
|
|
||||||
{
|
|
||||||
ip = ipAddresses.split(",")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 还是不能获取到,最后再通过request.getRemoteAddr();获取
|
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses))
|
|
||||||
{
|
{
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
return ip.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : 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)
|
||||||
@@ -124,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);
|
||||||
@@ -134,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);
|
||||||
@@ -150,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);
|
||||||
@@ -166,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);
|
||||||
@@ -183,6 +193,11 @@ public class IpUtils
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IP地址
|
||||||
|
*
|
||||||
|
* @return 本地IP地址
|
||||||
|
*/
|
||||||
public static String getHostIp()
|
public static String getHostIp()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -195,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
|
||||||
@@ -206,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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -16,6 +18,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
@@ -56,13 +59,17 @@ import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel相关处理
|
* Excel相关处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ExcelUtil<T>
|
public class ExcelUtil<T>
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
||||||
|
|
||||||
|
public static final String FORMULA_REGEX_STR = "=|-|\\+|@";
|
||||||
|
|
||||||
|
public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel sheet最大行数,默认65536
|
* Excel sheet最大行数,默认65536
|
||||||
*/
|
*/
|
||||||
@@ -107,7 +114,7 @@ public class ExcelUtil<T>
|
|||||||
* 当前行号
|
* 当前行号
|
||||||
*/
|
*/
|
||||||
private int rownum;
|
private int rownum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标题
|
* 标题
|
||||||
*/
|
*/
|
||||||
@@ -172,7 +179,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对excel表单默认第一个索引名转换成list
|
* 对excel表单默认第一个索引名转换成list
|
||||||
*
|
*
|
||||||
* @param is 输入流
|
* @param is 输入流
|
||||||
* @return 转换后集合
|
* @return 转换后集合
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +190,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对excel表单默认第一个索引名转换成list
|
* 对excel表单默认第一个索引名转换成list
|
||||||
*
|
*
|
||||||
* @param is 输入流
|
* @param is 输入流
|
||||||
* @param titleNum 标题占用行数
|
* @param titleNum 标题占用行数
|
||||||
* @return 转换后集合
|
* @return 转换后集合
|
||||||
@@ -195,7 +202,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对excel表单指定表格索引名转换成list
|
* 对excel表单指定表格索引名转换成list
|
||||||
*
|
*
|
||||||
* @param sheetName 表格索引名
|
* @param sheetName 表格索引名
|
||||||
* @param titleNum 标题占用行数
|
* @param titleNum 标题占用行数
|
||||||
* @param is 输入流
|
* @param is 输入流
|
||||||
@@ -280,7 +287,7 @@ public class ExcelUtil<T>
|
|||||||
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
||||||
if (StringUtils.isNotEmpty(dateFormat))
|
if (StringUtils.isNotEmpty(dateFormat))
|
||||||
{
|
{
|
||||||
val = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
val = parseDateToStr(dateFormat, val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -292,7 +299,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
val = Convert.toInt(val);
|
val = Convert.toInt(val);
|
||||||
}
|
}
|
||||||
else if (Long.TYPE == fieldType || Long.class == fieldType)
|
else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
|
||||||
{
|
{
|
||||||
val = Convert.toLong(val);
|
val = Convert.toLong(val);
|
||||||
}
|
}
|
||||||
@@ -349,7 +356,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
* @param response 返回数据
|
* @param response 返回数据
|
||||||
* @param list 导出数据集合
|
* @param list 导出数据集合
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
@@ -363,7 +370,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
* @param response 返回数据
|
* @param response 返回数据
|
||||||
* @param list 导出数据集合
|
* @param list 导出数据集合
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
@@ -381,13 +388,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
* @param sheetName 工作表的名称
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -398,7 +399,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @param title 标题
|
* @param title 标题
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@@ -413,7 +414,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void exportExcel(HttpServletResponse response)
|
public void exportExcel(HttpServletResponse response)
|
||||||
@@ -463,7 +464,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 填充excel数据
|
* 填充excel数据
|
||||||
*
|
*
|
||||||
* @param index 序号
|
* @param index 序号
|
||||||
* @param row 单元格行
|
* @param row 单元格行
|
||||||
*/
|
*/
|
||||||
@@ -488,7 +489,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建表格样式
|
* 创建表格样式
|
||||||
*
|
*
|
||||||
* @param wb 工作薄对象
|
* @param wb 工作薄对象
|
||||||
* @return 样式列表
|
* @return 样式列表
|
||||||
*/
|
*/
|
||||||
@@ -546,21 +547,46 @@ public class ExcelUtil<T>
|
|||||||
style.setFont(totalFont);
|
style.setFont(totalFont);
|
||||||
styles.put("total", style);
|
styles.put("total", style);
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
styles.putAll(annotationStyles(wb));
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
|
||||||
style.setAlignment(HorizontalAlignment.LEFT);
|
|
||||||
styles.put("data1", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
return styles;
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
}
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
styles.put("data2", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
|
||||||
style.setAlignment(HorizontalAlignment.RIGHT);
|
|
||||||
styles.put("data3", style);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据Excel注解创建表格样式
|
||||||
|
*
|
||||||
|
* @param wb 工作薄对象
|
||||||
|
* @return 自定义样式列表
|
||||||
|
*/
|
||||||
|
private Map<String, CellStyle> annotationStyles(Workbook wb)
|
||||||
|
{
|
||||||
|
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||||
|
for (Object[] os : fields)
|
||||||
|
{
|
||||||
|
Excel excel = (Excel) os[1];
|
||||||
|
String key = "data_" + excel.align() + "_" + excel.color();
|
||||||
|
if (!styles.containsKey(key))
|
||||||
|
{
|
||||||
|
CellStyle style = wb.createCellStyle();
|
||||||
|
style = wb.createCellStyle();
|
||||||
|
style.setAlignment(excel.align());
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
|
style.setBorderLeft(BorderStyle.THIN);
|
||||||
|
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
|
style.setBorderTop(BorderStyle.THIN);
|
||||||
|
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
|
style.setBorderBottom(BorderStyle.THIN);
|
||||||
|
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
|
Font dataFont = wb.createFont();
|
||||||
|
dataFont.setFontName("Arial");
|
||||||
|
dataFont.setFontHeightInPoints((short) 10);
|
||||||
|
dataFont.setColor(excel.color().index);
|
||||||
|
style.setFont(dataFont);
|
||||||
|
styles.put(key, style);
|
||||||
|
}
|
||||||
|
}
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,7 +606,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置单元格信息
|
* 设置单元格信息
|
||||||
*
|
*
|
||||||
* @param value 单元格值
|
* @param value 单元格值
|
||||||
* @param attr 注解相关
|
* @param attr 注解相关
|
||||||
* @param cell 单元格信息
|
* @param cell 单元格信息
|
||||||
@@ -589,7 +615,13 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
if (ColumnType.STRING == attr.cellType())
|
if (ColumnType.STRING == attr.cellType())
|
||||||
{
|
{
|
||||||
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
String cellValue = Convert.toStr(value);
|
||||||
|
// 对于任何以表达式触发字符 =-+@开头的单元格,直接使用tab字符作为前缀,防止CSV注入。
|
||||||
|
if (StringUtils.startsWithAny(cellValue, FORMULA_STR))
|
||||||
|
{
|
||||||
|
cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0");
|
||||||
|
}
|
||||||
|
cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix());
|
||||||
}
|
}
|
||||||
else if (ColumnType.NUMERIC == attr.cellType())
|
else if (ColumnType.NUMERIC == attr.cellType())
|
||||||
{
|
{
|
||||||
@@ -654,17 +686,10 @@ public class ExcelUtil<T>
|
|||||||
// 设置列宽
|
// 设置列宽
|
||||||
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
||||||
}
|
}
|
||||||
// 如果设置了提示信息则鼠标放上去提示.
|
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0)
|
||||||
if (StringUtils.isNotEmpty(attr.prompt()))
|
|
||||||
{
|
{
|
||||||
// 这里默认设了2-101列提示.
|
// 提示信息或只能选择不能输入的列内容.
|
||||||
setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
|
setPromptOrValidation(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
||||||
}
|
|
||||||
// 如果设置了combo属性则本列只能选择不能输入
|
|
||||||
if (attr.combo().length > 0)
|
|
||||||
{
|
|
||||||
// 这里默认设了2-101列只能选择不能输入.
|
|
||||||
setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,8 +708,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
// 创建cell
|
// 创建cell
|
||||||
cell = row.createCell(column);
|
cell = row.createCell(column);
|
||||||
int align = attr.align().value();
|
cell.setCellStyle(styles.get("data_" + attr.align() + "_" + attr.color()));
|
||||||
cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
|
||||||
|
|
||||||
// 用于读取对象中的属性
|
// 用于读取对象中的属性
|
||||||
Object value = getTargetValue(vo, field, attr);
|
Object value = getTargetValue(vo, field, attr);
|
||||||
@@ -693,7 +717,7 @@ public class ExcelUtil<T>
|
|||||||
String separator = attr.separator();
|
String separator = attr.separator();
|
||||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
@@ -723,48 +747,29 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 POI XSSFSheet 单元格提示
|
* 设置 POI XSSFSheet 单元格提示或选择框
|
||||||
*
|
*
|
||||||
* @param sheet 表单
|
* @param sheet 表单
|
||||||
* @param promptTitle 提示标题
|
* @param textlist 下拉框显示的内容
|
||||||
* @param promptContent 提示内容
|
* @param promptContent 提示内容
|
||||||
* @param firstRow 开始行
|
* @param firstRow 开始行
|
||||||
* @param endRow 结束行
|
* @param endRow 结束行
|
||||||
* @param firstCol 开始列
|
* @param firstCol 开始列
|
||||||
* @param endCol 结束列
|
* @param endCol 结束列
|
||||||
*/
|
*/
|
||||||
public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
|
public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow,
|
||||||
int firstCol, int endCol)
|
int firstCol, int endCol)
|
||||||
{
|
{
|
||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||||
DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
|
DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1");
|
||||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
||||||
dataValidation.createPromptBox(promptTitle, promptContent);
|
if (StringUtils.isNotEmpty(promptContent))
|
||||||
dataValidation.setShowPromptBox(true);
|
{
|
||||||
sheet.addValidationData(dataValidation);
|
// 如果设置了提示信息则鼠标放上去提示
|
||||||
}
|
dataValidation.createPromptBox("", promptContent);
|
||||||
|
dataValidation.setShowPromptBox(true);
|
||||||
/**
|
}
|
||||||
* 设置某些列的值只能输入预制的数据,显示下拉框.
|
|
||||||
*
|
|
||||||
* @param sheet 要设置的sheet.
|
|
||||||
* @param textlist 下拉框显示的内容
|
|
||||||
* @param firstRow 开始行
|
|
||||||
* @param endRow 结束行
|
|
||||||
* @param firstCol 开始列
|
|
||||||
* @param endCol 结束列
|
|
||||||
* @return 设置好的sheet.
|
|
||||||
*/
|
|
||||||
public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol)
|
|
||||||
{
|
|
||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
|
||||||
// 加载下拉列表内容
|
|
||||||
DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
|
|
||||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
|
||||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
|
||||||
// 数据有效性对象
|
|
||||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
|
||||||
// 处理Excel兼容性问题
|
// 处理Excel兼容性问题
|
||||||
if (dataValidation instanceof XSSFDataValidation)
|
if (dataValidation instanceof XSSFDataValidation)
|
||||||
{
|
{
|
||||||
@@ -775,13 +780,12 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
dataValidation.setSuppressDropDownArrow(false);
|
dataValidation.setSuppressDropDownArrow(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet.addValidationData(dataValidation);
|
sheet.addValidationData(dataValidation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析导出值 0=男,1=女,2=未知
|
* 解析导出值 0=男,1=女,2=未知
|
||||||
*
|
*
|
||||||
* @param propertyValue 参数值
|
* @param propertyValue 参数值
|
||||||
* @param converterExp 翻译注解
|
* @param converterExp 翻译注解
|
||||||
* @param separator 分隔符
|
* @param separator 分隔符
|
||||||
@@ -818,7 +822,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 反向解析值 男=0,女=1,未知=2
|
* 反向解析值 男=0,女=1,未知=2
|
||||||
*
|
*
|
||||||
* @param propertyValue 参数值
|
* @param propertyValue 参数值
|
||||||
* @param converterExp 翻译注解
|
* @param converterExp 翻译注解
|
||||||
* @param separator 分隔符
|
* @param separator 分隔符
|
||||||
@@ -855,7 +859,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据处理器
|
* 数据处理器
|
||||||
*
|
*
|
||||||
* @param value 数据值
|
* @param value 数据值
|
||||||
* @param excel 数据注解
|
* @param excel 数据注解
|
||||||
* @return
|
* @return
|
||||||
@@ -923,7 +927,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取bean中的属性值
|
* 获取bean中的属性值
|
||||||
*
|
*
|
||||||
* @param vo 实体对象
|
* @param vo 实体对象
|
||||||
* @param field 字段
|
* @param field 字段
|
||||||
* @param excel 注解
|
* @param excel 注解
|
||||||
@@ -936,7 +940,7 @@ public class ExcelUtil<T>
|
|||||||
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
||||||
{
|
{
|
||||||
String target = excel.targetAttr();
|
String target = excel.targetAttr();
|
||||||
if (target.indexOf(".") > -1)
|
if (target.contains("."))
|
||||||
{
|
{
|
||||||
String[] targets = target.split("[.]");
|
String[] targets = target.split("[.]");
|
||||||
for (String name : targets)
|
for (String name : targets)
|
||||||
@@ -954,7 +958,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 以类的属性的get方法方法形式获取值
|
* 以类的属性的get方法方法形式获取值
|
||||||
*
|
*
|
||||||
* @param o
|
* @param o
|
||||||
* @param name
|
* @param name
|
||||||
* @return value
|
* @return value
|
||||||
@@ -1031,7 +1035,7 @@ public class ExcelUtil<T>
|
|||||||
for (Object[] os : this.fields)
|
for (Object[] os : this.fields)
|
||||||
{
|
{
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
maxHeight = Math.max(maxHeight, excel.height());
|
||||||
}
|
}
|
||||||
return (short) (maxHeight * 20);
|
return (short) (maxHeight * 20);
|
||||||
}
|
}
|
||||||
@@ -1049,7 +1053,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建工作表
|
* 创建工作表
|
||||||
*
|
*
|
||||||
* @param sheetNo sheet数量
|
* @param sheetNo sheet数量
|
||||||
* @param index 序号
|
* @param index 序号
|
||||||
*/
|
*/
|
||||||
@@ -1066,7 +1070,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单元格值
|
* 获取单元格值
|
||||||
*
|
*
|
||||||
* @param row 获取的行
|
* @param row 获取的行
|
||||||
* @param column 获取单元格列号
|
* @param column 获取单元格列号
|
||||||
* @return 单元格值
|
* @return 单元格值
|
||||||
@@ -1126,7 +1130,7 @@ public class ExcelUtil<T>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否是空行
|
* 判断是否是空行
|
||||||
*
|
*
|
||||||
* @param row 判断的行
|
* @param row 判断的行
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -1146,4 +1150,37 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 格式化不同类型的日期对象
|
||||||
|
*
|
||||||
|
* @param dateFormat 日期格式
|
||||||
|
* @param val 被格式化的日期对象
|
||||||
|
* @return 格式化后的日期字符
|
||||||
|
*/
|
||||||
|
public String parseDateToStr(String dateFormat, Object val)
|
||||||
|
{
|
||||||
|
if (val == null)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String str;
|
||||||
|
if (val instanceof Date)
|
||||||
|
{
|
||||||
|
str = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
||||||
|
}
|
||||||
|
else if (val instanceof LocalDateTime)
|
||||||
|
{
|
||||||
|
str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime) val));
|
||||||
|
}
|
||||||
|
else if (val instanceof LocalDate)
|
||||||
|
{
|
||||||
|
str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate) val));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = val.toString();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ public class SqlUtil
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
||||||
for (int i = 0; i < sqlKeywords.length; i++)
|
for (String sqlKeyword : sqlKeywords)
|
||||||
{
|
{
|
||||||
if (StringUtils.indexOfIgnoreCase(value, sqlKeywords[i]) > -1)
|
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
|
||||||
{
|
{
|
||||||
throw new UtilException("参数存在SQL注入风险");
|
throw new UtilException("参数存在SQL注入风险");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils.uuid;
|
||||||
|
|
||||||
import com.ruoyi.common.core.text.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID生成器工具类
|
* ID生成器工具类
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.ruoyi.common.core.utils.uuid;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ruoyi 序列生成类
|
||||||
|
*/
|
||||||
|
public class Seq
|
||||||
|
{
|
||||||
|
// 通用序列类型
|
||||||
|
public static final String commSeqType = "COMMON";
|
||||||
|
|
||||||
|
// 上传序列类型
|
||||||
|
public static final String uploadSeqType = "UPLOAD";
|
||||||
|
|
||||||
|
// 通用接口序列数
|
||||||
|
private static AtomicInteger commSeq = new AtomicInteger(1);
|
||||||
|
|
||||||
|
// 上传接口序列数
|
||||||
|
private static AtomicInteger uploadSeq = new AtomicInteger(1);
|
||||||
|
|
||||||
|
// 机器标识
|
||||||
|
private static String machineCode = "A";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取通用序列号
|
||||||
|
*
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
public static String getId()
|
||||||
|
{
|
||||||
|
return getId(commSeqType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串
|
||||||
|
*
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
public static String getId(String type)
|
||||||
|
{
|
||||||
|
AtomicInteger atomicInt = commSeq;
|
||||||
|
if (uploadSeqType.equals(type))
|
||||||
|
{
|
||||||
|
atomicInt = uploadSeq;
|
||||||
|
}
|
||||||
|
return getId(atomicInt, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串
|
||||||
|
*
|
||||||
|
* @param atomicInt 序列数
|
||||||
|
* @param length 数值长度
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
public static String getId(AtomicInteger atomicInt, int length)
|
||||||
|
{
|
||||||
|
String result = DateUtils.dateTimeNow();
|
||||||
|
result += machineCode;
|
||||||
|
result += getSeq(atomicInt, length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数
|
||||||
|
*
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
private synchronized static String getSeq(AtomicInteger atomicInt, int length)
|
||||||
|
{
|
||||||
|
// 先取值再+1
|
||||||
|
int value = atomicInt.getAndIncrement();
|
||||||
|
|
||||||
|
// 如果更新后值>=10 的 (length)幂次方则重置为1
|
||||||
|
int maxSeq = (int) Math.pow(10, length);
|
||||||
|
if (atomicInt.get() >= maxSeq)
|
||||||
|
{
|
||||||
|
atomicInt.set(1);
|
||||||
|
}
|
||||||
|
// 转字符串,用0左补齐
|
||||||
|
return StringUtils.padl(value, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.ruoyi.common.core.text;
|
package com.ruoyi.common.core.utils.uuid;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@@ -48,6 +48,14 @@ public class BaseController
|
|||||||
PageUtils.startPage();
|
PageUtils.startPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理分页的线程变量
|
||||||
|
*/
|
||||||
|
protected void clearPage()
|
||||||
|
{
|
||||||
|
PageUtils.clearPage();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.common.core.web.page;
|
package com.ruoyi.common.core.web.page;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +41,8 @@ public class TableSupport
|
|||||||
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));
|
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.ruoyi.common.core.xss;
|
package com.ruoyi.common.core.xss;
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
|
||||||
import javax.validation.ConstraintValidatorContext;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import javax.validation.ConstraintValidator;
|
||||||
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义xss校验注解实现
|
* 自定义xss校验注解实现
|
||||||
@@ -12,15 +13,19 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class XssValidator implements ConstraintValidator<Xss, String>
|
public class XssValidator implements ConstraintValidator<Xss, String>
|
||||||
{
|
{
|
||||||
private final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
|
private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
|
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
|
||||||
{
|
{
|
||||||
|
if (StringUtils.isBlank(value))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return !containsHtml(value);
|
return !containsHtml(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsHtml(String value)
|
public static boolean containsHtml(String value)
|
||||||
{
|
{
|
||||||
Pattern pattern = Pattern.compile(HTML_PATTERN);
|
Pattern pattern = Pattern.compile(HTML_PATTERN);
|
||||||
Matcher matcher = pattern.matcher(value);
|
Matcher matcher = pattern.matcher(value);
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.common.core.utils.SpringUtils
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
com.ruoyi.common.core.utils.SpringUtils
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class DataScopeAspect
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
||||||
sqlString.append(" OR 1=0 ");
|
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.common.datascope.aspect.DataScopeAspect
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
com.ruoyi.common.datascope.aspect.DataScopeAspect
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.ruoyi.common.datasource.env;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* seata 在 springboot 2.6.x 存在循环引用问题的处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class ApplicationSeataInitializer implements EnvironmentPostProcessor, Ordered
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application)
|
|
||||||
{
|
|
||||||
System.setProperty("spring.main.allow-circular-references", "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOrder()
|
|
||||||
{
|
|
||||||
return Ordered.LOWEST_PRECEDENCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
|
||||||
com.ruoyi.common.datasource.env.ApplicationSeataInitializer
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.http.HttpMethod;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
import com.ruoyi.common.core.utils.ip.IpUtils;
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.common.log.service.AsyncLogService,\
|
|
||||||
com.ruoyi.common.log.aspect.LogAspect
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
com.ruoyi.common.log.service.AsyncLogService
|
||||||
|
com.ruoyi.common.log.aspect.LogAspect
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package com.ruoyi.common.redis.configure;
|
package com.ruoyi.common.redis.configure;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import java.nio.charset.Charset;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.SerializationException;
|
import org.springframework.data.redis.serializer.SerializationException;
|
||||||
import com.alibaba.fastjson.parser.ParserConfig;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import org.springframework.util.Assert;
|
import com.alibaba.fastjson2.JSONReader;
|
||||||
import java.nio.charset.Charset;
|
import com.alibaba.fastjson2.JSONWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis使用FastJson序列化
|
* Redis使用FastJson序列化
|
||||||
@@ -18,17 +14,10 @@ import java.nio.charset.Charset;
|
|||||||
*/
|
*/
|
||||||
public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||||
|
|
||||||
private Class<T> clazz;
|
private Class<T> clazz;
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
||||||
{
|
{
|
||||||
@@ -43,7 +32,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|||||||
{
|
{
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
|
return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,17 +44,6 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|||||||
}
|
}
|
||||||
String str = new String(bytes, DEFAULT_CHARSET);
|
String str = new String(bytes, DEFAULT_CHARSET);
|
||||||
|
|
||||||
return JSON.parseObject(str, clazz);
|
return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
||||||
}
|
|
||||||
|
|
||||||
public void setObjectMapper(ObjectMapper objectMapper)
|
|
||||||
{
|
|
||||||
Assert.notNull(objectMapper, "'objectMapper' must not be null");
|
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected JavaType getJavaType(Class<?> clazz)
|
|
||||||
{
|
|
||||||
return TypeFactory.defaultInstance().constructType(clazz);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.ruoyi.common.redis.configure;
|
package com.ruoyi.common.redis.configure;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
|
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -7,11 +9,6 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis配置
|
* redis配置
|
||||||
@@ -20,6 +17,7 @@ import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
|
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
||||||
public class RedisConfig extends CachingConfigurerSupport
|
public class RedisConfig extends CachingConfigurerSupport
|
||||||
{
|
{
|
||||||
@Bean
|
@Bean
|
||||||
@@ -31,11 +29,6 @@ public class RedisConfig extends CachingConfigurerSupport
|
|||||||
|
|
||||||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
|
||||||
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
|
||||||
serializer.setObjectMapper(mapper);
|
|
||||||
|
|
||||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||||
template.setKeySerializer(new StringRedisSerializer());
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
template.setValueSerializer(serializer);
|
template.setValueSerializer(serializer);
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.common.redis.configure.RedisConfig,\
|
|
||||||
com.ruoyi.common.redis.service.RedisService
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
com.ruoyi.common.redis.configure.RedisConfig
|
||||||
|
com.ruoyi.common.redis.service.RedisService
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class AuthLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证当前用户有效期, 如果相差不足360分钟,自动刷新缓存
|
* 验证当前用户有效期, 如果相差不足120分钟,自动刷新缓存
|
||||||
*
|
*
|
||||||
* @param loginUser 当前用户信息
|
* @param loginUser 当前用户信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
import com.ruoyi.common.core.constant.CacheConstants;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.utils.IdUtils;
|
|
||||||
import com.ruoyi.common.core.utils.JwtUtils;
|
import com.ruoyi.common.core.utils.JwtUtils;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
import com.ruoyi.common.core.utils.ip.IpUtils;
|
||||||
|
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ruoyi.common.security.utils;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
@@ -34,11 +35,10 @@ public class DictUtils
|
|||||||
*/
|
*/
|
||||||
public static List<SysDictData> getDictCache(String key)
|
public static List<SysDictData> getDictCache(String key)
|
||||||
{
|
{
|
||||||
Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
|
JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
|
||||||
if (StringUtils.isNotNull(cacheObj))
|
if (StringUtils.isNotNull(arrayCache))
|
||||||
{
|
{
|
||||||
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
return arrayCache.toList(SysDictData.class);
|
||||||
return dictDatas;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.common.security.config.WebMvcConfig,\
|
|
||||||
com.ruoyi.common.security.service.TokenService,\
|
|
||||||
com.ruoyi.common.security.aspect.PreAuthorizeAspect,\
|
|
||||||
com.ruoyi.common.security.aspect.InnerAuthAspect,\
|
|
||||||
com.ruoyi.common.security.handler.GlobalExceptionHandler
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
com.ruoyi.common.security.config.WebMvcConfig
|
||||||
|
com.ruoyi.common.security.service.TokenService
|
||||||
|
com.ruoyi.common.security.aspect.PreAuthorizeAspect
|
||||||
|
com.ruoyi.common.security.aspect.InnerAuthAspect
|
||||||
|
com.ruoyi.common.security.handler.GlobalExceptionHandler
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.ruoyi.common.swagger.config.SwaggerAutoConfiguration,\
|
|
||||||
com.ruoyi.common.swagger.config.SwaggerWebConfiguration,\
|
|
||||||
com.ruoyi.common.swagger.config.SwaggerBeanPostProcessor
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
com.ruoyi.common.swagger.config.SwaggerAutoConfiguration
|
||||||
|
com.ruoyi.common.swagger.config.SwaggerWebConfiguration
|
||||||
|
com.ruoyi.common.swagger.config.SwaggerBeanPostProcessor
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -57,6 +57,12 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Loadbalancer -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--验证码 -->
|
<!--验证码 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class KaptchaTextCreator extends DefaultTextCreator
|
|||||||
int x = random.nextInt(10);
|
int x = random.nextInt(10);
|
||||||
int y = random.nextInt(10);
|
int y = random.nextInt(10);
|
||||||
StringBuilder suChinese = new StringBuilder();
|
StringBuilder suChinese = new StringBuilder();
|
||||||
int randomoperands = (int) Math.round(Math.random() * 2);
|
int randomoperands = random.nextInt(3);
|
||||||
if (randomoperands == 0)
|
if (randomoperands == 0)
|
||||||
{
|
{
|
||||||
result = x * y;
|
result = x * y;
|
||||||
@@ -30,7 +30,7 @@ public class KaptchaTextCreator extends DefaultTextCreator
|
|||||||
}
|
}
|
||||||
else if (randomoperands == 1)
|
else if (randomoperands == 1)
|
||||||
{
|
{
|
||||||
if (!(x == 0) && y % x == 0)
|
if ((x != 0) && y % x == 0)
|
||||||
{
|
{
|
||||||
result = y / x;
|
result = y / x;
|
||||||
suChinese.append(CNUMBERS[y]);
|
suChinese.append(CNUMBERS[y]);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.cloud.gateway.config.GatewayProperties;
|
import org.springframework.cloud.gateway.config.GatewayProperties;
|
||||||
import org.springframework.cloud.gateway.route.RouteLocator;
|
import org.springframework.cloud.gateway.route.RouteLocator;
|
||||||
import org.springframework.cloud.gateway.support.NameUtils;
|
import org.springframework.cloud.gateway.support.NameUtils;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
|
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
||||||
@@ -24,9 +25,11 @@ public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigu
|
|||||||
* Swagger2默认的url后缀
|
* Swagger2默认的url后缀
|
||||||
*/
|
*/
|
||||||
public static final String SWAGGER2URL = "/v2/api-docs";
|
public static final String SWAGGER2URL = "/v2/api-docs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网关路由
|
* 网关路由
|
||||||
*/
|
*/
|
||||||
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private RouteLocator routeLocator;
|
private RouteLocator routeLocator;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUr
|
|||||||
|
|
||||||
public boolean matchBlacklist(String url)
|
public boolean matchBlacklist(String url)
|
||||||
{
|
{
|
||||||
return blacklistUrlPattern.isEmpty() ? false : blacklistUrlPattern.stream().filter(p -> p.matcher(url).find()).findAny().isPresent();
|
return !blacklistUrlPattern.isEmpty() && blacklistUrlPattern.stream().anyMatch(p -> p.matcher(url).find());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getBlacklistUrl()
|
public List<String> getBlacklistUrl()
|
||||||
|
|||||||
@@ -6,14 +6,10 @@ import org.springframework.cloud.gateway.filter.GatewayFilter;
|
|||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.OrderedGatewayFilter;
|
import org.springframework.cloud.gateway.filter.OrderedGatewayFilter;
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,30 +50,16 @@ public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheReques
|
|||||||
{
|
{
|
||||||
// GET DELETE 不过滤
|
// GET DELETE 不过滤
|
||||||
HttpMethod method = exchange.getRequest().getMethod();
|
HttpMethod method = exchange.getRequest().getMethod();
|
||||||
if (method == null || method.matches("GET") || method.matches("DELETE"))
|
if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)
|
||||||
{
|
{
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
return DataBufferUtils.join(exchange.getRequest().getBody()).map(dataBuffer -> {
|
return ServerWebExchangeUtils.cacheRequestBodyAndRequest(exchange, (serverHttpRequest) -> {
|
||||||
byte[] bytes = new byte[dataBuffer.readableByteCount()];
|
if (serverHttpRequest == exchange.getRequest())
|
||||||
dataBuffer.read(bytes);
|
|
||||||
DataBufferUtils.release(dataBuffer);
|
|
||||||
return bytes;
|
|
||||||
}).defaultIfEmpty(new byte[0]).flatMap(bytes -> {
|
|
||||||
DataBufferFactory dataBufferFactory = exchange.getResponse().bufferFactory();
|
|
||||||
ServerHttpRequestDecorator decorator = new ServerHttpRequestDecorator(exchange.getRequest())
|
|
||||||
{
|
{
|
||||||
@Override
|
return chain.filter(exchange);
|
||||||
public Flux<DataBuffer> getBody()
|
}
|
||||||
{
|
return chain.filter(exchange.mutate().request(serverHttpRequest).build());
|
||||||
if (bytes.length > 0)
|
|
||||||
{
|
|
||||||
return Flux.just(dataBufferFactory.wrap(bytes));
|
|
||||||
}
|
|
||||||
return Flux.empty();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return chain.filter(exchange.mutate().request(decorator).build());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import org.springframework.core.io.buffer.DataBuffer;
|
|||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
||||||
@@ -19,7 +20,7 @@ import reactor.core.publisher.Flux;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码过滤器
|
* 验证码过滤器
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@@ -52,8 +53,8 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
String rspStr = resolveBodyFromRequest(request);
|
String rspStr = resolveBodyFromRequest(request);
|
||||||
JSONObject obj = JSONObject.parseObject(rspStr);
|
JSONObject obj = JSON.parseObject(rspStr);
|
||||||
validateCodeService.checkCapcha(obj.getString(CODE), obj.getString(UUID));
|
validateCodeService.checkCaptcha(obj.getString(CODE), obj.getString(UUID));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class XssFilter implements GlobalFilter, Ordered
|
|||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
// GET DELETE 不过滤
|
// GET DELETE 不过滤
|
||||||
HttpMethod method = request.getMethod();
|
HttpMethod method = request.getMethod();
|
||||||
if (method == null || method.matches("GET") || method.matches("DELETE"))
|
if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)
|
||||||
{
|
{
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public class XssFilter implements GlobalFilter, Ordered
|
|||||||
/**
|
/**
|
||||||
* 是否是Json请求
|
* 是否是Json请求
|
||||||
*
|
*
|
||||||
* @param request
|
* @param exchange HTTP请求
|
||||||
*/
|
*/
|
||||||
public boolean isJsonRequest(ServerWebExchange exchange)
|
public boolean isJsonRequest(ServerWebExchange exchange)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import reactor.core.publisher.Mono;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码获取
|
* 验证码获取
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@@ -30,7 +30,7 @@ public class ValidateCodeHandler implements HandlerFunction<ServerResponse>
|
|||||||
AjaxResult ajax;
|
AjaxResult ajax;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ajax = validateCodeService.createCapcha();
|
ajax = validateCodeService.createCaptcha();
|
||||||
}
|
}
|
||||||
catch (CaptchaException | IOException e)
|
catch (CaptchaException | IOException e)
|
||||||
{
|
{
|
||||||
@@ -38,4 +38,4 @@ public class ValidateCodeHandler implements HandlerFunction<ServerResponse>
|
|||||||
}
|
}
|
||||||
return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
|
return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码处理
|
* 验证码处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface ValidateCodeService
|
public interface ValidateCodeService
|
||||||
@@ -14,10 +14,10 @@ public interface ValidateCodeService
|
|||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
public AjaxResult createCapcha() throws IOException, CaptchaException;
|
public AjaxResult createCaptcha() throws IOException, CaptchaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验验证码
|
* 校验验证码
|
||||||
*/
|
*/
|
||||||
public void checkCapcha(String key, String value) throws CaptchaException;
|
public void checkCaptcha(String key, String value) throws CaptchaException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import org.springframework.util.FastByteArrayOutputStream;
|
|||||||
import com.google.code.kaptcha.Producer;
|
import com.google.code.kaptcha.Producer;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.exception.CaptchaException;
|
import com.ruoyi.common.core.exception.CaptchaException;
|
||||||
import com.ruoyi.common.core.utils.IdUtils;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.sign.Base64;
|
import com.ruoyi.common.core.utils.sign.Base64;
|
||||||
|
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
||||||
@@ -43,12 +43,12 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult createCapcha() throws IOException, CaptchaException
|
public AjaxResult createCaptcha() throws IOException, CaptchaException
|
||||||
{
|
{
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
boolean captchaOnOff = captchaProperties.getEnabled();
|
boolean captchaEnabled = captchaProperties.getEnabled();
|
||||||
ajax.put("captchaOnOff", captchaOnOff);
|
ajax.put("captchaEnabled", captchaEnabled);
|
||||||
if (!captchaOnOff)
|
if (!captchaEnabled)
|
||||||
{
|
{
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||||||
* 校验验证码
|
* 校验验证码
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkCapcha(String code, String uuid) throws CaptchaException
|
public void checkCaptcha(String code, String uuid) throws CaptchaException
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(code))
|
if (StringUtils.isEmpty(code))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ spring:
|
|||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
main:
|
|
||||||
allow-circular-references: true
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ package com.ruoyi.file.utils;
|
|||||||
|
|
||||||
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.core.exception.file.FileNameLengthLimitExceededException;
|
import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException;
|
||||||
import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException;
|
import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException;
|
||||||
import com.ruoyi.common.core.exception.file.InvalidExtensionException;
|
import com.ruoyi.common.core.exception.file.InvalidExtensionException;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.IdUtils;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
||||||
import com.ruoyi.common.core.utils.file.MimeTypeUtils;
|
import com.ruoyi.common.core.utils.file.MimeTypeUtils;
|
||||||
|
import com.ruoyi.common.core.utils.uuid.Seq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传工具类
|
* 文件上传工具类
|
||||||
@@ -65,7 +68,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);
|
||||||
@@ -75,10 +78,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(fileName);
|
return getPathFileName(fileName);
|
||||||
return pathFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,10 +88,8 @@ 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), FileTypeUtils.getExtension(file));
|
||||||
fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
|
||||||
return fileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
||||||
@@ -123,13 +123,13 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String extension = getExtension(file);
|
String extension = FileTypeUtils.getExtension(file);
|
||||||
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
|
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
|
||||||
{
|
{
|
||||||
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
|
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
|
||||||
@@ -177,20 +177,4 @@ public class FileUploadUtils
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件名的后缀
|
|
||||||
*
|
|
||||||
* @param file 表单文件
|
|
||||||
* @return 后缀名
|
|
||||||
*/
|
|
||||||
public static final String getExtension(MultipartFile file)
|
|
||||||
{
|
|
||||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
||||||
if (StringUtils.isEmpty(extension))
|
|
||||||
{
|
|
||||||
extension = MimeTypeUtils.getExtension(file.getContentType());
|
|
||||||
}
|
|
||||||
return extension;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ public class GenController extends BaseController
|
|||||||
* 修改代码生成业务
|
* 修改代码生成业务
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:query")
|
@RequiresPermissions("tool:gen:query")
|
||||||
@GetMapping(value = "/{talbleId}")
|
@GetMapping(value = "/{tableId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long talbleId)
|
public AjaxResult getInfo(@PathVariable Long tableId)
|
||||||
{
|
{
|
||||||
GenTable table = genTableService.selectGenTableById(talbleId);
|
GenTable table = genTableService.selectGenTableById(tableId);
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("info", table);
|
map.put("info", table);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
@@ -87,7 +87,7 @@ public class GenController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 查询数据表字段列表
|
* 查询数据表字段列表
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/column/{talbleId}")
|
@GetMapping(value = "/column/{tableId}")
|
||||||
public TableDataInfo columnList(Long tableId)
|
public TableDataInfo columnList(Long tableId)
|
||||||
{
|
{
|
||||||
TableDataInfo dataInfo = new TableDataInfo();
|
TableDataInfo dataInfo = new TableDataInfo();
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
@@ -121,7 +121,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateGenTable(GenTable genTable)
|
public void updateGenTable(GenTable genTable)
|
||||||
{
|
{
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
@@ -143,7 +143,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteGenTableByIds(Long[] tableIds)
|
public void deleteGenTableByIds(Long[] tableIds)
|
||||||
{
|
{
|
||||||
genTableMapper.deleteGenTableByIds(tableIds);
|
genTableMapper.deleteGenTableByIds(tableIds);
|
||||||
@@ -156,7 +156,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
* @param tableList 导入表列表
|
* @param tableList 导入表列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void importGenTable(List<GenTable> tableList)
|
public void importGenTable(List<GenTable> tableList)
|
||||||
{
|
{
|
||||||
String operName = SecurityUtils.getUsername();
|
String operName = SecurityUtils.getUsername();
|
||||||
@@ -282,7 +282,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void synchDb(String tableName)
|
public void synchDb(String tableName)
|
||||||
{
|
{
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
@@ -304,8 +304,17 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
column.setColumnId(prevColumn.getColumnId());
|
column.setColumnId(prevColumn.getColumnId());
|
||||||
if (column.isList())
|
if (column.isList())
|
||||||
{
|
{
|
||||||
// 如果是列表,继续保留字典类型
|
// 如果是列表,继续保留查询方式/字典类型选项
|
||||||
column.setDictType(prevColumn.getDictType());
|
column.setDictType(prevColumn.getDictType());
|
||||||
|
column.setQueryType(prevColumn.getQueryType());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
|
||||||
|
&& (column.isInsert() || column.isEdit())
|
||||||
|
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
|
||||||
|
{
|
||||||
|
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
|
||||||
|
column.setIsRequired(prevColumn.getIsRequired());
|
||||||
|
column.setHtmlType(prevColumn.getHtmlType());
|
||||||
}
|
}
|
||||||
genTableColumnMapper.updateGenTableColumn(column);
|
genTableColumnMapper.updateGenTableColumn(column);
|
||||||
}
|
}
|
||||||
@@ -392,7 +401,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
|
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
|
||||||
{
|
{
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSON.parseObject(options);
|
||||||
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
|
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
|
||||||
{
|
{
|
||||||
throw new ServiceException("树编码字段不能为空");
|
throw new ServiceException("树编码字段不能为空");
|
||||||
@@ -476,7 +485,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
*/
|
*/
|
||||||
public void setTableFromOptions(GenTable genTable)
|
public void setTableFromOptions(GenTable genTable)
|
||||||
{
|
{
|
||||||
JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
|
JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
|
||||||
if (StringUtils.isNotNull(paramsObj))
|
if (StringUtils.isNotNull(paramsObj))
|
||||||
{
|
{
|
||||||
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class GenUtils
|
|||||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||||
// 设置默认类型
|
// 设置默认类型
|
||||||
column.setJavaType(GenConstants.TYPE_STRING);
|
column.setJavaType(GenConstants.TYPE_STRING);
|
||||||
|
column.setQueryType(GenConstants.QUERY_EQ);
|
||||||
|
|
||||||
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
||||||
{
|
{
|
||||||
@@ -151,8 +152,7 @@ public class GenUtils
|
|||||||
{
|
{
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
int lastIndex = packageName.lastIndexOf(".");
|
||||||
int nameLength = packageName.length();
|
int nameLength = packageName.length();
|
||||||
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||||
return moduleName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,8 +165,7 @@ public class GenUtils
|
|||||||
{
|
{
|
||||||
int lastIndex = tableName.lastIndexOf("_");
|
int lastIndex = tableName.lastIndexOf("_");
|
||||||
int nameLength = tableName.length();
|
int nameLength = tableName.length();
|
||||||
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||||
return businessName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,4 +254,4 @@ public class GenUtils
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
@@ -75,7 +76,7 @@ public class VelocityUtils
|
|||||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
||||||
{
|
{
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSON.parseObject(options);
|
||||||
String parentMenuId = getParentMenuId(paramsObj);
|
String parentMenuId = getParentMenuId(paramsObj);
|
||||||
context.put("parentMenuId", parentMenuId);
|
context.put("parentMenuId", parentMenuId);
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,7 @@ public class VelocityUtils
|
|||||||
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
|
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
|
||||||
{
|
{
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSON.parseObject(options);
|
||||||
String treeCode = getTreecode(paramsObj);
|
String treeCode = getTreecode(paramsObj);
|
||||||
String treeParentCode = getTreeParentCode(paramsObj);
|
String treeParentCode = getTreeParentCode(paramsObj);
|
||||||
String treeName = getTreeName(paramsObj);
|
String treeName = getTreeName(paramsObj);
|
||||||
@@ -228,8 +229,7 @@ public class VelocityUtils
|
|||||||
public static String getPackagePrefix(String packageName)
|
public static String getPackagePrefix(String packageName)
|
||||||
{
|
{
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
int lastIndex = packageName.lastIndexOf(".");
|
||||||
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
return StringUtils.substring(packageName, 0, lastIndex);
|
||||||
return basePackage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,6 +272,23 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
List<GenTableColumn> columns = genTable.getColumns();
|
List<GenTableColumn> columns = genTable.getColumns();
|
||||||
Set<String> dicts = new HashSet<String>();
|
Set<String> dicts = new HashSet<String>();
|
||||||
|
addDicts(dicts, columns);
|
||||||
|
if (StringUtils.isNotNull(genTable.getSubTable()))
|
||||||
|
{
|
||||||
|
List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();
|
||||||
|
addDicts(dicts, subColumns);
|
||||||
|
}
|
||||||
|
return StringUtils.join(dicts, ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加字典列表
|
||||||
|
*
|
||||||
|
* @param dicts 字典列表
|
||||||
|
* @param columns 列集合
|
||||||
|
*/
|
||||||
|
public static void addDicts(Set<String> dicts, List<GenTableColumn> columns)
|
||||||
|
{
|
||||||
for (GenTableColumn column : columns)
|
for (GenTableColumn column : columns)
|
||||||
{
|
{
|
||||||
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
||||||
@@ -281,7 +298,6 @@ public class VelocityUtils
|
|||||||
dicts.add("'" + column.getDictType() + "'");
|
dicts.add("'" + column.getDictType() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.join(dicts, ", ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,7 +382,7 @@ public class VelocityUtils
|
|||||||
public static int getExpandColumn(GenTable genTable)
|
public static int getExpandColumn(GenTable genTable)
|
||||||
{
|
{
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSON.parseObject(options);
|
||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (GenTableColumn column : genTable.getColumns())
|
for (GenTableColumn column : genTable.getColumns())
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
#set($dictType=$column.dictType)
|
#set($dictType=$column.dictType)
|
||||||
@@ -17,13 +17,12 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
placeholder="请输入${comment}"
|
placeholder="请输入${comment}"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
@@ -34,13 +33,13 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
@@ -51,7 +50,6 @@
|
|||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="daterange${AttrName}"
|
v-model="daterange${AttrName}"
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
@@ -80,14 +78,24 @@
|
|||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
icon="el-icon-sort"
|
||||||
|
size="mini"
|
||||||
|
@click="toggleExpandAll"
|
||||||
|
>展开/折叠</el-button>
|
||||||
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
|
v-if="refreshTable"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="${businessName}List"
|
:data="${businessName}List"
|
||||||
row-key="${treeCode}"
|
row-key="${treeCode}"
|
||||||
default-expand-all
|
:default-expand-all="isExpandAll"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
>
|
>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
@@ -244,7 +252,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
@@ -295,6 +303,10 @@ export default {
|
|||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
|
// 是否展开,默认全部展开
|
||||||
|
isExpandAll: true,
|
||||||
|
// 重新渲染表格状态
|
||||||
|
refreshTable: true,
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
@@ -425,6 +437,14 @@ export default {
|
|||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加${functionName}";
|
this.title = "添加${functionName}";
|
||||||
},
|
},
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
toggleExpandAll() {
|
||||||
|
this.refreshTable = false;
|
||||||
|
this.isExpandAll = !this.isExpandAll;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.refreshTable = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
#set($dictType=$column.dictType)
|
#set($dictType=$column.dictType)
|
||||||
@@ -17,13 +17,12 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
placeholder="请输入${comment}"
|
placeholder="请输入${comment}"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
@@ -34,24 +33,23 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择${comment}">
|
placeholder="请选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="daterange${AttrName}"
|
v-model="daterange${AttrName}"
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
@@ -265,11 +263,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择${comment}">
|
placeholder="请选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "textarea")
|
#elseif($column.htmlType == "textarea")
|
||||||
@@ -302,12 +300,39 @@
|
|||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||||
#elseif($column.list && "" != $javaField)
|
#elseif($column.list && $column.htmlType == "input")
|
||||||
<el-table-column label="$comment" prop="${javaField}">
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="240">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd" placeholder="请选择$comment" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.$column.dictType"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|||||||
@@ -76,14 +76,23 @@
|
|||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
icon="Sort"
|
||||||
|
@click="toggleExpandAll"
|
||||||
|
>展开/折叠</el-button>
|
||||||
|
</el-col>
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
|
v-if="refreshTable"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="${businessName}List"
|
:data="${businessName}List"
|
||||||
row-key="${treeCode}"
|
row-key="${treeCode}"
|
||||||
default-expand-all
|
:default-expand-all="isExpandAll"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
>
|
>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
@@ -165,11 +174,13 @@
|
|||||||
#set($dictType=$column.dictType)
|
#set($dictType=$column.dictType)
|
||||||
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||||
<el-form-item label="${comment}" prop="${treeParentCode}">
|
<el-form-item label="${comment}" prop="${treeParentCode}">
|
||||||
<tree-select
|
<el-tree-select
|
||||||
v-model:value="form.${treeParentCode}"
|
v-model="form.${treeParentCode}"
|
||||||
:options="${businessName}Options"
|
:data="${businessName}Options"
|
||||||
:objMap="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
|
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
|
||||||
|
value-key="${treeCode}"
|
||||||
placeholder="请选择${comment}"
|
placeholder="请选择${comment}"
|
||||||
|
check-strictly
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "input")
|
#elseif($column.htmlType == "input")
|
||||||
@@ -283,6 +294,8 @@ const open = ref(false);
|
|||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const showSearch = ref(true);
|
const showSearch = ref(true);
|
||||||
const title = ref("");
|
const title = ref("");
|
||||||
|
const isExpandAll = ref(true);
|
||||||
|
const refreshTable = ref(true);
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
@@ -343,8 +356,8 @@ function getList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 查询${functionName}下拉树结构 */
|
/** 查询${functionName}下拉树结构 */
|
||||||
async function getTreeselect() {
|
function getTreeselect() {
|
||||||
await list${BusinessName}().then(response => {
|
list${BusinessName}().then(response => {
|
||||||
${businessName}Options.value = [];
|
${businessName}Options.value = [];
|
||||||
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
||||||
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
||||||
@@ -393,9 +406,9 @@ function resetQuery() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
async function handleAdd(row) {
|
function handleAdd(row) {
|
||||||
reset();
|
reset();
|
||||||
await getTreeselect();
|
getTreeselect();
|
||||||
if (row != null && row.${treeCode}) {
|
if (row != null && row.${treeCode}) {
|
||||||
form.value.${treeParentCode} = row.${treeCode};
|
form.value.${treeParentCode} = row.${treeCode};
|
||||||
} else {
|
} else {
|
||||||
@@ -405,6 +418,15 @@ async function handleAdd(row) {
|
|||||||
title.value = "添加${functionName}";
|
title.value = "添加${functionName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
function toggleExpandAll() {
|
||||||
|
refreshTable.value = false;
|
||||||
|
isExpandAll.value = !isExpandAll.value;
|
||||||
|
nextTick(() => {
|
||||||
|
refreshTable.value = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
async function handleUpdate(row) {
|
async function handleUpdate(row) {
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
placeholder="选择${comment}">
|
placeholder="请选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
placeholder="选择${comment}">
|
placeholder="请选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "textarea")
|
#elseif($column.htmlType == "textarea")
|
||||||
@@ -293,12 +293,44 @@
|
|||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||||
#elseif($column.list && "" != $javaField)
|
#elseif($column.list && $column.htmlType == "input")
|
||||||
<el-table-column label="$comment" prop="${javaField}">
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="240">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="scope.row.$javaField"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择$comment">
|
||||||
|
</el-date-picker>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in $column.dictType"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.ruoyi.common.core.constant.Constants;
|
|||||||
import com.ruoyi.common.core.constant.ScheduleConstants;
|
import com.ruoyi.common.core.constant.ScheduleConstants;
|
||||||
import com.ruoyi.common.core.exception.job.TaskException;
|
import com.ruoyi.common.core.exception.job.TaskException;
|
||||||
import com.ruoyi.common.core.exception.job.TaskException.Code;
|
import com.ruoyi.common.core.exception.job.TaskException.Code;
|
||||||
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.job.domain.SysJob;
|
import com.ruoyi.job.domain.SysJob;
|
||||||
|
|
||||||
@@ -125,11 +126,9 @@ public class ScheduleUtils
|
|||||||
int count = StringUtils.countMatches(packageName, ".");
|
int count = StringUtils.countMatches(packageName, ".");
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
{
|
{
|
||||||
if (!StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR))
|
return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
Object obj = SpringUtils.getBean(StringUtils.split(invokeTarget, ".")[0]);
|
||||||
|
return StringUtils.containsAnyIgnoreCase(obj.getClass().getPackage().getName(), Constants.JOB_WHITELIST_STR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -126,16 +126,17 @@ public class SysDeptController extends BaseController
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||||
{
|
{
|
||||||
|
Long deptId = dept.getDeptId();
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
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() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
else if (dept.getParentId().equals(deptId))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
}
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
||||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
|
||||||
{
|
{
|
||||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
@@ -159,6 +160,7 @@ public class SysDeptController extends BaseController
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("部门存在用户,不允许删除");
|
return AjaxResult.error("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.Arrays;
|
||||||
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;
|
||||||
@@ -13,6 +13,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
||||||
|
import com.ruoyi.common.core.utils.file.MimeTypeUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
@@ -126,11 +128,16 @@ public class SysProfileController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/avatar")
|
@PostMapping("/avatar")
|
||||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file)
|
||||||
{
|
{
|
||||||
if (!file.isEmpty())
|
if (!file.isEmpty())
|
||||||
{
|
{
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
String extension = FileTypeUtils.getExtension(file);
|
||||||
|
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION))
|
||||||
|
{
|
||||||
|
return AjaxResult.error("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
|
||||||
|
}
|
||||||
R<SysFile> fileResult = remoteFileService.upload(file);
|
R<SysFile> fileResult = remoteFileService.upload(file);
|
||||||
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData()))
|
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData()))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class SysRoleController extends BaseController
|
|||||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
@@ -123,6 +124,7 @@ public class SysRoleController extends BaseController
|
|||||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
return toAjax(roleService.authDataScope(role));
|
return toAjax(roleService.authDataScope(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +137,7 @@ public class SysRoleController extends BaseController
|
|||||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
role.setUpdateBy(SecurityUtils.getUsername());
|
role.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
}
|
}
|
||||||
@@ -213,6 +216,7 @@ public class SysRoleController extends BaseController
|
|||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
||||||
{
|
{
|
||||||
|
roleService.checkRoleDataScope(roleId);
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,6 +223,7 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
@@ -261,6 +262,7 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(userService.resetPwd(user));
|
return toAjax(userService.resetPwd(user));
|
||||||
@@ -275,6 +277,7 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
}
|
}
|
||||||
@@ -302,6 +305,7 @@ public class SysUserController extends BaseController
|
|||||||
@PutMapping("/authRole")
|
@PutMapping("/authRole")
|
||||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||||
{
|
{
|
||||||
|
userService.checkUserDataScope(userId);
|
||||||
userService.insertUserAuth(userId, roleIds);
|
userService.insertUserAuth(userId, roleIds);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import com.ruoyi.system.api.domain.SysDictType;
|
import com.ruoyi.system.api.domain.SysDictType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9,7 +8,6 @@ import com.ruoyi.system.api.domain.SysDictType;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Mapper
|
|
||||||
public interface SysDictTypeMapper
|
public interface SysDictTypeMapper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public interface SysUserMapper
|
|||||||
public List<SysUser> selectUserList(SysUser sysUser);
|
public List<SysUser> selectUserList(SysUser sysUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询未已配用户角色列表
|
* 根据条件分页查询已配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ public interface ISysConfigService
|
|||||||
* 批量删除参数信息
|
* 批量删除参数信息
|
||||||
*
|
*
|
||||||
* @param configIds 需要删除的参数ID
|
* @param configIds 需要删除的参数ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
public void deleteConfigByIds(Long[] configIds);
|
public void deleteConfigByIds(Long[] configIds);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public interface ISysDictDataService
|
|||||||
* 批量删除字典数据信息
|
* 批量删除字典数据信息
|
||||||
*
|
*
|
||||||
* @param dictCodes 需要删除的字典数据ID
|
* @param dictCodes 需要删除的字典数据ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
public void deleteDictDataByIds(Long[] dictCodes);
|
public void deleteDictDataByIds(Long[] dictCodes);
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ public interface ISysDictTypeService
|
|||||||
* 批量删除字典信息
|
* 批量删除字典信息
|
||||||
*
|
*
|
||||||
* @param dictIds 需要删除的字典ID
|
* @param dictIds 需要删除的字典ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
public void deleteDictTypeByIds(Long[] dictIds);
|
public void deleteDictTypeByIds(Long[] dictIds);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public interface ISysLogininforService
|
|||||||
* 批量删除系统登录日志
|
* 批量删除系统登录日志
|
||||||
*
|
*
|
||||||
* @param infoIds 需要删除的登录日志ID
|
* @param infoIds 需要删除的登录日志ID
|
||||||
* @return
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteLogininforByIds(Long[] infoIds);
|
public int deleteLogininforByIds(Long[] infoIds);
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public interface ISysPostService
|
|||||||
*
|
*
|
||||||
* @param postIds 需要删除的岗位ID
|
* @param postIds 需要删除的岗位ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws Exception 异常
|
|
||||||
*/
|
*/
|
||||||
public int deletePostByIds(Long[] postIds);
|
public int deletePostByIds(Long[] postIds);
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user