Compare commits
No commits in common. "master" and "v3.6.0" have entirely different histories.
|
|
@ -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.6.3</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.6.3-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>
|
||||||
|
|
||||||
|
|
@ -39,7 +39,6 @@ com.ruoyi
|
||||||
│ └── ruoyi-common-datasource // 多数据源
|
│ └── ruoyi-common-datasource // 多数据源
|
||||||
│ └── ruoyi-common-log // 日志记录
|
│ └── ruoyi-common-log // 日志记录
|
||||||
│ └── ruoyi-common-redis // 缓存服务
|
│ └── ruoyi-common-redis // 缓存服务
|
||||||
│ └── ruoyi-common-seata // 分布式事务
|
|
||||||
│ └── ruoyi-common-security // 安全模块
|
│ └── ruoyi-common-security // 安全模块
|
||||||
│ └── ruoyi-common-swagger // 系统接口
|
│ └── ruoyi-common-swagger // 系统接口
|
||||||
├── ruoyi-modules // 业务模块
|
├── ruoyi-modules // 业务模块
|
||||||
|
|
@ -128,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) [](https://jq.qq.com/?_wv=1027&k=nw3OiyXs) [](https://jq.qq.com/?_wv=1027&k=kiU5WDls) [](https://jq.qq.com/?_wv=1027&k=MtBy6YfT) [](https://jq.qq.com/?_wv=1027&k=FqImHgH2) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=G4jZ4EtdT50PhnMBudTnEwgonxkXOscJ&authKey=FkGHYfoTKlGE6wHdKdjH9bVoOgQjtLP9WM%2Fj7pqGY1msoqw9uxDiBo39E2mLgzYg&noverify=0&group_code=128355254) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=irnwcXhbLOQEv1g-TwGifjNTA_f4wZiA&authKey=4bpzEwhcUY%2FvsPDHvzYn6xfoS%2FtOArvZ%2BGXzfr7O0%2FEqLfkKA%2BuCDXlzHIFg8t93&noverify=0&group_code=179219821) 点击按钮入群。
|
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) 点击按钮入群。
|
||||||
|
|
@ -9,8 +9,8 @@ usage() {
|
||||||
|
|
||||||
# copy sql
|
# copy sql
|
||||||
echo "begin copy sql "
|
echo "begin copy sql "
|
||||||
cp ../sql/ry_20230706.sql ./mysql/db
|
cp ../sql/ry_20210908.sql ./mysql/db
|
||||||
cp ../sql/ry_config_20220929.sql ./mysql/db
|
cp ../sql/ry_config_20220114.sql ./mysql/db
|
||||||
|
|
||||||
# copy html
|
# copy html
|
||||||
echo "begin copy html "
|
echo "begin copy html "
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ management.metrics.export.influx.enabled=false
|
||||||
server.tomcat.accesslog.enabled=true
|
server.tomcat.accesslog.enabled=true
|
||||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
|
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
|
||||||
|
|
||||||
server.tomcat.basedir=/home/ruoyi/nacos/tomcat/logs
|
server.tomcat.basedir=
|
||||||
|
|
||||||
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,28 +14,23 @@ http {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /home/ruoyi/projects/ruoyi-ui;
|
root /home/ruoyi/projects/ruoyi-ui;
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /prod-api/{
|
location /prod-api/{
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host $http_host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header REMOTE-HOST $remote_addr;
|
proxy_set_header REMOTE-HOST $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_pass http://ruoyi-gateway:8080/;
|
proxy_pass http://ruoyi-gateway:8080/;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 避免actuator暴露
|
|
||||||
if ($request_uri ~ "/actuator") {
|
|
||||||
return 403;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
error_page 500 502 503 504 /50x.html;
|
||||||
location = /50x.html {
|
location = /50x.html {
|
||||||
root html;
|
root html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}# requirepass 123456
|
||||||
91
pom.xml
91
pom.xml
|
|
@ -6,35 +6,40 @@
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.3</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.6.3</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.7.18</spring-boot.version>
|
<spring-boot.version>2.7.1</spring-boot.version>
|
||||||
<spring-cloud.version>2021.0.8</spring-cloud.version>
|
<spring-cloud.version>2021.0.3</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2021.0.1.0</spring-cloud-alibaba.version>
|
||||||
<spring-boot-admin.version>2.7.11</spring-boot-admin.version>
|
<alibaba.nacos.version>2.0.4</alibaba.nacos.version>
|
||||||
|
<alibaba.seata.version>1.5.1</alibaba.seata.version>
|
||||||
|
<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.3</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<pagehelper.boot.version>2.0.0</pagehelper.boot.version>
|
<pagehelper.boot.version>1.4.3</pagehelper.boot.version>
|
||||||
<druid.version>1.2.20</druid.version>
|
<druid.version>1.2.11</druid.version>
|
||||||
<dynamic-ds.version>4.2.0</dynamic-ds.version>
|
<dynamic-ds.version>3.5.1</dynamic-ds.version>
|
||||||
<commons.io.version>2.13.0</commons.io.version>
|
<commons.io.version>2.11.0</commons.io.version>
|
||||||
|
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<fastjson.version>2.0.43</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>
|
||||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
<commons-collections.version>3.2.2</commons-collections.version>
|
||||||
|
<transmittable-thread-local.version>2.13.2</transmittable-thread-local.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
|
|
@ -59,6 +64,20 @@
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Alibaba Nacos 配置 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
|
<artifactId>nacos-client</artifactId>
|
||||||
|
<version>${alibaba.nacos.version}</version>
|
||||||
|
</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>
|
||||||
|
|
@ -75,6 +94,13 @@
|
||||||
<version>${tobato.version}</version>
|
<version>${tobato.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mybatis 依赖配置 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${spring-boot.mybatis}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger 依赖配置 -->
|
<!-- Swagger 依赖配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
|
|
@ -89,7 +115,7 @@
|
||||||
|
|
||||||
<!-- 验证码 -->
|
<!-- 验证码 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pro.fessional</groupId>
|
<groupId>com.github.penggle</groupId>
|
||||||
<artifactId>kaptcha</artifactId>
|
<artifactId>kaptcha</artifactId>
|
||||||
<version>${kaptcha.version}</version>
|
<version>${kaptcha.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
@ -115,6 +141,13 @@
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 文件上传工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>${commons.fileupload.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 代码生成使用模板 -->
|
<!-- 代码生成使用模板 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
|
@ -122,6 +155,13 @@
|
||||||
<version>${velocity.version}</version>
|
<version>${velocity.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Collection 增强Java集合框架 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
<version>${commons-collections.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- JSON 解析器和生成器 -->
|
<!-- JSON 解析器和生成器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
|
@ -178,13 +218,6 @@
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 分布式事务 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common-seata</artifactId>
|
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 日志记录 -->
|
<!-- 日志记录 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
|
|
@ -239,22 +272,6 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.3</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.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public interface RemoteLogService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/operlog")
|
@PostMapping("/operlog")
|
||||||
public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
|
public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存访问记录
|
* 保存访问记录
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ public class SysDictData extends BaseEntity
|
||||||
|
|
||||||
public boolean getDefault()
|
public boolean getDefault()
|
||||||
{
|
{
|
||||||
return UserConstants.YES.equals(this.isDefault);
|
return UserConstants.YES.equals(this.isDefault) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsDefault()
|
public String getIsDefault()
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,6 @@ public class SysOperLog extends BaseEntity
|
||||||
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date operTime;
|
private Date operTime;
|
||||||
|
|
||||||
/** 消耗时间 */
|
|
||||||
@Excel(name = "消耗时间", suffix = "毫秒")
|
|
||||||
private Long costTime;
|
|
||||||
|
|
||||||
public Long getOperId()
|
public Long getOperId()
|
||||||
{
|
{
|
||||||
return operId;
|
return operId;
|
||||||
|
|
@ -242,14 +238,4 @@ public class SysOperLog extends BaseEntity
|
||||||
{
|
{
|
||||||
this.operTime = operTime;
|
this.operTime = operTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCostTime()
|
|
||||||
{
|
|
||||||
return costTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCostTime(Long costTime)
|
|
||||||
{
|
|
||||||
this.costTime = costTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
@ -33,7 +31,7 @@ public class SysRole extends BaseEntity
|
||||||
|
|
||||||
/** 角色排序 */
|
/** 角色排序 */
|
||||||
@Excel(name = "角色排序")
|
@Excel(name = "角色排序")
|
||||||
private Integer roleSort;
|
private String roleSort;
|
||||||
|
|
||||||
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */
|
/** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */
|
||||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
||||||
|
|
@ -61,9 +59,6 @@ public class SysRole extends BaseEntity
|
||||||
/** 部门组(数据权限) */
|
/** 部门组(数据权限) */
|
||||||
private Long[] deptIds;
|
private Long[] deptIds;
|
||||||
|
|
||||||
/** 角色菜单权限 */
|
|
||||||
private Set<String> permissions;
|
|
||||||
|
|
||||||
public SysRole()
|
public SysRole()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -118,13 +113,13 @@ public class SysRole extends BaseEntity
|
||||||
this.roleKey = roleKey;
|
this.roleKey = roleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
public Integer getRoleSort()
|
public String getRoleSort()
|
||||||
{
|
{
|
||||||
return roleSort;
|
return roleSort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleSort(Integer roleSort)
|
public void setRoleSort(String roleSort)
|
||||||
{
|
{
|
||||||
this.roleSort = roleSort;
|
this.roleSort = roleSort;
|
||||||
}
|
}
|
||||||
|
|
@ -209,16 +204,6 @@ public class SysRole extends BaseEntity
|
||||||
this.deptIds = deptIds;
|
this.deptIds = deptIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPermissions()
|
|
||||||
{
|
|
||||||
return permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPermissions(Set<String> permissions)
|
|
||||||
{
|
|
||||||
this.permissions = permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,13 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveLog(SysOperLog sysOperLog, String source)
|
public R<Boolean> saveLog(SysOperLog sysOperLog, String source)
|
||||||
{
|
{
|
||||||
return R.fail("保存操作日志失败:" + throwable.getMessage());
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
|
public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
|
||||||
{
|
{
|
||||||
return R.fail("保存登录日志失败:" + throwable.getMessage());
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,19 @@ package com.ruoyi.auth.service;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
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.enums.UserStatus;
|
import com.ruoyi.common.core.enums.UserStatus;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
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.redis.service.RedisService;
|
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.system.api.RemoteLogService;
|
||||||
import com.ruoyi.system.api.RemoteUserService;
|
import com.ruoyi.system.api.RemoteUserService;
|
||||||
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
|
||||||
|
|
@ -26,18 +26,12 @@ import com.ruoyi.system.api.model.LoginUser;
|
||||||
@Component
|
@Component
|
||||||
public class SysLoginService
|
public class SysLoginService
|
||||||
{
|
{
|
||||||
|
@Autowired
|
||||||
|
private RemoteLogService remoteLogService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteUserService remoteUserService;
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPasswordService passwordService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysRecordLogService recordLogService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
|
|
@ -46,64 +40,60 @@ public class SysLoginService
|
||||||
// 用户名或密码为空 错误
|
// 用户名或密码为空 错误
|
||||||
if (StringUtils.isAnyBlank(username, password))
|
if (StringUtils.isAnyBlank(username, password))
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||||
throw new ServiceException("用户/密码必须填写");
|
throw new ServiceException("用户/密码必须填写");
|
||||||
}
|
}
|
||||||
// 密码如果不在指定范围内 错误
|
// 密码如果不在指定范围内 错误
|
||||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||||
throw new ServiceException("用户密码不在指定范围");
|
throw new ServiceException("用户密码不在指定范围");
|
||||||
}
|
}
|
||||||
// 用户名不在指定范围内 错误
|
// 用户名不在指定范围内 错误
|
||||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||||
throw new ServiceException("用户名不在指定范围");
|
throw new ServiceException("用户名不在指定范围");
|
||||||
}
|
}
|
||||||
// IP黑名单校验
|
|
||||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
|
||||||
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
|
|
||||||
{
|
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单");
|
|
||||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
|
||||||
}
|
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
|
||||||
{
|
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R.FAIL == userResult.getCode())
|
if (R.FAIL == userResult.getCode())
|
||||||
{
|
{
|
||||||
throw new ServiceException(userResult.getMsg());
|
throw new ServiceException(userResult.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
||||||
|
{
|
||||||
|
recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
|
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||||
|
}
|
||||||
LoginUser userInfo = userResult.getData();
|
LoginUser userInfo = userResult.getData();
|
||||||
SysUser user = userResult.getData().getSysUser();
|
SysUser user = userResult.getData().getSysUser();
|
||||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||||
}
|
}
|
||||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||||
}
|
}
|
||||||
passwordService.validate(user, password);
|
if (!SecurityUtils.matchesPassword(password, user.getPassword()))
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
{
|
||||||
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误");
|
||||||
|
throw new ServiceException("用户不存在/密码错误");
|
||||||
|
}
|
||||||
|
recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logout(String loginName)
|
public void logout(String loginName)
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -138,6 +128,32 @@ public class SysLoginService
|
||||||
{
|
{
|
||||||
throw new ServiceException(registerResult.getMsg());
|
throw new ServiceException(registerResult.getMsg());
|
||||||
}
|
}
|
||||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 记录登录信息
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param status 状态
|
||||||
|
* @param message 消息内容
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void recordLogininfor(String username, String status, String message)
|
||||||
|
{
|
||||||
|
SysLogininfor logininfor = new SysLogininfor();
|
||||||
|
logininfor.setUserName(username);
|
||||||
|
logininfor.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
||||||
|
logininfor.setMsg(message);
|
||||||
|
// 日志状态
|
||||||
|
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
|
||||||
|
{
|
||||||
|
logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
|
||||||
|
}
|
||||||
|
else if (Constants.LOGIN_FAIL.equals(status))
|
||||||
|
{
|
||||||
|
logininfor.setStatus(Constants.LOGIN_FAIL_STATUS);
|
||||||
|
}
|
||||||
|
remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
package com.ruoyi.auth.service;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录密码方法
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class SysPasswordService
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
|
||||||
|
|
||||||
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysRecordLogService recordLogService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录账户密码错误次数缓存键名
|
|
||||||
*
|
|
||||||
* @param username 用户名
|
|
||||||
* @return 缓存键key
|
|
||||||
*/
|
|
||||||
private String getCacheKey(String username)
|
|
||||||
{
|
|
||||||
return CacheConstants.PWD_ERR_CNT_KEY + username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validate(SysUser user, String password)
|
|
||||||
{
|
|
||||||
String username = user.getUserName();
|
|
||||||
|
|
||||||
Integer retryCount = redisService.getCacheObject(getCacheKey(username));
|
|
||||||
|
|
||||||
if (retryCount == null)
|
|
||||||
{
|
|
||||||
retryCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
|
|
||||||
{
|
|
||||||
String errMsg = String.format("密码输入错误%s次,帐户锁定%s分钟", maxRetryCount, lockTime);
|
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL,errMsg);
|
|
||||||
throw new ServiceException(errMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matches(user, password))
|
|
||||||
{
|
|
||||||
retryCount = retryCount + 1;
|
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, String.format("密码输入错误%s次", retryCount));
|
|
||||||
redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
|
|
||||||
throw new ServiceException("用户不存在/密码错误");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
clearLoginRecordCache(username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean matches(SysUser user, String rawPassword)
|
|
||||||
{
|
|
||||||
return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearLoginRecordCache(String loginName)
|
|
||||||
{
|
|
||||||
if (redisService.hasKey(getCacheKey(loginName)))
|
|
||||||
{
|
|
||||||
redisService.deleteObject(getCacheKey(loginName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
package com.ruoyi.auth.service;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
||||||
import com.ruoyi.system.api.RemoteLogService;
|
|
||||||
import com.ruoyi.system.api.domain.SysLogininfor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 记录日志方法
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class SysRecordLogService
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private RemoteLogService remoteLogService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 记录登录信息
|
|
||||||
*
|
|
||||||
* @param username 用户名
|
|
||||||
* @param status 状态
|
|
||||||
* @param message 消息内容
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void recordLogininfor(String username, String status, String message)
|
|
||||||
{
|
|
||||||
SysLogininfor logininfor = new SysLogininfor();
|
|
||||||
logininfor.setUserName(username);
|
|
||||||
logininfor.setIpaddr(IpUtils.getIpAddr());
|
|
||||||
logininfor.setMsg(message);
|
|
||||||
// 日志状态
|
|
||||||
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
|
|
||||||
{
|
|
||||||
logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
|
|
||||||
}
|
|
||||||
else if (Constants.LOGIN_FAIL.equals(status))
|
|
||||||
{
|
|
||||||
logininfor.setStatus(Constants.LOGIN_FAIL_STATUS);
|
|
||||||
}
|
|
||||||
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.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -12,18 +12,17 @@
|
||||||
<module>ruoyi-common-log</module>
|
<module>ruoyi-common-log</module>
|
||||||
<module>ruoyi-common-core</module>
|
<module>ruoyi-common-core</module>
|
||||||
<module>ruoyi-common-redis</module>
|
<module>ruoyi-common-redis</module>
|
||||||
<module>ruoyi-common-seata</module>
|
|
||||||
<module>ruoyi-common-swagger</module>
|
<module>ruoyi-common-swagger</module>
|
||||||
<module>ruoyi-common-security</module>
|
<module>ruoyi-common-security</module>
|
||||||
<module>ruoyi-common-datascope</module>
|
<module>ruoyi-common-datascope</module>
|
||||||
<module>ruoyi-common-datasource</module>
|
<module>ruoyi-common-datasource</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common通用模块
|
ruoyi-common通用模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -95,6 +95,12 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Commons Fileupload -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<!-- excel工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,12 @@ public @interface Excel
|
||||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度
|
* 导出时在excel中每个列的高度 单位为字符
|
||||||
*/
|
*/
|
||||||
public double height() default 14;
|
public double height() default 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的宽度
|
* 导出时在excel中每个列的宽 单位为字符
|
||||||
*/
|
*/
|
||||||
public double width() default 16;
|
public double width() default 16;
|
||||||
|
|
||||||
|
|
@ -83,11 +83,6 @@ public @interface Excel
|
||||||
*/
|
*/
|
||||||
public String[] combo() default {};
|
public String[] combo() default {};
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
|
||||||
*/
|
|
||||||
public boolean needMerge() default false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||||
*/
|
*/
|
||||||
|
|
@ -109,22 +104,7 @@ public @interface Excel
|
||||||
public ColumnType cellType() default ColumnType.STRING;
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出列头背景颜色
|
* 导出字体颜色
|
||||||
*/
|
|
||||||
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出列头字体颜色
|
|
||||||
*/
|
|
||||||
public IndexedColors headerColor() default IndexedColors.WHITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出单元格背景颜色
|
|
||||||
*/
|
|
||||||
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出单元格字体颜色
|
|
||||||
*/
|
*/
|
||||||
public IndexedColors color() default IndexedColors.BLACK;
|
public IndexedColors color() default IndexedColors.BLACK;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.ruoyi.common.core.constant;
|
package com.ruoyi.common.core.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存常量信息
|
* 缓存的key 常量
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
|
@ -17,43 +17,8 @@ public class CacheConstants
|
||||||
*/
|
*/
|
||||||
public final static long REFRESH_TIME = 120;
|
public final static long REFRESH_TIME = 120;
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码最大错误次数
|
|
||||||
*/
|
|
||||||
public final static int PASSWORD_MAX_RETRY_COUNT = 5;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码锁定时间,默认10(分钟)
|
|
||||||
*/
|
|
||||||
public final static long PASSWORD_LOCK_TIME = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限缓存前缀
|
* 权限缓存前缀
|
||||||
*/
|
*/
|
||||||
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码 redis key
|
|
||||||
*/
|
|
||||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数管理 cache key
|
|
||||||
*/
|
|
||||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典管理 cache key
|
|
||||||
*/
|
|
||||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录账户密码错误次数 redis key
|
|
||||||
*/
|
|
||||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录IP黑名单 cache key
|
|
||||||
*/
|
|
||||||
public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,6 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String GBK = "GBK";
|
public static final String GBK = "GBK";
|
||||||
|
|
||||||
/**
|
|
||||||
* www主域
|
|
||||||
*/
|
|
||||||
public static final String WWW = "www.";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RMI 远程方法调用
|
* RMI 远程方法调用
|
||||||
*/
|
*/
|
||||||
|
|
@ -107,21 +102,32 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String IS_ASC = "isAsc";
|
public static final String IS_ASC = "isAsc";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码 redis key
|
||||||
|
*/
|
||||||
|
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码有效期(分钟)
|
* 验证码有效期(分钟)
|
||||||
*/
|
*/
|
||||||
public static final long CAPTCHA_EXPIRATION = 2;
|
public static final long CAPTCHA_EXPIRATION = 2;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数管理 cache key
|
||||||
|
*/
|
||||||
|
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典管理 cache key
|
||||||
|
*/
|
||||||
|
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
public static final String RESOURCE_PREFIX = "/profile";
|
public static final String RESOURCE_PREFIX = "/profile";
|
||||||
|
|
||||||
/**
|
|
||||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
|
||||||
*/
|
|
||||||
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,4 @@ public class HttpStatus
|
||||||
* 接口未实现
|
* 接口未实现
|
||||||
*/
|
*/
|
||||||
public static final int NOT_IMPLEMENTED = 501;
|
public static final int NOT_IMPLEMENTED = 501;
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统警告消息
|
|
||||||
*/
|
|
||||||
public static final int WARN = 601;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,4 @@ public class SecurityConstants
|
||||||
* 登录用户
|
* 登录用户
|
||||||
*/
|
*/
|
||||||
public static final String LOGIN_USER = "login_user";
|
public static final String LOGIN_USER = "login_user";
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色权限
|
|
||||||
*/
|
|
||||||
public static final String ROLE_PERMISSION = "role_permission";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,10 @@ public class UserConstants
|
||||||
/** InnerLink组件标识 */
|
/** InnerLink组件标识 */
|
||||||
public final static String INNER_LINK = "InnerLink";
|
public final static String INNER_LINK = "InnerLink";
|
||||||
|
|
||||||
/** 校验是否唯一的返回标识 */
|
/** 校验返回结果码 */
|
||||||
public final static boolean UNIQUE = true;
|
public final static String UNIQUE = "0";
|
||||||
public final static boolean NOT_UNIQUE = false;
|
|
||||||
|
public final static String NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名长度限制
|
* 用户名长度限制
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,6 @@ public class SecurityContextHolder
|
||||||
set(SecurityConstants.USER_KEY, userKey);
|
set(SecurityConstants.USER_KEY, userKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPermission()
|
|
||||||
{
|
|
||||||
return get(SecurityConstants.ROLE_PERMISSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPermission(String permissions)
|
|
||||||
{
|
|
||||||
set(SecurityConstants.ROLE_PERMISSION, permissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void remove()
|
public static void remove()
|
||||||
{
|
{
|
||||||
THREAD_LOCAL.remove();
|
THREAD_LOCAL.remove();
|
||||||
|
|
|
||||||
|
|
@ -102,14 +102,4 @@ public class R<T> implements Serializable
|
||||||
{
|
{
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Boolean isError(R<T> ret)
|
|
||||||
{
|
|
||||||
return !isSuccess(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Boolean isSuccess(R<T> ret)
|
|
||||||
{
|
|
||||||
return R.SUCCESS == ret.getCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ package com.ruoyi.common.core.exception;
|
||||||
*/
|
*/
|
||||||
public class GlobalException extends RuntimeException
|
public class GlobalException extends RuntimeException
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +45,6 @@ public class GlobalException extends RuntimeException
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
return message;
|
return message;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ public final class ServiceException extends RuntimeException
|
||||||
return detailMessage;
|
return detailMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
return message;
|
return message;
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ public class FileException extends BaseException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public FileException(String code, Object[] args, String msg)
|
public FileException(String code, Object[] args)
|
||||||
{
|
{
|
||||||
super("file", code, args, msg);
|
super("file", code, args, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@ public class FileNameLengthLimitExceededException extends FileException
|
||||||
|
|
||||||
public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
||||||
{
|
{
|
||||||
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }, "the filename is too long");
|
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@ public class FileSizeLimitExceededException extends FileException
|
||||||
|
|
||||||
public FileSizeLimitExceededException(long defaultMaxSize)
|
public FileSizeLimitExceededException(long defaultMaxSize)
|
||||||
{
|
{
|
||||||
super("upload.exceed.maxSize", new Object[] { defaultMaxSize }, "the filesize is too large");
|
super("upload.exceed.maxSize", new Object[] { defaultMaxSize });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
package com.ruoyi.common.core.exception.file;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传异常类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class FileUploadException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final Throwable cause;
|
|
||||||
|
|
||||||
public FileUploadException()
|
|
||||||
{
|
|
||||||
this(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileUploadException(final String msg)
|
|
||||||
{
|
|
||||||
this(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileUploadException(String msg, Throwable cause)
|
|
||||||
{
|
|
||||||
super(msg);
|
|
||||||
this.cause = cause;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void printStackTrace(PrintStream stream)
|
|
||||||
{
|
|
||||||
super.printStackTrace(stream);
|
|
||||||
if (cause != null)
|
|
||||||
{
|
|
||||||
stream.println("Caused by:");
|
|
||||||
cause.printStackTrace(stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void printStackTrace(PrintWriter writer)
|
|
||||||
{
|
|
||||||
super.printStackTrace(writer);
|
|
||||||
if (cause != null)
|
|
||||||
{
|
|
||||||
writer.println("Caused by:");
|
|
||||||
cause.printStackTrace(writer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Throwable getCause()
|
|
||||||
{
|
|
||||||
return cause;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.common.core.exception.file;
|
package com.ruoyi.common.core.exception.file;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import org.apache.commons.fileupload.FileUploadException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传 误异常类
|
* 文件上传 误异常类
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.ruoyi.common.core.text;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
@ -314,7 +313,7 @@ public class Convert
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param split 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Integer[] toIntArray(String split, String str)
|
public static Integer[] toIntArray(String split, String str)
|
||||||
|
|
@ -371,7 +370,7 @@ public class Convert
|
||||||
* 转换为String数组<br>
|
* 转换为String数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param split 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String[] toStrArray(String split, String str)
|
public static String[] toStrArray(String split, String str)
|
||||||
|
|
@ -713,7 +712,7 @@ public class Convert
|
||||||
}
|
}
|
||||||
if (value instanceof Double)
|
if (value instanceof Double)
|
||||||
{
|
{
|
||||||
return BigDecimal.valueOf((Double) value);
|
return new BigDecimal((Double) value);
|
||||||
}
|
}
|
||||||
if (value instanceof Integer)
|
if (value instanceof Integer)
|
||||||
{
|
{
|
||||||
|
|
@ -963,7 +962,9 @@ public class Convert
|
||||||
c[i] = (char) (c[i] - 65248);
|
c[i] = (char) (c[i] - 65248);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new String(c);
|
String returnString = new String(c);
|
||||||
|
|
||||||
|
return returnString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -984,12 +985,7 @@ public class Convert
|
||||||
String s = "";
|
String s = "";
|
||||||
for (int i = 0; i < fraction.length; i++)
|
for (int i = 0; i < fraction.length; i++)
|
||||||
{
|
{
|
||||||
// 优化double计算精度丢失问题
|
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||||
BigDecimal nNum = new BigDecimal(n);
|
|
||||||
BigDecimal decimal = new BigDecimal(10);
|
|
||||||
BigDecimal scale = nNum.multiply(decimal).setScale(2, RoundingMode.HALF_EVEN);
|
|
||||||
double d = scale.doubleValue();
|
|
||||||
s += (digit[(int) (Math.floor(d * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
|
||||||
}
|
}
|
||||||
if (s.length() < 1)
|
if (s.length() < 1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -137,20 +137,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算时间差
|
* 计算两个时间差
|
||||||
*
|
|
||||||
* @param endDate 最后时间
|
|
||||||
* @param startTime 开始时间
|
|
||||||
* @return 时间差(天/小时/分钟)
|
|
||||||
*/
|
*/
|
||||||
public static String timeDistance(Date endDate, Date startTime)
|
public static String getDatePoor(Date endDate, Date nowDate)
|
||||||
{
|
{
|
||||||
long nd = 1000 * 24 * 60 * 60;
|
long nd = 1000 * 24 * 60 * 60;
|
||||||
long nh = 1000 * 60 * 60;
|
long nh = 1000 * 60 * 60;
|
||||||
long nm = 1000 * 60;
|
long nm = 1000 * 60;
|
||||||
// long ns = 1000;
|
// long ns = 1000;
|
||||||
// 获得两个时间的毫秒时间差异
|
// 获得两个时间的毫秒时间差异
|
||||||
long diff = endDate.getTime() - startTime.getTime();
|
long diff = endDate.getTime() - nowDate.getTime();
|
||||||
// 计算差多少天
|
// 计算差多少天
|
||||||
long day = diff / nd;
|
long day = diff / nd;
|
||||||
// 计算差多少小时
|
// 计算差多少小时
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,8 @@ import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.ServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
@ -82,34 +79,6 @@ public class ServletUtils
|
||||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得所有请求参数
|
|
||||||
*
|
|
||||||
* @param request 请求对象{@link ServletRequest}
|
|
||||||
* @return Map
|
|
||||||
*/
|
|
||||||
public static Map<String, String[]> getParams(ServletRequest request)
|
|
||||||
{
|
|
||||||
final Map<String, String[]> map = request.getParameterMap();
|
|
||||||
return Collections.unmodifiableMap(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得所有请求参数
|
|
||||||
*
|
|
||||||
* @param request 请求对象{@link ServletRequest}
|
|
||||||
* @return Map
|
|
||||||
*/
|
|
||||||
public static Map<String, String> getParamMap(ServletRequest request)
|
|
||||||
{
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet())
|
|
||||||
{
|
|
||||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -294,32 +294,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
|
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断给定的collection列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value
|
|
||||||
*
|
|
||||||
* @param collection 给定的集合
|
|
||||||
* @param array 给定的数组
|
|
||||||
* @return boolean 结果
|
|
||||||
*/
|
|
||||||
public static boolean containsAny(Collection<String> collection, String... array)
|
|
||||||
{
|
|
||||||
if (isEmpty(collection) || isEmpty(array))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (String str : array)
|
|
||||||
{
|
|
||||||
if (collection.contains(str))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驼峰转下划线命名
|
* 驼峰转下划线命名
|
||||||
*/
|
*/
|
||||||
|
|
@ -428,8 +402,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驼峰式命名法
|
* 驼峰式命名法 例如:user_name->userName
|
||||||
* 例如:user_name->userName
|
|
||||||
*/
|
*/
|
||||||
public static String toCamelCase(String s)
|
public static String toCamelCase(String s)
|
||||||
{
|
{
|
||||||
|
|
@ -437,10 +410,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (s.indexOf(SEPARATOR) == -1)
|
|
||||||
{
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
StringBuilder sb = new StringBuilder(s.length());
|
StringBuilder sb = new StringBuilder(s.length());
|
||||||
boolean upperCase = false;
|
boolean upperCase = false;
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,8 @@ public class FileUtils
|
||||||
// 路径为文件且不为空则进行删除
|
// 路径为文件且不为空则进行删除
|
||||||
if (file.isFile() && file.exists())
|
if (file.isFile() && file.exists())
|
||||||
{
|
{
|
||||||
flag = file.delete();
|
file.delete();
|
||||||
|
flag = true;
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
@ -126,8 +127,15 @@ public class FileUtils
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 判断是否在允许下载的文件规则内
|
|
||||||
return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource));
|
// 检查允许下载的文件规则
|
||||||
|
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不在允许下载的文件规则
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ public final class HTMLFilter
|
||||||
final String name = m.group(1).toLowerCase();
|
final String name = m.group(1).toLowerCase();
|
||||||
if (allowed(name))
|
if (allowed(name))
|
||||||
{
|
{
|
||||||
if (!inArray(name, vSelfClosingTags))
|
if (false == inArray(name, vSelfClosingTags))
|
||||||
{
|
{
|
||||||
if (vTagCounts.containsKey(name))
|
if (vTagCounts.containsKey(name))
|
||||||
{
|
{
|
||||||
|
|
@ -387,7 +387,7 @@ public final class HTMLFilter
|
||||||
{
|
{
|
||||||
paramValue = processParamProtocol(paramValue);
|
paramValue = processParamProtocol(paramValue);
|
||||||
}
|
}
|
||||||
params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\\\"");
|
params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.ruoyi.common.core.utils.ip;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -13,23 +12,6 @@ import com.ruoyi.common.core.utils.StringUtils;
|
||||||
*/
|
*/
|
||||||
public class IpUtils
|
public class IpUtils
|
||||||
{
|
{
|
||||||
public final static String REGX_0_255 = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)";
|
|
||||||
// 匹配 ip
|
|
||||||
public final static String REGX_IP = "((" + REGX_0_255 + "\\.){3}" + REGX_0_255 + ")";
|
|
||||||
public final static String REGX_IP_WILDCARD = "(((\\*\\.){3}\\*)|(" + REGX_0_255 + "(\\.\\*){3})|(" + REGX_0_255 + "\\." + REGX_0_255 + ")(\\.\\*){2}" + "|((" + REGX_0_255 + "\\.){3}\\*))";
|
|
||||||
// 匹配网段
|
|
||||||
public final static String REGX_IP_SEG = "(" + REGX_IP + "\\-" + REGX_IP + ")";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取客户端IP
|
|
||||||
*
|
|
||||||
* @return IP地址
|
|
||||||
*/
|
|
||||||
public static String getIpAddr()
|
|
||||||
{
|
|
||||||
return getIpAddr(ServletUtils.getRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客户端IP
|
* 获取客户端IP
|
||||||
*
|
*
|
||||||
|
|
@ -266,7 +248,7 @@ public class IpUtils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.substring(ip, 0, 255);
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -279,104 +261,4 @@ public class IpUtils
|
||||||
{
|
{
|
||||||
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为IP
|
|
||||||
*/
|
|
||||||
public static boolean isIP(String ip)
|
|
||||||
{
|
|
||||||
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为IP,或 *为间隔的通配符地址
|
|
||||||
*/
|
|
||||||
public static boolean isIpWildCard(String ip)
|
|
||||||
{
|
|
||||||
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP_WILDCARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检测参数是否在ip通配符里
|
|
||||||
*/
|
|
||||||
public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip)
|
|
||||||
{
|
|
||||||
String[] s1 = ipWildCard.split("\\.");
|
|
||||||
String[] s2 = ip.split("\\.");
|
|
||||||
boolean isMatchedSeg = true;
|
|
||||||
for (int i = 0; i < s1.length && !s1[i].equals("*"); i++)
|
|
||||||
{
|
|
||||||
if (!s1[i].equals(s2[i]))
|
|
||||||
{
|
|
||||||
isMatchedSeg = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isMatchedSeg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为特定格式如:“10.10.10.1-10.10.10.99”的ip段字符串
|
|
||||||
*/
|
|
||||||
public static boolean isIPSegment(String ipSeg)
|
|
||||||
{
|
|
||||||
return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断ip是否在指定网段中
|
|
||||||
*/
|
|
||||||
public static boolean ipIsInNetNoCheck(String iparea, String ip)
|
|
||||||
{
|
|
||||||
int idx = iparea.indexOf('-');
|
|
||||||
String[] sips = iparea.substring(0, idx).split("\\.");
|
|
||||||
String[] sipe = iparea.substring(idx + 1).split("\\.");
|
|
||||||
String[] sipt = ip.split("\\.");
|
|
||||||
long ips = 0L, ipe = 0L, ipt = 0L;
|
|
||||||
for (int i = 0; i < 4; ++i)
|
|
||||||
{
|
|
||||||
ips = ips << 8 | Integer.parseInt(sips[i]);
|
|
||||||
ipe = ipe << 8 | Integer.parseInt(sipe[i]);
|
|
||||||
ipt = ipt << 8 | Integer.parseInt(sipt[i]);
|
|
||||||
}
|
|
||||||
if (ips > ipe)
|
|
||||||
{
|
|
||||||
long t = ips;
|
|
||||||
ips = ipe;
|
|
||||||
ipe = t;
|
|
||||||
}
|
|
||||||
return ips <= ipt && ipt <= ipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验ip是否符合过滤串规则
|
|
||||||
*
|
|
||||||
* @param filter 过滤IP列表,支持后缀'*'通配,支持网段如:`10.10.10.1-10.10.10.99`
|
|
||||||
* @param ip 校验IP地址
|
|
||||||
* @return boolean 结果
|
|
||||||
*/
|
|
||||||
public static boolean isMatchedIp(String filter, String ip)
|
|
||||||
{
|
|
||||||
if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(ip))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String[] ips = filter.split(";");
|
|
||||||
for (String iStr : ips)
|
|
||||||
{
|
|
||||||
if (isIP(iStr) && iStr.equals(ip))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
package com.ruoyi.common.core.utils.poi;
|
package com.ruoyi.common.core.utils.poi;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel数据格式处理适配器
|
* Excel数据格式处理适配器
|
||||||
*
|
*
|
||||||
|
|
@ -15,10 +12,8 @@ public interface ExcelHandlerAdapter
|
||||||
*
|
*
|
||||||
* @param value 单元格数据值
|
* @param value 单元格数据值
|
||||||
* @param args excel注解args参数组
|
* @param args excel注解args参数组
|
||||||
* @param cell 单元格对象
|
|
||||||
* @param wb 工作簿对象
|
|
||||||
*
|
*
|
||||||
* @return 处理后的值
|
* @return 处理后的值
|
||||||
*/
|
*/
|
||||||
Object format(Object value, String[] args, Cell cell, Workbook wb);
|
Object format(Object value, String[] args);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,12 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -20,9 +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.ArrayUtils;
|
|
||||||
import org.apache.commons.lang3.RegExUtils;
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
|
||||||
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;
|
||||||
|
|
@ -37,7 +33,6 @@ import org.apache.poi.ss.usermodel.FillPatternType;
|
||||||
import org.apache.poi.ss.usermodel.Font;
|
import org.apache.poi.ss.usermodel.Font;
|
||||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
import org.apache.poi.ss.usermodel.Name;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||||
|
|
@ -55,7 +50,6 @@ 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;
|
||||||
import com.ruoyi.common.core.annotation.Excels;
|
import com.ruoyi.common.core.annotation.Excels;
|
||||||
import com.ruoyi.common.core.exception.UtilException;
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
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;
|
||||||
|
|
@ -131,26 +125,6 @@ public class ExcelUtil<T>
|
||||||
*/
|
*/
|
||||||
private short maxHeight;
|
private short maxHeight;
|
||||||
|
|
||||||
/**
|
|
||||||
* 合并后最后行数
|
|
||||||
*/
|
|
||||||
private int subMergedLastRowNum = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 合并后开始行数
|
|
||||||
*/
|
|
||||||
private int subMergedFirstRowNum = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对象的子列表方法
|
|
||||||
*/
|
|
||||||
private Method subMethod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对象的子列表属性
|
|
||||||
*/
|
|
||||||
private List<Field> subFields;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计列表
|
* 统计列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -166,27 +140,11 @@ public class ExcelUtil<T>
|
||||||
*/
|
*/
|
||||||
public Class<T> clazz;
|
public Class<T> clazz;
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要排除列属性
|
|
||||||
*/
|
|
||||||
public String[] excludeFields;
|
|
||||||
|
|
||||||
public ExcelUtil(Class<T> clazz)
|
public ExcelUtil(Class<T> clazz)
|
||||||
{
|
{
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 隐藏Excel中列属性
|
|
||||||
*
|
|
||||||
* @param fields 列属性名 示例[单个"name"/多个"id","name"]
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void hideColumn(String... fields)
|
|
||||||
{
|
|
||||||
this.excludeFields = fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(List<T> list, String sheetName, String title, Type type)
|
public void init(List<T> list, String sheetName, String title, Type type)
|
||||||
{
|
{
|
||||||
if (list == null)
|
if (list == null)
|
||||||
|
|
@ -200,7 +158,6 @@ public class ExcelUtil<T>
|
||||||
createExcelField();
|
createExcelField();
|
||||||
createWorkbook();
|
createWorkbook();
|
||||||
createTitle();
|
createTitle();
|
||||||
createSubHead();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -210,79 +167,30 @@ public class ExcelUtil<T>
|
||||||
{
|
{
|
||||||
if (StringUtils.isNotEmpty(title))
|
if (StringUtils.isNotEmpty(title))
|
||||||
{
|
{
|
||||||
subMergedFirstRowNum++;
|
|
||||||
subMergedLastRowNum++;
|
|
||||||
int titleLastCol = this.fields.size() - 1;
|
|
||||||
if (isSubList())
|
|
||||||
{
|
|
||||||
titleLastCol = titleLastCol + subFields.size() - 1;
|
|
||||||
}
|
|
||||||
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
|
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
|
||||||
titleRow.setHeightInPoints(30);
|
titleRow.setHeightInPoints(30);
|
||||||
Cell titleCell = titleRow.createCell(0);
|
Cell titleCell = titleRow.createCell(0);
|
||||||
titleCell.setCellStyle(styles.get("title"));
|
titleCell.setCellStyle(styles.get("title"));
|
||||||
titleCell.setCellValue(title);
|
titleCell.setCellValue(title);
|
||||||
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), titleLastCol));
|
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(),
|
||||||
}
|
this.fields.size() - 1));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建对象的子列表名称
|
|
||||||
*/
|
|
||||||
public void createSubHead()
|
|
||||||
{
|
|
||||||
if (isSubList())
|
|
||||||
{
|
|
||||||
subMergedFirstRowNum++;
|
|
||||||
subMergedLastRowNum++;
|
|
||||||
Row subRow = sheet.createRow(rownum);
|
|
||||||
int excelNum = 0;
|
|
||||||
for (Object[] objects : fields)
|
|
||||||
{
|
|
||||||
Excel attr = (Excel) objects[1];
|
|
||||||
Cell headCell1 = subRow.createCell(excelNum);
|
|
||||||
headCell1.setCellValue(attr.name());
|
|
||||||
headCell1.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
|
||||||
excelNum++;
|
|
||||||
}
|
|
||||||
int headFirstRow = excelNum - 1;
|
|
||||||
int headLastRow = headFirstRow + subFields.size() - 1;
|
|
||||||
if (headLastRow > headFirstRow)
|
|
||||||
{
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, headFirstRow, headLastRow));
|
|
||||||
}
|
|
||||||
rownum++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对excel表单默认第一个索引名转换成list
|
* 对excel表单默认第一个索引名转换成list
|
||||||
*
|
*
|
||||||
* @param is 输入流
|
* @param is 输入流
|
||||||
* @return 转换后集合
|
* @return 转换后集合
|
||||||
*/
|
*/
|
||||||
public List<T> importExcel(InputStream is)
|
public List<T> importExcel(InputStream is) throws Exception
|
||||||
{
|
{
|
||||||
List<T> list = null;
|
return importExcel(is, 0);
|
||||||
try
|
|
||||||
{
|
|
||||||
list = importExcel(is, 0);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.error("导入Excel异常{}", e.getMessage());
|
|
||||||
throw new UtilException(e.getMessage());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtils.closeQuietly(is);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对excel表单默认第一个索引名转换成list
|
* 对excel表单默认第一个索引名转换成list
|
||||||
*
|
*
|
||||||
* @param is 输入流
|
* @param is 输入流
|
||||||
* @param titleNum 标题占用行数
|
* @param titleNum 标题占用行数
|
||||||
* @return 转换后集合
|
* @return 转换后集合
|
||||||
|
|
@ -294,7 +202,7 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对excel表单指定表格索引名转换成list
|
* 对excel表单指定表格索引名转换成list
|
||||||
*
|
*
|
||||||
* @param sheetName 表格索引名
|
* @param sheetName 表格索引名
|
||||||
* @param titleNum 标题占用行数
|
* @param titleNum 标题占用行数
|
||||||
* @param is 输入流
|
* @param is 输入流
|
||||||
|
|
@ -314,6 +222,7 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
// 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1
|
// 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1
|
||||||
int rows = sheet.getLastRowNum();
|
int rows = sheet.getLastRowNum();
|
||||||
|
|
||||||
if (rows > 0)
|
if (rows > 0)
|
||||||
{
|
{
|
||||||
// 定义一个map用于存放excel列的序号和field.
|
// 定义一个map用于存放excel列的序号和field.
|
||||||
|
|
@ -428,13 +337,13 @@ public class ExcelUtil<T>
|
||||||
{
|
{
|
||||||
propertyName = field.getName() + "." + attr.targetAttr();
|
propertyName = field.getName() + "." + attr.targetAttr();
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
else if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
||||||
{
|
{
|
||||||
val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
|
val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
|
||||||
}
|
}
|
||||||
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
||||||
{
|
{
|
||||||
val = dataFormatHandlerAdapter(val, attr, null);
|
val = dataFormatHandlerAdapter(val, attr);
|
||||||
}
|
}
|
||||||
ReflectUtils.invokeSetter(entity, propertyName, val);
|
ReflectUtils.invokeSetter(entity, propertyName, val);
|
||||||
}
|
}
|
||||||
|
|
@ -452,6 +361,7 @@ public class ExcelUtil<T>
|
||||||
* @param list 导出数据集合
|
* @param list 导出数据集合
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)
|
||||||
{
|
{
|
||||||
|
|
@ -466,6 +376,7 @@ public class ExcelUtil<T>
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @param title 标题
|
* @param title 标题
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
||||||
{
|
{
|
||||||
|
|
@ -503,7 +414,7 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void exportExcel(HttpServletResponse response)
|
public void exportExcel(HttpServletResponse response)
|
||||||
|
|
@ -540,20 +451,8 @@ public class ExcelUtil<T>
|
||||||
// 写入各个字段的列头名称
|
// 写入各个字段的列头名称
|
||||||
for (Object[] os : fields)
|
for (Object[] os : fields)
|
||||||
{
|
{
|
||||||
Field field = (Field) os[0];
|
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
if (Collection.class.isAssignableFrom(field.getType()))
|
this.createCell(excel, row, column++);
|
||||||
{
|
|
||||||
for (Field subField : subFields)
|
|
||||||
{
|
|
||||||
Excel subExcel = subField.getAnnotation(Excel.class);
|
|
||||||
this.createHeadCell(subExcel, row, column++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.createHeadCell(excel, row, column++);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (Type.EXPORT.equals(type))
|
if (Type.EXPORT.equals(type))
|
||||||
{
|
{
|
||||||
|
|
@ -565,78 +464,32 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填充excel数据
|
* 填充excel数据
|
||||||
*
|
*
|
||||||
* @param index 序号
|
* @param index 序号
|
||||||
* @param row 单元格行
|
* @param row 单元格行
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void fillExcelData(int index, Row row)
|
public void fillExcelData(int index, Row row)
|
||||||
{
|
{
|
||||||
int startNo = index * sheetSize;
|
int startNo = index * sheetSize;
|
||||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
int endNo = Math.min(startNo + sheetSize, list.size());
|
||||||
int rowNo = (1 + rownum) - startNo;
|
|
||||||
for (int i = startNo; i < endNo; i++)
|
for (int i = startNo; i < endNo; i++)
|
||||||
{
|
{
|
||||||
rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo;
|
row = sheet.createRow(i + 1 + rownum - startNo);
|
||||||
row = sheet.createRow(rowNo);
|
|
||||||
// 得到导出对象.
|
// 得到导出对象.
|
||||||
T vo = (T) list.get(i);
|
T vo = (T) list.get(i);
|
||||||
Collection<?> subList = null;
|
|
||||||
if (isSubList())
|
|
||||||
{
|
|
||||||
if (isSubListValue(vo))
|
|
||||||
{
|
|
||||||
subList = getListCellValue(vo);
|
|
||||||
subMergedLastRowNum = subMergedLastRowNum + subList.size();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subMergedFirstRowNum++;
|
|
||||||
subMergedLastRowNum++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for (Object[] os : fields)
|
for (Object[] os : fields)
|
||||||
{
|
{
|
||||||
Field field = (Field) os[0];
|
Field field = (Field) os[0];
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
if (Collection.class.isAssignableFrom(field.getType()) && StringUtils.isNotNull(subList))
|
this.addCell(excel, row, vo, field, column++);
|
||||||
{
|
|
||||||
boolean subFirst = false;
|
|
||||||
for (Object obj : subList)
|
|
||||||
{
|
|
||||||
if (subFirst)
|
|
||||||
{
|
|
||||||
rowNo++;
|
|
||||||
row = sheet.createRow(rowNo);
|
|
||||||
}
|
|
||||||
List<Field> subFields = FieldUtils.getFieldsListWithAnnotation(obj.getClass(), Excel.class);
|
|
||||||
int subIndex = 0;
|
|
||||||
for (Field subField : subFields)
|
|
||||||
{
|
|
||||||
if (subField.isAnnotationPresent(Excel.class))
|
|
||||||
{
|
|
||||||
subField.setAccessible(true);
|
|
||||||
Excel attr = subField.getAnnotation(Excel.class);
|
|
||||||
this.addCell(attr, row, (T) obj, subField, column + subIndex);
|
|
||||||
}
|
|
||||||
subIndex++;
|
|
||||||
}
|
|
||||||
subFirst = true;
|
|
||||||
}
|
|
||||||
this.subMergedFirstRowNum = this.subMergedFirstRowNum + subList.size();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.addCell(excel, row, vo, field, column++);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建表格样式
|
* 创建表格样式
|
||||||
*
|
*
|
||||||
* @param wb 工作薄对象
|
* @param wb 工作薄对象
|
||||||
* @return 样式列表
|
* @return 样式列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -671,6 +524,20 @@ public class ExcelUtil<T>
|
||||||
style.setFont(dataFont);
|
style.setFont(dataFont);
|
||||||
styles.put("data", style);
|
styles.put("data", style);
|
||||||
|
|
||||||
|
style = wb.createCellStyle();
|
||||||
|
style.cloneStyleFrom(styles.get("data"));
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
|
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
Font headerFont = wb.createFont();
|
||||||
|
headerFont.setFontName("Arial");
|
||||||
|
headerFont.setFontHeightInPoints((short) 10);
|
||||||
|
headerFont.setBold(true);
|
||||||
|
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
||||||
|
style.setFont(headerFont);
|
||||||
|
styles.put("header", style);
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
style = wb.createCellStyle();
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
|
@ -680,62 +547,28 @@ public class ExcelUtil<T>
|
||||||
style.setFont(totalFont);
|
style.setFont(totalFont);
|
||||||
styles.put("total", style);
|
styles.put("total", style);
|
||||||
|
|
||||||
styles.putAll(annotationHeaderStyles(wb, styles));
|
styles.putAll(annotationStyles(wb));
|
||||||
|
|
||||||
styles.putAll(annotationDataStyles(wb));
|
|
||||||
|
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据Excel注解创建表格头样式
|
* 根据Excel注解创建表格样式
|
||||||
*
|
*
|
||||||
* @param wb 工作薄对象
|
* @param wb 工作薄对象
|
||||||
* @return 自定义样式列表
|
* @return 自定义样式列表
|
||||||
*/
|
*/
|
||||||
private Map<String, CellStyle> annotationHeaderStyles(Workbook wb, Map<String, CellStyle> styles)
|
private Map<String, CellStyle> annotationStyles(Workbook wb)
|
||||||
{
|
|
||||||
Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>();
|
|
||||||
for (Object[] os : fields)
|
|
||||||
{
|
|
||||||
Excel excel = (Excel) os[1];
|
|
||||||
String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
|
|
||||||
if (!headerStyles.containsKey(key))
|
|
||||||
{
|
|
||||||
CellStyle style = wb.createCellStyle();
|
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
style.setFillForegroundColor(excel.headerBackgroundColor().index);
|
|
||||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
Font headerFont = wb.createFont();
|
|
||||||
headerFont.setFontName("Arial");
|
|
||||||
headerFont.setFontHeightInPoints((short) 10);
|
|
||||||
headerFont.setBold(true);
|
|
||||||
headerFont.setColor(excel.headerColor().index);
|
|
||||||
style.setFont(headerFont);
|
|
||||||
headerStyles.put(key, style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return headerStyles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据Excel注解创建表格列样式
|
|
||||||
*
|
|
||||||
* @param wb 工作薄对象
|
|
||||||
* @return 自定义样式列表
|
|
||||||
*/
|
|
||||||
private Map<String, CellStyle> annotationDataStyles(Workbook wb)
|
|
||||||
{
|
{
|
||||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||||
for (Object[] os : fields)
|
for (Object[] os : fields)
|
||||||
{
|
{
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor());
|
String key = "data_" + excel.align() + "_" + excel.color();
|
||||||
if (!styles.containsKey(key))
|
if (!styles.containsKey(key))
|
||||||
{
|
{
|
||||||
CellStyle style = wb.createCellStyle();
|
CellStyle style = wb.createCellStyle();
|
||||||
|
style = wb.createCellStyle();
|
||||||
style.setAlignment(excel.align());
|
style.setAlignment(excel.align());
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
style.setBorderRight(BorderStyle.THIN);
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
|
@ -746,8 +579,6 @@ public class ExcelUtil<T>
|
||||||
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
style.setBorderBottom(BorderStyle.THIN);
|
style.setBorderBottom(BorderStyle.THIN);
|
||||||
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
style.setFillForegroundColor(excel.backgroundColor().getIndex());
|
|
||||||
Font dataFont = wb.createFont();
|
Font dataFont = wb.createFont();
|
||||||
dataFont.setFontName("Arial");
|
dataFont.setFontName("Arial");
|
||||||
dataFont.setFontHeightInPoints((short) 10);
|
dataFont.setFontHeightInPoints((short) 10);
|
||||||
|
|
@ -762,29 +593,20 @@ public class ExcelUtil<T>
|
||||||
/**
|
/**
|
||||||
* 创建单元格
|
* 创建单元格
|
||||||
*/
|
*/
|
||||||
public Cell createHeadCell(Excel attr, Row row, int column)
|
public Cell createCell(Excel attr, Row row, int column)
|
||||||
{
|
{
|
||||||
// 创建列
|
// 创建列
|
||||||
Cell cell = row.createCell(column);
|
Cell cell = row.createCell(column);
|
||||||
// 写入列信息
|
// 写入列信息
|
||||||
cell.setCellValue(attr.name());
|
cell.setCellValue(attr.name());
|
||||||
setDataValidation(attr, row, column);
|
setDataValidation(attr, row, column);
|
||||||
cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
cell.setCellStyle(styles.get("header"));
|
||||||
if (isSubList())
|
|
||||||
{
|
|
||||||
// 填充默认样式,防止合并单元格样式失效
|
|
||||||
sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor())));
|
|
||||||
if (attr.needMerge())
|
|
||||||
{
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rownum - 1, rownum, column, column));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置单元格信息
|
* 设置单元格信息
|
||||||
*
|
*
|
||||||
* @param value 单元格值
|
* @param value 单元格值
|
||||||
* @param attr 注解相关
|
* @param attr 注解相关
|
||||||
* @param cell 单元格信息
|
* @param cell 单元格信息
|
||||||
|
|
@ -799,10 +621,6 @@ public class ExcelUtil<T>
|
||||||
{
|
{
|
||||||
cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0");
|
cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0");
|
||||||
}
|
}
|
||||||
if (value instanceof Collection && StringUtils.equals("[]", cellValue))
|
|
||||||
{
|
|
||||||
cellValue = StringUtils.EMPTY;
|
|
||||||
}
|
|
||||||
cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix());
|
cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix());
|
||||||
}
|
}
|
||||||
else if (ColumnType.NUMERIC == attr.cellType())
|
else if (ColumnType.NUMERIC == attr.cellType())
|
||||||
|
|
@ -870,16 +688,8 @@ public class ExcelUtil<T>
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0)
|
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0)
|
||||||
{
|
{
|
||||||
if (attr.combo().length > 15 || StringUtils.join(attr.combo()).length() > 255)
|
// 提示信息或只能选择不能输入的列内容.
|
||||||
{
|
setPromptOrValidation(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
||||||
// 如果下拉数大于15或字符串长度大于255,则使用一个新sheet存储,避免生成的模板下拉值获取不到
|
|
||||||
setXSSFValidationWithHidden(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 提示信息或只能选择不能输入的列内容.
|
|
||||||
setPromptOrValidation(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -898,12 +708,7 @@ public class ExcelUtil<T>
|
||||||
{
|
{
|
||||||
// 创建cell
|
// 创建cell
|
||||||
cell = row.createCell(column);
|
cell = row.createCell(column);
|
||||||
if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge())
|
cell.setCellStyle(styles.get("data_" + attr.align() + "_" + attr.color()));
|
||||||
{
|
|
||||||
CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column);
|
|
||||||
sheet.addMergedRegion(cellAddress);
|
|
||||||
}
|
|
||||||
cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor())));
|
|
||||||
|
|
||||||
// 用于读取对象中的属性
|
// 用于读取对象中的属性
|
||||||
Object value = getTargetValue(vo, field, attr);
|
Object value = getTargetValue(vo, field, attr);
|
||||||
|
|
@ -920,11 +725,11 @@ public class ExcelUtil<T>
|
||||||
}
|
}
|
||||||
else if (value instanceof BigDecimal && -1 != attr.scale())
|
else if (value instanceof BigDecimal && -1 != attr.scale())
|
||||||
{
|
{
|
||||||
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue());
|
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
|
||||||
}
|
}
|
||||||
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
||||||
{
|
{
|
||||||
cell.setCellValue(dataFormatHandlerAdapter(value, attr, cell));
|
cell.setCellValue(dataFormatHandlerAdapter(value, attr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -978,58 +783,6 @@ public class ExcelUtil<T>
|
||||||
sheet.addValidationData(dataValidation);
|
sheet.addValidationData(dataValidation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框).
|
|
||||||
*
|
|
||||||
* @param sheet 要设置的sheet.
|
|
||||||
* @param textlist 下拉框显示的内容
|
|
||||||
* @param promptContent 提示内容
|
|
||||||
* @param firstRow 开始行
|
|
||||||
* @param endRow 结束行
|
|
||||||
* @param firstCol 开始列
|
|
||||||
* @param endCol 结束列
|
|
||||||
*/
|
|
||||||
public void setXSSFValidationWithHidden(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol)
|
|
||||||
{
|
|
||||||
String hideSheetName = "combo_" + firstCol + "_" + endCol;
|
|
||||||
Sheet hideSheet = wb.createSheet(hideSheetName); // 用于存储 下拉菜单数据
|
|
||||||
for (int i = 0; i < textlist.length; i++)
|
|
||||||
{
|
|
||||||
hideSheet.createRow(i).createCell(0).setCellValue(textlist[i]);
|
|
||||||
}
|
|
||||||
// 创建名称,可被其他单元格引用
|
|
||||||
Name name = wb.createName();
|
|
||||||
name.setNameName(hideSheetName + "_data");
|
|
||||||
name.setRefersToFormula(hideSheetName + "!$A$1:$A$" + textlist.length);
|
|
||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
|
||||||
// 加载下拉列表内容
|
|
||||||
DataValidationConstraint constraint = helper.createFormulaListConstraint(hideSheetName + "_data");
|
|
||||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
|
||||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
|
||||||
// 数据有效性对象
|
|
||||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
|
||||||
if (StringUtils.isNotEmpty(promptContent))
|
|
||||||
{
|
|
||||||
// 如果设置了提示信息则鼠标放上去提示
|
|
||||||
dataValidation.createPromptBox("", promptContent);
|
|
||||||
dataValidation.setShowPromptBox(true);
|
|
||||||
}
|
|
||||||
// 处理Excel兼容性问题
|
|
||||||
if (dataValidation instanceof XSSFDataValidation)
|
|
||||||
{
|
|
||||||
dataValidation.setSuppressDropDownArrow(true);
|
|
||||||
dataValidation.setShowErrorBox(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dataValidation.setSuppressDropDownArrow(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
sheet.addValidationData(dataValidation);
|
|
||||||
// 设置hiddenSheet隐藏
|
|
||||||
wb.setSheetHidden(wb.getSheetIndex(hideSheet), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析导出值 0=男,1=女,2=未知
|
* 解析导出值 0=男,1=女,2=未知
|
||||||
*
|
*
|
||||||
|
|
@ -1045,7 +798,7 @@ public class ExcelUtil<T>
|
||||||
for (String item : convertSource)
|
for (String item : convertSource)
|
||||||
{
|
{
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
if (StringUtils.containsAny(propertyValue, separator))
|
if (StringUtils.containsAny(separator, propertyValue))
|
||||||
{
|
{
|
||||||
for (String value : propertyValue.split(separator))
|
for (String value : propertyValue.split(separator))
|
||||||
{
|
{
|
||||||
|
|
@ -1069,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 分隔符
|
||||||
|
|
@ -1082,7 +835,7 @@ public class ExcelUtil<T>
|
||||||
for (String item : convertSource)
|
for (String item : convertSource)
|
||||||
{
|
{
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
if (StringUtils.containsAny(propertyValue, separator))
|
if (StringUtils.containsAny(separator, propertyValue))
|
||||||
{
|
{
|
||||||
for (String value : propertyValue.split(separator))
|
for (String value : propertyValue.split(separator))
|
||||||
{
|
{
|
||||||
|
|
@ -1111,13 +864,13 @@ public class ExcelUtil<T>
|
||||||
* @param excel 数据注解
|
* @param excel 数据注解
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String dataFormatHandlerAdapter(Object value, Excel excel, Cell cell)
|
public String dataFormatHandlerAdapter(Object value, Excel excel)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object instance = excel.handler().newInstance();
|
Object instance = excel.handler().newInstance();
|
||||||
Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class, Cell.class, Workbook.class });
|
Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class });
|
||||||
value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb);
|
value = formatMethod.invoke(instance, value, excel.args());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -1244,40 +997,29 @@ public class ExcelUtil<T>
|
||||||
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||||
for (Field field : tempFields)
|
for (Field field : tempFields)
|
||||||
{
|
{
|
||||||
if (!ArrayUtils.contains(this.excludeFields, field.getName()))
|
// 单注解
|
||||||
|
if (field.isAnnotationPresent(Excel.class))
|
||||||
{
|
{
|
||||||
// 单注解
|
Excel attr = field.getAnnotation(Excel.class);
|
||||||
if (field.isAnnotationPresent(Excel.class))
|
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
||||||
|
{
|
||||||
|
field.setAccessible(true);
|
||||||
|
fields.add(new Object[] { field, attr });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多注解
|
||||||
|
if (field.isAnnotationPresent(Excels.class))
|
||||||
|
{
|
||||||
|
Excels attrs = field.getAnnotation(Excels.class);
|
||||||
|
Excel[] excels = attrs.value();
|
||||||
|
for (Excel attr : excels)
|
||||||
{
|
{
|
||||||
Excel attr = field.getAnnotation(Excel.class);
|
|
||||||
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
||||||
{
|
{
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
fields.add(new Object[] { field, attr });
|
fields.add(new Object[] { field, attr });
|
||||||
}
|
}
|
||||||
if (Collection.class.isAssignableFrom(field.getType()))
|
|
||||||
{
|
|
||||||
subMethod = getSubMethod(field.getName(), clazz);
|
|
||||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
|
||||||
Class<?> subClass = (Class<?>) pt.getActualTypeArguments()[0];
|
|
||||||
this.subFields = FieldUtils.getFieldsListWithAnnotation(subClass, Excel.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多注解
|
|
||||||
if (field.isAnnotationPresent(Excels.class))
|
|
||||||
{
|
|
||||||
Excels attrs = field.getAnnotation(Excels.class);
|
|
||||||
Excel[] excels = attrs.value();
|
|
||||||
for (Excel attr : excels)
|
|
||||||
{
|
|
||||||
if (!ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr())
|
|
||||||
&& (attr != null && (attr.type() == Type.ALL || attr.type() == type)))
|
|
||||||
{
|
|
||||||
field.setAccessible(true);
|
|
||||||
fields.add(new Object[] { field, attr });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1311,7 +1053,7 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建工作表
|
* 创建工作表
|
||||||
*
|
*
|
||||||
* @param sheetNo sheet数量
|
* @param sheetNo sheet数量
|
||||||
* @param index 序号
|
* @param index 序号
|
||||||
*/
|
*/
|
||||||
|
|
@ -1328,7 +1070,7 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单元格值
|
* 获取单元格值
|
||||||
*
|
*
|
||||||
* @param row 获取的行
|
* @param row 获取的行
|
||||||
* @param column 获取单元格列号
|
* @param column 获取单元格列号
|
||||||
* @return 单元格值
|
* @return 单元格值
|
||||||
|
|
@ -1388,7 +1130,7 @@ public class ExcelUtil<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否是空行
|
* 判断是否是空行
|
||||||
*
|
*
|
||||||
* @param row 判断的行
|
* @param row 判断的行
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -1441,61 +1183,4 @@ public class ExcelUtil<T>
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否有对象的子列表
|
|
||||||
*/
|
|
||||||
public boolean isSubList()
|
|
||||||
{
|
|
||||||
return StringUtils.isNotNull(subFields) && subFields.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否有对象的子列表,集合不为空
|
|
||||||
*/
|
|
||||||
public boolean isSubListValue(T vo)
|
|
||||||
{
|
|
||||||
return StringUtils.isNotNull(subFields) && subFields.size() > 0 && StringUtils.isNotNull(getListCellValue(vo)) && getListCellValue(vo).size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取集合的值
|
|
||||||
*/
|
|
||||||
public Collection<?> getListCellValue(Object obj)
|
|
||||||
{
|
|
||||||
Object value;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
value = subMethod.invoke(obj, new Object[] {});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return new ArrayList<Object>();
|
|
||||||
}
|
|
||||||
return (Collection<?>) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象的子列表方法
|
|
||||||
*
|
|
||||||
* @param name 名称
|
|
||||||
* @param pojoClass 类对象
|
|
||||||
* @return 子列表方法
|
|
||||||
*/
|
|
||||||
public Method getSubMethod(String name, Class<?> pojoClass)
|
|
||||||
{
|
|
||||||
StringBuffer getMethodName = new StringBuffer("get");
|
|
||||||
getMethodName.append(name.substring(0, 1).toUpperCase());
|
|
||||||
getMethodName.append(name.substring(1));
|
|
||||||
Method method = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
method = pojoClass.getMethod(getMethodName.toString(), new Class[] {});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.error("获取对象异常{}", e.getMessage());
|
|
||||||
}
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,13 @@ public class SqlUtil
|
||||||
/**
|
/**
|
||||||
* 定义常用的 sql关键字
|
* 定义常用的 sql关键字
|
||||||
*/
|
*/
|
||||||
public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";
|
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
||||||
*/
|
*/
|
||||||
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
||||||
|
|
||||||
/**
|
|
||||||
* 限制orderBy最大长度
|
|
||||||
*/
|
|
||||||
private static final int ORDER_BY_MAX_LENGTH = 500;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查字符,防止注入绕过
|
* 检查字符,防止注入绕过
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,10 +29,6 @@ public class SqlUtil
|
||||||
{
|
{
|
||||||
throw new UtilException("参数不符合规范,不能进行查询");
|
throw new UtilException("参数不符合规范,不能进行查询");
|
||||||
}
|
}
|
||||||
if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH)
|
|
||||||
{
|
|
||||||
throw new UtilException("参数已超过最大限制,不能进行查询");
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class Seq
|
||||||
private static AtomicInteger uploadSeq = new AtomicInteger(1);
|
private static AtomicInteger uploadSeq = new AtomicInteger(1);
|
||||||
|
|
||||||
// 机器标识
|
// 机器标识
|
||||||
private static final String machineCode = "A";
|
private static String machineCode = "A";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通用序列号
|
* 获取通用序列号
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取类型 4(伪随机生成的)UUID 的静态工厂。
|
* 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。
|
||||||
*
|
*
|
||||||
* @return 随机生成的 {@code UUID}
|
* @return 随机生成的 {@code UUID}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -70,54 +70,6 @@ public class BaseController
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功
|
|
||||||
*/
|
|
||||||
public AjaxResult success()
|
|
||||||
{
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*/
|
|
||||||
public AjaxResult success(String message)
|
|
||||||
{
|
|
||||||
return AjaxResult.success(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*/
|
|
||||||
public AjaxResult success(Object data)
|
|
||||||
{
|
|
||||||
return AjaxResult.success(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回失败消息
|
|
||||||
*/
|
|
||||||
public AjaxResult error()
|
|
||||||
{
|
|
||||||
return AjaxResult.error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回失败消息
|
|
||||||
*/
|
|
||||||
public AjaxResult error(String message)
|
|
||||||
{
|
|
||||||
return AjaxResult.error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回警告消息
|
|
||||||
*/
|
|
||||||
public AjaxResult warn(String message)
|
|
||||||
{
|
|
||||||
return AjaxResult.warn(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应返回结果
|
* 响应返回结果
|
||||||
*
|
*
|
||||||
|
|
@ -139,4 +91,36 @@ public class BaseController
|
||||||
{
|
{
|
||||||
return result ? success() : error();
|
return result ? success() : error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public AjaxResult success()
|
||||||
|
{
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult error()
|
||||||
|
{
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*/
|
||||||
|
public AjaxResult success(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult error(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.common.core.web.domain;
|
package com.ruoyi.common.core.web.domain;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
|
||||||
import com.ruoyi.common.core.constant.HttpStatus;
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
|
|
@ -58,6 +57,20 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
super.put(DATA_TAG, data);
|
super.put(DATA_TAG, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方便链式调用
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult put(String key, Object value)
|
||||||
|
{
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
|
|
@ -102,33 +115,10 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回警告消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult warn(String msg)
|
|
||||||
{
|
|
||||||
return AjaxResult.warn(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回警告消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @param data 数据对象
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult warn(String msg, Object data)
|
|
||||||
{
|
|
||||||
return new AjaxResult(HttpStatus.WARN, msg, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @return 错误消息
|
* @return
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error()
|
public static AjaxResult error()
|
||||||
{
|
{
|
||||||
|
|
@ -139,7 +129,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 错误消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(String msg)
|
public static AjaxResult error(String msg)
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +141,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @param data 数据对象
|
* @param data 数据对象
|
||||||
* @return 错误消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(String msg, Object data)
|
public static AjaxResult error(String msg, Object data)
|
||||||
{
|
{
|
||||||
|
|
@ -163,54 +153,10 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
*
|
*
|
||||||
* @param code 状态码
|
* @param code 状态码
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 错误消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(int code, String msg)
|
public static AjaxResult error(int code, String msg)
|
||||||
{
|
{
|
||||||
return new AjaxResult(code, msg, null);
|
return new AjaxResult(code, msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为成功消息
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean isSuccess()
|
|
||||||
{
|
|
||||||
return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为警告消息
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean isWarn()
|
|
||||||
{
|
|
||||||
return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为错误消息
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean isError()
|
|
||||||
{
|
|
||||||
return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 方便链式调用
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AjaxResult put(String key, Object value)
|
|
||||||
{
|
|
||||||
super.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity基类
|
* Entity基类
|
||||||
|
|
@ -18,7 +16,6 @@ public class BaseEntity implements Serializable
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 搜索值 */
|
/** 搜索值 */
|
||||||
@JsonIgnore
|
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
/** 创建者 */
|
/** 创建者 */
|
||||||
|
|
@ -39,7 +36,6 @@ public class BaseEntity implements Serializable
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/** 请求参数 */
|
/** 请求参数 */
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
public String getSearchValue()
|
public String getSearchValue()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,4 @@ public @interface DataScope
|
||||||
* 用户表的别名
|
* 用户表的别名
|
||||||
*/
|
*/
|
||||||
public String userAlias() default "";
|
public String userAlias() default "";
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@RequiresPermissions获取,多个权限用逗号分隔开来
|
|
||||||
*/
|
|
||||||
public String permission() default "";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
package com.ruoyi.common.datascope.aspect;
|
package com.ruoyi.common.datascope.aspect;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.core.context.SecurityContextHolder;
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||||
|
|
@ -72,9 +68,8 @@ public class DataScopeAspect
|
||||||
// 如果是超级管理员,则不过滤数据
|
// 如果是超级管理员,则不过滤数据
|
||||||
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
|
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
|
||||||
{
|
{
|
||||||
String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission());
|
|
||||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||||
controllerDataScope.userAlias(), permission);
|
controllerDataScope.userAlias());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,29 +81,17 @@ public class DataScopeAspect
|
||||||
* @param user 用户
|
* @param user 用户
|
||||||
* @param deptAlias 部门别名
|
* @param deptAlias 部门别名
|
||||||
* @param userAlias 用户别名
|
* @param userAlias 用户别名
|
||||||
* @param permission 权限字符
|
|
||||||
*/
|
*/
|
||||||
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission)
|
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias)
|
||||||
{
|
{
|
||||||
StringBuilder sqlString = new StringBuilder();
|
StringBuilder sqlString = new StringBuilder();
|
||||||
List<String> conditions = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (SysRole role : user.getRoles())
|
for (SysRole role : user.getRoles())
|
||||||
{
|
{
|
||||||
String dataScope = role.getDataScope();
|
String dataScope = role.getDataScope();
|
||||||
if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(permission) && StringUtils.isNotEmpty(role.getPermissions())
|
|
||||||
&& !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (DATA_SCOPE_ALL.equals(dataScope))
|
if (DATA_SCOPE_ALL.equals(dataScope))
|
||||||
{
|
{
|
||||||
sqlString = new StringBuilder();
|
sqlString = new StringBuilder();
|
||||||
conditions.add(dataScope);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
|
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
|
||||||
|
|
@ -139,13 +122,6 @@ public class DataScopeAspect
|
||||||
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conditions.add(dataScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多角色情况下,所有角色都不包含传递过来的权限字符,这个时候sqlString也会为空,所以要限制一下,不查询任何数据
|
|
||||||
if (StringUtils.isEmpty(conditions))
|
|
||||||
{
|
|
||||||
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(sqlString.toString()))
|
if (StringUtils.isNotBlank(sqlString.toString()))
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,19 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>ruoyi-common-datasource</artifactId>
|
<artifactId>ruoyi-common-datasource</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
ruoyi-common-datasource多数据源
|
ruoyi-common-datasource多数据源
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Druid -->
|
<!-- Druid -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
|
@ -30,6 +30,12 @@
|
||||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||||
<version>${dynamic-ds.version}</version>
|
<version>${dynamic-ds.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Seata -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,4 @@ public @interface Log
|
||||||
* 是否保存响应的参数
|
* 是否保存响应的参数
|
||||||
*/
|
*/
|
||||||
public boolean isSaveResponseData() default true;
|
public boolean isSaveResponseData() default true;
|
||||||
|
|
||||||
/**
|
|
||||||
* 排除指定的请求参数
|
|
||||||
*/
|
|
||||||
public String[] excludeParamNames() default {};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,13 @@ import java.util.Collection;
|
||||||
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;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
import org.aspectj.lang.annotation.AfterThrowing;
|
import org.aspectj.lang.annotation.AfterThrowing;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.NamedThreadLocal;
|
|
||||||
import org.springframework.http.HttpMethod;
|
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;
|
||||||
|
|
@ -24,7 +21,6 @@ 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.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessStatus;
|
import com.ruoyi.common.log.enums.BusinessStatus;
|
||||||
import com.ruoyi.common.log.filter.PropertyPreExcludeFilter;
|
|
||||||
import com.ruoyi.common.log.service.AsyncLogService;
|
import com.ruoyi.common.log.service.AsyncLogService;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysOperLog;
|
import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
|
|
@ -39,25 +35,10 @@ import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
public class LogAspect
|
public class LogAspect
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
|
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
|
||||||
|
|
||||||
/** 排除敏感属性字段 */
|
|
||||||
public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
|
|
||||||
|
|
||||||
/** 计算操作消耗时间 */
|
|
||||||
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsyncLogService asyncLogService;
|
private AsyncLogService asyncLogService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理请求前执行
|
|
||||||
*/
|
|
||||||
@Before(value = "@annotation(controllerLog)")
|
|
||||||
public void boBefore(JoinPoint joinPoint, Log controllerLog)
|
|
||||||
{
|
|
||||||
TIME_THREADLOCAL.set(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理完请求后执行
|
* 处理完请求后执行
|
||||||
*
|
*
|
||||||
|
|
@ -89,9 +70,9 @@ public class LogAspect
|
||||||
SysOperLog operLog = new SysOperLog();
|
SysOperLog operLog = new SysOperLog();
|
||||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||||
// 请求的地址
|
// 请求的地址
|
||||||
String ip = IpUtils.getIpAddr();
|
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
||||||
operLog.setOperIp(ip);
|
operLog.setOperIp(ip);
|
||||||
operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
|
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
|
||||||
String username = SecurityUtils.getUsername();
|
String username = SecurityUtils.getUsername();
|
||||||
if (StringUtils.isNotBlank(username))
|
if (StringUtils.isNotBlank(username))
|
||||||
{
|
{
|
||||||
|
|
@ -111,21 +92,16 @@ public class LogAspect
|
||||||
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
||||||
// 处理设置注解上的参数
|
// 处理设置注解上的参数
|
||||||
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
||||||
// 设置消耗时间
|
|
||||||
operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
|
|
||||||
// 保存数据库
|
// 保存数据库
|
||||||
asyncLogService.saveSysLog(operLog);
|
asyncLogService.saveSysLog(operLog);
|
||||||
}
|
}
|
||||||
catch (Exception exp)
|
catch (Exception exp)
|
||||||
{
|
{
|
||||||
// 记录本地异常日志
|
// 记录本地异常日志
|
||||||
|
log.error("==前置通知异常==");
|
||||||
log.error("异常信息:{}", exp.getMessage());
|
log.error("异常信息:{}", exp.getMessage());
|
||||||
exp.printStackTrace();
|
exp.printStackTrace();
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
TIME_THREADLOCAL.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,7 +123,7 @@ public class LogAspect
|
||||||
if (log.isSaveRequestData())
|
if (log.isSaveRequestData())
|
||||||
{
|
{
|
||||||
// 获取参数的信息,传入到数据库中。
|
// 获取参数的信息,传入到数据库中。
|
||||||
setRequestValue(joinPoint, operLog, log.excludeParamNames());
|
setRequestValue(joinPoint, operLog);
|
||||||
}
|
}
|
||||||
// 是否需要保存response,参数和值
|
// 是否需要保存response,参数和值
|
||||||
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
|
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
|
||||||
|
|
@ -162,26 +138,20 @@ public class LogAspect
|
||||||
* @param operLog 操作日志
|
* @param operLog 操作日志
|
||||||
* @throws Exception 异常
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception
|
private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception
|
||||||
{
|
{
|
||||||
String requestMethod = operLog.getRequestMethod();
|
String requestMethod = operLog.getRequestMethod();
|
||||||
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
|
if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))
|
||||||
if (StringUtils.isEmpty(paramsMap)
|
|
||||||
&& (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)))
|
|
||||||
{
|
{
|
||||||
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
|
String params = argsArrayToString(joinPoint.getArgs());
|
||||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter(excludeParamNames)), 0, 2000));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数拼装
|
* 参数拼装
|
||||||
*/
|
*/
|
||||||
private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames)
|
private String argsArrayToString(Object[] paramsArray)
|
||||||
{
|
{
|
||||||
String params = "";
|
String params = "";
|
||||||
if (paramsArray != null && paramsArray.length > 0)
|
if (paramsArray != null && paramsArray.length > 0)
|
||||||
|
|
@ -192,7 +162,7 @@ public class LogAspect
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames));
|
Object jsonObj = JSON.toJSON(o);
|
||||||
params += jsonObj.toString() + " ";
|
params += jsonObj.toString() + " ";
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -204,14 +174,6 @@ public class LogAspect
|
||||||
return params.trim();
|
return params.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 忽略敏感属性
|
|
||||||
*/
|
|
||||||
public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames)
|
|
||||||
{
|
|
||||||
return new PropertyPreExcludeFilter().addExcludes(ArrayUtils.addAll(EXCLUDE_PROPERTIES, excludeParamNames));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否需要过滤的对象。
|
* 判断是否需要过滤的对象。
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package com.ruoyi.common.log.filter;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排除JSON敏感属性
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class PropertyPreExcludeFilter extends SimplePropertyPreFilter
|
|
||||||
{
|
|
||||||
public PropertyPreExcludeFilter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public PropertyPreExcludeFilter addExcludes(String... filters)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < filters.length; i++)
|
|
||||||
{
|
|
||||||
this.getExcludes().add(filters[i]);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class AsyncLogService
|
||||||
* 保存系统日志记录
|
* 保存系统日志记录
|
||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void saveSysLog(SysOperLog sysOperLog) throws Exception
|
public void saveSysLog(SysOperLog sysOperLog)
|
||||||
{
|
{
|
||||||
remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ import org.springframework.data.redis.serializer.SerializationException;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONReader;
|
import com.alibaba.fastjson2.JSONReader;
|
||||||
import com.alibaba.fastjson2.JSONWriter;
|
import com.alibaba.fastjson2.JSONWriter;
|
||||||
import com.alibaba.fastjson2.filter.Filter;
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis使用FastJson序列化
|
* Redis使用FastJson序列化
|
||||||
|
|
@ -18,10 +16,9 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
||||||
{
|
{
|
||||||
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||||
|
|
||||||
static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR);
|
|
||||||
|
|
||||||
private Class<T> clazz;
|
private Class<T> clazz;
|
||||||
|
|
||||||
|
|
||||||
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
@ -47,6 +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, AUTO_TYPE_FILTER);
|
return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,9 @@ public class RedisService
|
||||||
* @param collection 多个对象
|
* @param collection 多个对象
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final Collection collection)
|
public long deleteObject(final Collection collection)
|
||||||
{
|
{
|
||||||
return redisTemplate.delete(collection) > 0;
|
return redisTemplate.delete(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -243,21 +243,9 @@ public class RedisService
|
||||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除Hash中的某条数据
|
|
||||||
*
|
|
||||||
* @param key Redis键
|
|
||||||
* @param hKey Hash键
|
|
||||||
* @return 是否成功
|
|
||||||
*/
|
|
||||||
public boolean deleteCacheMapValue(final String key, final String hKey)
|
|
||||||
{
|
|
||||||
return redisTemplate.opsForHash().delete(key, hKey) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的基本对象列表
|
* 获得缓存的基本对象列表
|
||||||
*
|
*
|
||||||
* @param pattern 字符串前缀
|
* @param pattern 字符串前缀
|
||||||
* @return 对象列表
|
* @return 对象列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>ruoyi-common-seata</artifactId>
|
|
||||||
|
|
||||||
<description>
|
|
||||||
ruoyi-common-seata分布式事务
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<!-- SpringBoot Seata -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.springframework.util.PatternMatchUtils;
|
import org.springframework.util.PatternMatchUtils;
|
||||||
import com.ruoyi.common.core.context.SecurityContextHolder;
|
|
||||||
import com.ruoyi.common.core.exception.auth.NotLoginException;
|
import com.ruoyi.common.core.exception.auth.NotLoginException;
|
||||||
import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
||||||
import com.ruoyi.common.core.exception.auth.NotRoleException;
|
import com.ruoyi.common.core.exception.auth.NotRoleException;
|
||||||
|
|
@ -135,7 +134,6 @@ public class AuthLogic
|
||||||
*/
|
*/
|
||||||
public void checkPermi(RequiresPermissions requiresPermissions)
|
public void checkPermi(RequiresPermissions requiresPermissions)
|
||||||
{
|
{
|
||||||
SecurityContextHolder.setPermission(StringUtils.join(requiresPermissions.value(), ","));
|
|
||||||
if (requiresPermissions.logical() == Logical.AND)
|
if (requiresPermissions.logical() == Logical.AND)
|
||||||
{
|
{
|
||||||
checkPermiAnd(requiresPermissions.value());
|
checkPermiAnd(requiresPermissions.value());
|
||||||
|
|
@ -355,7 +353,7 @@ public class AuthLogic
|
||||||
public boolean hasPermi(Collection<String> authorities, String permission)
|
public boolean hasPermi(Collection<String> authorities, String permission)
|
||||||
{
|
{
|
||||||
return authorities.stream().filter(StringUtils::hasText)
|
return authorities.stream().filter(StringUtils::hasText)
|
||||||
.anyMatch(x -> ALL_PERMISSION.equals(x) || PatternMatchUtils.simpleMatch(x, permission));
|
.anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(x, permission));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -368,6 +366,6 @@ public class AuthLogic
|
||||||
public boolean hasRole(Collection<String> roles, String role)
|
public boolean hasRole(Collection<String> roles, String role)
|
||||||
{
|
{
|
||||||
return roles.stream().filter(StringUtils::hasText)
|
return roles.stream().filter(StringUtils::hasText)
|
||||||
.anyMatch(x -> SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role));
|
.anyMatch(x -> SUPER_ADMIN.contains(x) || PatternMatchUtils.simpleMatch(x, role));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class AuthUtil
|
||||||
/**
|
/**
|
||||||
* 会话注销,根据指定Token
|
* 会话注销,根据指定Token
|
||||||
*
|
*
|
||||||
* @param token 指定token
|
* @param tokenValue 指定token
|
||||||
*/
|
*/
|
||||||
public static void logoutByToken(String token)
|
public static void logoutByToken(String token)
|
||||||
{
|
{
|
||||||
|
|
@ -44,9 +44,6 @@ public class AuthUtil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前登录用户信息
|
* 获取当前登录用户信息
|
||||||
*
|
|
||||||
* @param token 指定token
|
|
||||||
* @return 用户信息
|
|
||||||
*/
|
*/
|
||||||
public static LoginUser getLoginUser(String token)
|
public static LoginUser getLoginUser(String token)
|
||||||
{
|
{
|
||||||
|
|
@ -55,8 +52,6 @@ public class AuthUtil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证当前用户有效期
|
* 验证当前用户有效期
|
||||||
*
|
|
||||||
* @param loginUser 用户信息
|
|
||||||
*/
|
*/
|
||||||
public static void verifyLoginUserExpire(LoginUser loginUser)
|
public static void verifyLoginUserExpire(LoginUser loginUser)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,6 @@ public class FeignRequestInterceptor implements RequestInterceptor
|
||||||
{
|
{
|
||||||
requestTemplate.header(SecurityConstants.DETAILS_USER_ID, userId);
|
requestTemplate.header(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
}
|
}
|
||||||
String userKey = headers.get(SecurityConstants.USER_KEY);
|
|
||||||
if (StringUtils.isNotEmpty(userKey))
|
|
||||||
{
|
|
||||||
requestTemplate.header(SecurityConstants.USER_KEY, userKey);
|
|
||||||
}
|
|
||||||
String userName = headers.get(SecurityConstants.DETAILS_USERNAME);
|
String userName = headers.get(SecurityConstants.DETAILS_USERNAME);
|
||||||
if (StringUtils.isNotEmpty(userName))
|
if (StringUtils.isNotEmpty(userName))
|
||||||
{
|
{
|
||||||
|
|
@ -48,7 +43,7 @@ public class FeignRequestInterceptor implements RequestInterceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置客户端IP
|
// 配置客户端IP
|
||||||
requestTemplate.header("X-Forwarded-For", IpUtils.getIpAddr());
|
requestTemplate.header("X-Forwarded-For", IpUtils.getIpAddr(ServletUtils.getRequest()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
package com.ruoyi.common.security.handler;
|
package com.ruoyi.common.security.handler;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.validation.BindException;
|
||||||
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
import com.ruoyi.common.core.constant.HttpStatus;
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.exception.DemoModeException;
|
import com.ruoyi.common.core.exception.DemoModeException;
|
||||||
import com.ruoyi.common.core.exception.InnerAuthException;
|
import com.ruoyi.common.core.exception.InnerAuthException;
|
||||||
|
|
@ -8,20 +16,10 @@ import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
||||||
import com.ruoyi.common.core.exception.auth.NotRoleException;
|
import com.ruoyi.common.core.exception.auth.NotRoleException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.validation.BindException;
|
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
||||||
import org.springframework.web.bind.MissingPathVariableException;
|
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
||||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局异常处理器
|
* 全局异常处理器
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
|
|
@ -55,7 +53,8 @@ public class GlobalExceptionHandler
|
||||||
* 请求方式不支持
|
* 请求方式不支持
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, HttpServletRequest request)
|
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||||
|
HttpServletRequest request)
|
||||||
{
|
{
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||||
|
|
@ -73,28 +72,6 @@ public class GlobalExceptionHandler
|
||||||
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求路径中缺少必需的路径变量
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(MissingPathVariableException.class)
|
|
||||||
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request)
|
|
||||||
{
|
|
||||||
String requestURI = request.getRequestURI();
|
|
||||||
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
|
|
||||||
return AjaxResult.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求参数类型不匹配
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
|
||||||
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request)
|
|
||||||
{
|
|
||||||
String requestURI = request.getRequestURI();
|
|
||||||
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
|
|
||||||
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拦截未知的运行时异常
|
* 拦截未知的运行时异常
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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;
|
||||||
|
|
@ -27,8 +25,6 @@ import com.ruoyi.system.api.model.LoginUser;
|
||||||
@Component
|
@Component
|
||||||
public class TokenService
|
public class TokenService
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(TokenService.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
|
@ -53,7 +49,7 @@ public class TokenService
|
||||||
loginUser.setToken(token);
|
loginUser.setToken(token);
|
||||||
loginUser.setUserid(userId);
|
loginUser.setUserid(userId);
|
||||||
loginUser.setUsername(userName);
|
loginUser.setUsername(userName);
|
||||||
loginUser.setIpaddr(IpUtils.getIpAddr());
|
loginUser.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
|
|
||||||
// Jwt存储信息
|
// Jwt存储信息
|
||||||
|
|
@ -110,7 +106,6 @@ public class TokenService
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("获取用户信息异常'{}'", e.getMessage());
|
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,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.alibaba.fastjson2.JSONArray;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
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;
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
|
|
@ -58,7 +58,7 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static void clearDictCache()
|
public static void clearDictCache()
|
||||||
{
|
{
|
||||||
Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(CacheConstants.SYS_DICT_KEY + "*");
|
Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(Constants.SYS_DICT_KEY + "*");
|
||||||
SpringUtils.getBean(RedisService.class).deleteObject(keys);
|
SpringUtils.getBean(RedisService.class).deleteObject(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,6 +70,6 @@ public class DictUtils
|
||||||
*/
|
*/
|
||||||
public static String getCacheKey(String configKey)
|
public static String getCacheKey(String configKey)
|
||||||
{
|
{
|
||||||
return CacheConstants.SYS_DICT_KEY + configKey;
|
return Constants.SYS_DICT_KEY + configKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
|
@ -26,9 +26,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
@EnableConfigurationProperties(SwaggerProperties.class)
|
@EnableAutoConfiguration
|
||||||
@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true)
|
||||||
@Import({SwaggerBeanPostProcessor.class, SwaggerWebConfiguration.class})
|
|
||||||
public class SwaggerAutoConfiguration
|
public class SwaggerAutoConfiguration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,6 +37,13 @@ public class SwaggerAutoConfiguration
|
||||||
|
|
||||||
private static final String BASE_PATH = "/**";
|
private static final String BASE_PATH = "/**";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public SwaggerProperties swaggerProperties()
|
||||||
|
{
|
||||||
|
return new SwaggerProperties();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket api(SwaggerProperties swaggerProperties)
|
public Docket api(SwaggerProperties swaggerProperties)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.common.swagger.config;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
|
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
|
||||||
import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
|
import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
|
||||||
|
|
@ -15,6 +16,7 @@ import java.util.stream.Collectors;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class SwaggerBeanPostProcessor implements BeanPostProcessor
|
public class SwaggerBeanPostProcessor implements BeanPostProcessor
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ package com.ruoyi.common.swagger.config;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
@ConfigurationProperties("swagger")
|
@ConfigurationProperties("swagger")
|
||||||
public class SwaggerProperties
|
public class SwaggerProperties
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.common.swagger.config;
|
package com.ruoyi.common.swagger.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
|
@ -8,6 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@Configuration
|
||||||
public class SwaggerWebConfiguration implements WebMvcConfigurer
|
public class SwaggerWebConfiguration implements WebMvcConfigurer
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
# com.ruoyi.common.swagger.config.SwaggerAutoConfiguration
|
com.ruoyi.common.swagger.config.SwaggerAutoConfiguration
|
||||||
# com.ruoyi.common.swagger.config.SwaggerWebConfiguration
|
com.ruoyi.common.swagger.config.SwaggerWebConfiguration
|
||||||
# com.ruoyi.common.swagger.config.SwaggerBeanPostProcessor
|
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.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
<!--验证码 -->
|
<!--验证码 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pro.fessional</groupId>
|
<groupId>com.github.penggle</groupId>
|
||||||
<artifactId>kaptcha</artifactId>
|
<artifactId>kaptcha</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
|
||||||
// 非登录/注册请求或验证码关闭,不处理
|
// 非登录/注册请求或验证码关闭,不处理
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL) || !captchaProperties.getEnabled())
|
if (!StringUtils.containsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL) || !captchaProperties.getEnabled())
|
||||||
{
|
{
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,6 @@ public class XssFilter implements GlobalFilter, Ordered
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
|
||||||
{
|
{
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
// xss开关未开启 或 通过nacos关闭,不过滤
|
|
||||||
if (!xss.getEnabled())
|
|
||||||
{
|
|
||||||
return chain.filter(exchange);
|
|
||||||
}
|
|
||||||
// GET DELETE 不过滤
|
// GET DELETE 不过滤
|
||||||
HttpMethod method = request.getMethod();
|
HttpMethod method = request.getMethod();
|
||||||
if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)
|
if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE)
|
||||||
|
|
@ -87,7 +82,7 @@ public class XssFilter implements GlobalFilter, Ordered
|
||||||
// 防xss攻击过滤
|
// 防xss攻击过滤
|
||||||
bodyStr = EscapeUtil.clean(bodyStr);
|
bodyStr = EscapeUtil.clean(bodyStr);
|
||||||
// 转成字节
|
// 转成字节
|
||||||
byte[] bytes = bodyStr.getBytes(StandardCharsets.UTF_8);
|
byte[] bytes = bodyStr.getBytes();
|
||||||
NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT);
|
NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT);
|
||||||
DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length);
|
DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length);
|
||||||
buffer.write(bytes);
|
buffer.write(bytes);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.FastByteArrayOutputStream;
|
import org.springframework.util.FastByteArrayOutputStream;
|
||||||
import com.google.code.kaptcha.Producer;
|
import com.google.code.kaptcha.Producer;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
|
||||||
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.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
@ -56,7 +55,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtils.simpleUUID();
|
String uuid = IdUtils.simpleUUID();
|
||||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
|
|
||||||
String capStr = null, code = null;
|
String capStr = null, code = null;
|
||||||
BufferedImage image = null;
|
BufferedImage image = null;
|
||||||
|
|
@ -107,7 +106,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||||
{
|
{
|
||||||
throw new CaptchaException("验证码已失效");
|
throw new CaptchaException("验证码已失效");
|
||||||
}
|
}
|
||||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
String captcha = redisService.getCacheObject(verifyKey);
|
String captcha = redisService.getCacheObject(verifyKey);
|
||||||
redisService.deleteObject(verifyKey);
|
redisService.deleteObject(verifyKey);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,4 @@ spring:
|
||||||
dataId: sentinel-ruoyi-gateway
|
dataId: sentinel-ruoyi-gateway
|
||||||
groupId: DEFAULT_GROUP
|
groupId: DEFAULT_GROUP
|
||||||
data-type: json
|
data-type: json
|
||||||
rule-type: gw-flow
|
rule-type: flow
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.3</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.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
package com.ruoyi.file.service;
|
package com.ruoyi.file.service;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import com.alibaba.nacos.common.utils.IoUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FastDFS 文件存储
|
* FastDFS 文件存储
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -29,7 +27,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FastDfs文件上传接口
|
* FastDfs文件上传接口
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
@ -37,10 +35,8 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(MultipartFile file) throws Exception
|
public String uploadFile(MultipartFile file) throws Exception
|
||||||
{
|
{
|
||||||
InputStream inputStream = file.getInputStream();
|
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
|
||||||
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
|
FilenameUtils.getExtension(file.getOriginalFilename()), null);
|
||||||
FileTypeUtils.getExtension(file), null);
|
|
||||||
IoUtils.closeQuietly(inputStream);
|
|
||||||
return domain + "/" + storePath.getFullPath();
|
return domain + "/" + storePath.getFullPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
package com.ruoyi.file.service;
|
package com.ruoyi.file.service;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
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.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.alibaba.nacos.common.utils.IoUtils;
|
|
||||||
import com.ruoyi.file.config.MinioConfig;
|
import com.ruoyi.file.config.MinioConfig;
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
|
|
@ -12,7 +10,7 @@ import io.minio.PutObjectArgs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minio 文件存储
|
* Minio 文件存储
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -25,8 +23,8 @@ public class MinioSysFileServiceImpl implements ISysFileService
|
||||||
private MinioClient client;
|
private MinioClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minio文件上传接口
|
* 本地文件上传接口
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
@ -35,15 +33,13 @@ public class MinioSysFileServiceImpl implements ISysFileService
|
||||||
public String uploadFile(MultipartFile file) throws Exception
|
public String uploadFile(MultipartFile file) throws Exception
|
||||||
{
|
{
|
||||||
String fileName = FileUploadUtils.extractFilename(file);
|
String fileName = FileUploadUtils.extractFilename(file);
|
||||||
InputStream inputStream = file.getInputStream();
|
|
||||||
PutObjectArgs args = PutObjectArgs.builder()
|
PutObjectArgs args = PutObjectArgs.builder()
|
||||||
.bucket(minioConfig.getBucketName())
|
.bucket(minioConfig.getBucketName())
|
||||||
.object(fileName)
|
.object(fileName)
|
||||||
.stream(inputStream, file.getSize(), -1)
|
.stream(file.getInputStream(), file.getSize(), -1)
|
||||||
.contentType(file.getContentType())
|
.contentType(file.getContentType())
|
||||||
.build();
|
.build();
|
||||||
client.putObject(args);
|
client.putObject(args);
|
||||||
IoUtils.closeQuietly(inputStream);
|
|
||||||
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
|
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import java.nio.file.Paths;
|
||||||
import java.util.Objects;
|
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.FileException;
|
|
||||||
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;
|
||||||
|
|
@ -47,10 +46,6 @@ public class FileUploadUtils
|
||||||
{
|
{
|
||||||
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||||
}
|
}
|
||||||
catch (FileException fe)
|
|
||||||
{
|
|
||||||
throw new IOException(fe.getDefaultMessage(), fe);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new IOException(e.getMessage(), e);
|
throw new IOException(e.getMessage(), e);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -54,10 +54,16 @@
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Commons Collections -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Mysql Connector -->
|
<!-- Mysql Connector -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- RuoYi Common Log -->
|
<!-- RuoYi Common Log -->
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class RuoYiGenApplication
|
public class RuoYiGenApplication
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class GenController extends BaseController
|
||||||
map.put("info", table);
|
map.put("info", table);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
map.put("tables", tables);
|
map.put("tables", tables);
|
||||||
return success(map);
|
return AjaxResult.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -109,7 +109,7 @@ public class GenController extends BaseController
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||||
genTableService.importGenTable(tableList);
|
genTableService.importGenTable(tableList);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,7 +122,7 @@ public class GenController extends BaseController
|
||||||
{
|
{
|
||||||
genTableService.validateEdit(genTable);
|
genTableService.validateEdit(genTable);
|
||||||
genTableService.updateGenTable(genTable);
|
genTableService.updateGenTable(genTable);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,7 +134,7 @@ public class GenController extends BaseController
|
||||||
public AjaxResult remove(@PathVariable Long[] tableIds)
|
public AjaxResult remove(@PathVariable Long[] tableIds)
|
||||||
{
|
{
|
||||||
genTableService.deleteGenTableByIds(tableIds);
|
genTableService.deleteGenTableByIds(tableIds);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,7 +145,7 @@ public class GenController extends BaseController
|
||||||
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
|
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
|
||||||
{
|
{
|
||||||
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
||||||
return success(dataMap);
|
return AjaxResult.success(dataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -169,7 +169,7 @@ public class GenController extends BaseController
|
||||||
public AjaxResult genCode(@PathVariable("tableName") String tableName)
|
public AjaxResult genCode(@PathVariable("tableName") String tableName)
|
||||||
{
|
{
|
||||||
genTableService.generatorCode(tableName);
|
genTableService.generatorCode(tableName);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -181,7 +181,7 @@ public class GenController extends BaseController
|
||||||
public AjaxResult synchDb(@PathVariable("tableName") String tableName)
|
public AjaxResult synchDb(@PathVariable("tableName") String tableName)
|
||||||
{
|
{
|
||||||
genTableService.synchDb(tableName);
|
genTableService.synchDb(tableName);
|
||||||
return success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,6 @@ public class GenTable extends BaseEntity
|
||||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
||||||
private String tplCategory;
|
private String tplCategory;
|
||||||
|
|
||||||
/** 前端类型(element-ui模版 element-plus模版) */
|
|
||||||
private String tplWebType;
|
|
||||||
|
|
||||||
/** 生成包路径 */
|
/** 生成包路径 */
|
||||||
@NotBlank(message = "生成包路径不能为空")
|
@NotBlank(message = "生成包路径不能为空")
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
@ -168,16 +165,6 @@ public class GenTable extends BaseEntity
|
||||||
this.tplCategory = tplCategory;
|
this.tplCategory = tplCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTplWebType()
|
|
||||||
{
|
|
||||||
return tplWebType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTplWebType(String tplWebType)
|
|
||||||
{
|
|
||||||
this.tplWebType = tplWebType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackageName()
|
public String getPackageName()
|
||||||
{
|
{
|
||||||
return packageName;
|
return packageName;
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates)
|
||||||
{
|
{
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
|
|
@ -254,7 +254,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates)
|
||||||
{
|
{
|
||||||
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
|
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
|
||||||
|
|
@ -367,7 +367,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates)
|
||||||
{
|
{
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
|
|
|
||||||
|
|
@ -123,17 +123,11 @@ public class VelocityUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模板信息
|
* 获取模板信息
|
||||||
* @param tplCategory 生成的模板
|
*
|
||||||
* @param tplWebType 前端类型
|
|
||||||
* @return 模板列表
|
* @return 模板列表
|
||||||
*/
|
*/
|
||||||
public static List<String> getTemplateList(String tplCategory, String tplWebType)
|
public static List<String> getTemplateList(String tplCategory)
|
||||||
{
|
{
|
||||||
String useWebType = "vm/vue";
|
|
||||||
if ("element-plus".equals(tplWebType))
|
|
||||||
{
|
|
||||||
useWebType = "vm/vue/v3";
|
|
||||||
}
|
|
||||||
List<String> templates = new ArrayList<String>();
|
List<String> templates = new ArrayList<String>();
|
||||||
templates.add("vm/java/domain.java.vm");
|
templates.add("vm/java/domain.java.vm");
|
||||||
templates.add("vm/java/mapper.java.vm");
|
templates.add("vm/java/mapper.java.vm");
|
||||||
|
|
@ -145,15 +139,15 @@ public class VelocityUtils
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.add("vm/js/api.js.vm");
|
||||||
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
||||||
{
|
{
|
||||||
templates.add(useWebType + "/index.vue.vm");
|
templates.add("vm/vue/index.vue.vm");
|
||||||
}
|
}
|
||||||
else if (GenConstants.TPL_TREE.equals(tplCategory))
|
else if (GenConstants.TPL_TREE.equals(tplCategory))
|
||||||
{
|
{
|
||||||
templates.add(useWebType + "/index-tree.vue.vm");
|
templates.add("vm/vue/index-tree.vue.vm");
|
||||||
}
|
}
|
||||||
else if (GenConstants.TPL_SUB.equals(tplCategory))
|
else if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||||
{
|
{
|
||||||
templates.add(useWebType + "/index.vue.vm");
|
templates.add("vm/vue/index.vue.vm");
|
||||||
templates.add("vm/java/sub-domain.java.vm");
|
templates.add("vm/java/sub-domain.java.vm");
|
||||||
}
|
}
|
||||||
return templates;
|
return templates;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ruoyi.gen.mapper.GenTableColumnMapper">
|
<mapper namespace="com.ruoyi.gen.mapper.GenTableColumnMapper">
|
||||||
|
|
||||||
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
||||||
<id property="columnId" column="column_id" />
|
<id property="columnId" column="column_id" />
|
||||||
<result property="tableId" column="table_id" />
|
<result property="tableId" column="table_id" />
|
||||||
|
|
@ -28,23 +28,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableColumnVo">
|
<sql id="selectGenTableColumnVo">
|
||||||
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
|
<select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
|
||||||
<include refid="selectGenTableColumnVo"/>
|
<include refid="selectGenTableColumnVo"/>
|
||||||
where table_id = #{tableId}
|
where table_id = #{tableId}
|
||||||
order by sort
|
order by sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
||||||
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
||||||
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
||||||
order by ordinal_position
|
order by ordinal_position
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
||||||
insert into gen_table_column (
|
insert into gen_table_column (
|
||||||
<if test="tableId != null and tableId != ''">table_id,</if>
|
<if test="tableId != null and tableId != ''">table_id,</if>
|
||||||
|
|
@ -88,37 +88,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateGenTableColumn" parameterType="GenTableColumn">
|
<update id="updateGenTableColumn" parameterType="GenTableColumn">
|
||||||
update gen_table_column
|
update gen_table_column
|
||||||
<set>
|
<set>
|
||||||
<if test="columnComment != null">column_comment = #{columnComment},</if>
|
column_comment = #{columnComment},
|
||||||
<if test="javaType != null">java_type = #{javaType},</if>
|
java_type = #{javaType},
|
||||||
<if test="javaField != null">java_field = #{javaField},</if>
|
java_field = #{javaField},
|
||||||
<if test="isInsert != null">is_insert = #{isInsert},</if>
|
is_insert = #{isInsert},
|
||||||
<if test="isEdit != null">is_edit = #{isEdit},</if>
|
is_edit = #{isEdit},
|
||||||
<if test="isList != null">is_list = #{isList},</if>
|
is_list = #{isList},
|
||||||
<if test="isQuery != null">is_query = #{isQuery},</if>
|
is_query = #{isQuery},
|
||||||
<if test="isRequired != null">is_required = #{isRequired},</if>
|
is_required = #{isRequired},
|
||||||
<if test="queryType != null">query_type = #{queryType},</if>
|
query_type = #{queryType},
|
||||||
<if test="htmlType != null">html_type = #{htmlType},</if>
|
html_type = #{htmlType},
|
||||||
<if test="dictType != null">dict_type = #{dictType},</if>
|
dict_type = #{dictType},
|
||||||
<if test="sort != null">sort = #{sort},</if>
|
sort = #{sort},
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
update_by = #{updateBy},
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where column_id = #{columnId}
|
where column_id = #{columnId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
||||||
delete from gen_table_column where table_id in
|
delete from gen_table_column where table_id in
|
||||||
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
||||||
#{tableId}
|
#{tableId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteGenTableColumns">
|
<delete id="deleteGenTableColumns">
|
||||||
delete from gen_table_column where column_id in
|
delete from gen_table_column where column_id in
|
||||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||||
#{item.columnId}
|
#{item.columnId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="subTableFkName" column="sub_table_fk_name" />
|
<result property="subTableFkName" column="sub_table_fk_name" />
|
||||||
<result property="className" column="class_name" />
|
<result property="className" column="class_name" />
|
||||||
<result property="tplCategory" column="tpl_category" />
|
<result property="tplCategory" column="tpl_category" />
|
||||||
<result property="tplWebType" column="tpl_web_type" />
|
|
||||||
<result property="packageName" column="package_name" />
|
<result property="packageName" column="package_name" />
|
||||||
<result property="moduleName" column="module_name" />
|
<result property="moduleName" column="module_name" />
|
||||||
<result property="businessName" column="business_name" />
|
<result property="businessName" column="business_name" />
|
||||||
|
|
@ -55,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableVo">
|
<sql id="selectGenTableVo">
|
||||||
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||||
|
|
@ -112,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
FROM gen_table t
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
|
@ -120,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
FROM gen_table t
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
|
@ -128,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
FROM gen_table t
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
|
@ -141,7 +140,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
||||||
<if test="className != null and className != ''">class_name,</if>
|
<if test="className != null and className != ''">class_name,</if>
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
|
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
|
||||||
<if test="tplWebType != null and tplWebType != ''">tpl_web_type,</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name,</if>
|
<if test="packageName != null and packageName != ''">package_name,</if>
|
||||||
<if test="moduleName != null and moduleName != ''">module_name,</if>
|
<if test="moduleName != null and moduleName != ''">module_name,</if>
|
||||||
<if test="businessName != null and businessName != ''">business_name,</if>
|
<if test="businessName != null and businessName != ''">business_name,</if>
|
||||||
|
|
@ -157,7 +155,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
|
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
|
||||||
<if test="className != null and className != ''">#{className},</if>
|
<if test="className != null and className != ''">#{className},</if>
|
||||||
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
|
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
|
||||||
<if test="tplWebType != null and tplWebType != ''">#{tplWebType},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
||||||
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
|
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
|
||||||
<if test="businessName != null and businessName != ''">#{businessName},</if>
|
<if test="businessName != null and businessName != ''">#{businessName},</if>
|
||||||
|
|
@ -183,7 +180,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
||||||
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
|
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
|
||||||
<if test="tplWebType != null and tplWebType != ''">tpl_web_type = #{tplWebType},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
||||||
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
|
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
|
||||||
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
|
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class ${ClassName}Controller extends BaseController
|
||||||
public AjaxResult list(${ClassName} ${className})
|
public AjaxResult list(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
return success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class ${ClassName}Controller extends BaseController
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -187,11 +187,11 @@
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "imageUpload")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<image-upload v-model="form.${field}"/>
|
<image-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "fileUpload")
|
#elseif($column.htmlType == "fileUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<file-upload v-model="form.${field}"/>
|
<file-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
|
|
@ -205,11 +205,8 @@
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:value="dict.value"
|
|
||||||
#end
|
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -220,7 +217,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
|
|
@ -231,27 +228,24 @@
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:label="dict.value"
|
|
||||||
#end
|
|
||||||
>{{dict.label}}</el-radio>
|
>{{dict.label}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
|
@ -341,7 +335,7 @@ export default {
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($foreach.count != $columns.size()),#end
|
]#if($foreach.count != $columns.size()),#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
@ -404,7 +398,10 @@ export default {
|
||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||||
|
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
#else
|
#else
|
||||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
|
|
||||||
|
|
@ -198,11 +198,11 @@
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "imageUpload")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<image-upload v-model="form.${field}"/>
|
<image-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "fileUpload")
|
#elseif($column.htmlType == "fileUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<file-upload v-model="form.${field}"/>
|
<file-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
|
|
@ -216,11 +216,8 @@
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:value="dict.value"
|
|
||||||
#end
|
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -231,7 +228,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
|
|
@ -242,27 +239,24 @@
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:label="dict.value"
|
|
||||||
#end
|
|
||||||
>{{dict.label}}</el-radio>
|
>{{dict.label}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
|
@ -418,7 +412,7 @@ export default {
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($foreach.count != $columns.size()),#end
|
]#if($foreach.count != $columns.size()),#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
@ -462,7 +456,9 @@ export default {
|
||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
#else
|
#else
|
||||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
|
|
||||||
|
|
@ -136,9 +136,24 @@
|
||||||
#end
|
#end
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
<el-button
|
||||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
type="text"
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
icon="Edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -173,11 +188,11 @@
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "imageUpload")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<image-upload v-model="form.${field}"/>
|
<image-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "fileUpload")
|
#elseif($column.htmlType == "fileUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<file-upload v-model="form.${field}"/>
|
<file-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
|
|
@ -191,11 +206,8 @@
|
||||||
v-for="dict in ${dictType}"
|
v-for="dict in ${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:value="dict.value"
|
|
||||||
#end
|
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -206,7 +218,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in ${dictType}"
|
v-for="dict in ${dictType}"
|
||||||
|
|
@ -217,27 +229,24 @@
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in ${dictType}"
|
v-for="dict in ${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:label="dict.value"
|
|
||||||
#end
|
|
||||||
>{{dict.label}}</el-radio>
|
>{{dict.label}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
|
@ -313,7 +322,7 @@ const data = reactive({
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($foreach.count != $columns.size()),#end
|
]#if($foreach.count != $columns.size()),#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
@ -366,7 +375,10 @@ function cancel() {
|
||||||
function reset() {
|
function reset() {
|
||||||
form.value = {
|
form.value = {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||||
|
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
#else
|
#else
|
||||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,18 @@
|
||||||
#end
|
#end
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
<el-button
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
type="text"
|
||||||
|
icon="Edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -181,11 +191,11 @@
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "imageUpload")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<image-upload v-model="form.${field}"/>
|
<image-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "fileUpload")
|
#elseif($column.htmlType == "fileUpload")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<file-upload v-model="form.${field}"/>
|
<file-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
|
|
@ -199,11 +209,8 @@
|
||||||
v-for="dict in ${dictType}"
|
v-for="dict in ${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:value="dict.value"
|
|
||||||
#end
|
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -214,7 +221,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in ${dictType}"
|
v-for="dict in ${dictType}"
|
||||||
|
|
@ -225,27 +232,24 @@
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-checkbox-group v-model="form.${field}">
|
<el-checkbox-group v-model="form.${field}">
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in ${dictType}"
|
v-for="dict in ${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
#else
|
|
||||||
:label="dict.value"
|
|
||||||
#end
|
|
||||||
>{{dict.label}}</el-radio>
|
>{{dict.label}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}">
|
||||||
<el-radio-group v-model="form.${field}">
|
<el-radio-group v-model="form.${field}">
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
|
@ -394,7 +398,7 @@ const data = reactive({
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($foreach.count != $columns.size()),#end
|
]#if($foreach.count != $columns.size()),#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
@ -438,7 +442,9 @@ function cancel() {
|
||||||
function reset() {
|
function reset() {
|
||||||
form.value = {
|
form.value = {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
#else
|
#else
|
||||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
|
@ -486,8 +492,8 @@ function handleAdd() {
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
function handleUpdate(row) {
|
function handleUpdate(row) {
|
||||||
reset();
|
reset();
|
||||||
const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value
|
const ${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value
|
||||||
get${BusinessName}(_${pkColumn.javaField}).then(response => {
|
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
||||||
form.value = response.data;
|
form.value = response.data;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "checkbox")
|
||||||
|
|
@ -533,9 +539,9 @@ function submitForm() {
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
function handleDelete(row) {
|
function handleDelete(row) {
|
||||||
const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
|
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
|
||||||
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
|
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() {
|
||||||
return del${BusinessName}(_${pkColumn.javaField}s);
|
return del${BusinessName}(${pkColumn.javaField}s);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
getList();
|
getList();
|
||||||
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
如果使用的是RuoYi-Cloud-Vue3前端,那么需要覆盖一下此目录的模板index.vue.vm、index-tree.vue.vm文件到上级vue目录。
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -62,8 +62,8 @@
|
||||||
|
|
||||||
<!-- Mysql Connector -->
|
<!-- Mysql Connector -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- RuoYi Common Log -->
|
<!-- RuoYi Common Log -->
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class RuoYiJobApplication
|
public class RuoYiJobApplication
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue