Merge branch 'master' of https://gitee.com/y_project/RuoYi-Cloud
This commit is contained in:
commit
53c881927f
66
pom.xml
66
pom.xml
|
|
@ -6,37 +6,37 @@
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.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.0.0</ruoyi.version>
|
<ruoyi.version>3.1.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.5.1</spring-boot.version>
|
<spring-boot.version>2.5.3</spring-boot.version>
|
||||||
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||||||
<alibaba.nacos.version>2.0.2</alibaba.nacos.version>
|
<alibaba.nacos.version>2.0.3</alibaba.nacos.version>
|
||||||
<spring-boot-admin.version>2.4.1</spring-boot-admin.version>
|
<spring-boot-admin.version>2.4.3</spring-boot-admin.version>
|
||||||
<spring-boot.mybatis>2.1.4</spring-boot.mybatis>
|
<spring-boot.mybatis>2.2.0</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.26.5</tobato.version>
|
<tobato.version>1.27.2</tobato.version>
|
||||||
<kaptcha.version>2.3.2</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
||||||
<druid.version>1.2.6</druid.version>
|
<druid.version>1.2.6</druid.version>
|
||||||
<dynamic-ds.version>3.4.0</dynamic-ds.version>
|
<dynamic-ds.version>3.4.1</dynamic-ds.version>
|
||||||
<commons.io.version>2.10.0</commons.io.version>
|
<commons.io.version>2.11.0</commons.io.version>
|
||||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||||
<velocity.version>1.7</velocity.version>
|
<velocity.version>1.7</velocity.version>
|
||||||
<fastjson.version>1.2.76</fastjson.version>
|
<fastjson.version>1.2.76</fastjson.version>
|
||||||
<minio.version>8.2.1</minio.version>
|
<minio.version>8.2.2</minio.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<common-pool.version>2.6.2</common-pool.version>
|
<common-pool.version>2.10.0</common-pool.version>
|
||||||
<commons-collections.version>3.2.2</commons-collections.version>
|
<commons-collections.version>3.2.2</commons-collections.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba 微服务 -->
|
<!-- SpringCloud Alibaba 微服务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
|
@ -77,28 +77,28 @@
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringBoot 监控客户端 -->
|
<!-- SpringBoot 监控客户端 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.codecentric</groupId>
|
<groupId>de.codecentric</groupId>
|
||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
<version>${spring-boot-admin.version}</version>
|
<version>${spring-boot-admin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- FastDFS 分布式文件系统 -->
|
<!-- FastDFS 分布式文件系统 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tobato</groupId>
|
<groupId>com.github.tobato</groupId>
|
||||||
<artifactId>fastdfs-client</artifactId>
|
<artifactId>fastdfs-client</artifactId>
|
||||||
<version>${tobato.version}</version>
|
<version>${tobato.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Mybatis 依赖配置 -->
|
<!-- Mybatis 依赖配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis.spring.boot</groupId>
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
<version>${spring-boot.mybatis}</version>
|
<version>${spring-boot.mybatis}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger 依赖配置 -->
|
<!-- Swagger 依赖配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
|
|
@ -172,7 +172,7 @@
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 公共资源池 -->
|
<!-- 公共资源池 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
|
@ -181,71 +181,71 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 核心模块 -->
|
<!-- 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 接口模块 -->
|
<!-- 接口模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-swagger</artifactId>
|
<artifactId>ruoyi-common-swagger</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 安全模块 -->
|
<!-- 安全模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-security</artifactId>
|
<artifactId>ruoyi-common-security</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 权限范围 -->
|
<!-- 权限范围 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-datascope</artifactId>
|
<artifactId>ruoyi-common-datascope</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 多数据源 -->
|
<!-- 多数据源 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-datasource</artifactId>
|
<artifactId>ruoyi-common-datasource</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 日志记录 -->
|
<!-- 日志记录 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-log</artifactId>
|
<artifactId>ruoyi-common-log</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 缓存服务 -->
|
<!-- 缓存服务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common-redis</artifactId>
|
<artifactId>ruoyi-common-redis</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 系统接口 -->
|
<!-- 系统接口 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-api-system</artifactId>
|
<artifactId>ruoyi-api-system</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>ruoyi-auth</module>
|
<module>ruoyi-auth</module>
|
||||||
<module>ruoyi-gateway</module>
|
<module>ruoyi-gateway</module>
|
||||||
<module>ruoyi-visual</module>
|
<module>ruoyi-visual</module>
|
||||||
<module>ruoyi-modules</module>
|
<module>ruoyi-modules</module>
|
||||||
<module>ruoyi-api</module>
|
<module>ruoyi-api</module>
|
||||||
<module>ruoyi-common</module>
|
<module>ruoyi-common</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.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.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ package com.ruoyi.system.api;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.api.domain.SysOperLog;
|
import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
import com.ruoyi.system.api.factory.RemoteLogFallbackFactory;
|
import com.ruoyi.system.api.factory.RemoteLogFallbackFactory;
|
||||||
|
|
||||||
|
|
@ -21,20 +23,19 @@ public interface RemoteLogService
|
||||||
* 保存系统日志
|
* 保存系统日志
|
||||||
*
|
*
|
||||||
* @param sysOperLog 日志实体
|
* @param sysOperLog 日志实体
|
||||||
|
* @param source 请求来源
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/operlog")
|
@PostMapping("/operlog")
|
||||||
R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog);
|
public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存访问记录
|
* 保存访问记录
|
||||||
*
|
*
|
||||||
* @param username 用户名称
|
* @param sysLogininfor 访问实体
|
||||||
* @param status 状态
|
* @param source 请求来源
|
||||||
* @param message 消息
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/logininfor")
|
@PostMapping("/logininfor")
|
||||||
R<Boolean> saveLogininfor(@RequestParam("username") String username, @RequestParam("status") String status,
|
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
@RequestParam("message") String message);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,13 @@ package com.ruoyi.system.api;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
|
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
|
||||||
|
|
@ -20,8 +25,19 @@ public interface RemoteUserService
|
||||||
* 通过用户名查询用户信息
|
* 通过用户名查询用户信息
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
|
* @param source 请求来源
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/user/info/{username}")
|
@GetMapping("/user/info/{username}")
|
||||||
public R<LoginUser> getUserInfo(@PathVariable("username") String username);
|
public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户信息
|
||||||
|
*
|
||||||
|
* @param sysUser 用户信息
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/register")
|
||||||
|
public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
@ -57,9 +57,6 @@ public class SysUser extends BaseEntity
|
||||||
/** 密码 */
|
/** 密码 */
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/** 盐加密 */
|
|
||||||
private String salt;
|
|
||||||
|
|
||||||
/** 帐号状态(0正常 1停用) */
|
/** 帐号状态(0正常 1停用) */
|
||||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
@ -211,16 +208,6 @@ public class SysUser extends BaseEntity
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSalt()
|
|
||||||
{
|
|
||||||
return salt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSalt(String salt)
|
|
||||||
{
|
|
||||||
this.salt = salt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
|
|
@ -322,7 +309,6 @@ public class SysUser extends BaseEntity
|
||||||
.append("sex", getSex())
|
.append("sex", getSex())
|
||||||
.append("avatar", getAvatar())
|
.append("avatar", getAvatar())
|
||||||
.append("password", getPassword())
|
.append("password", getPassword())
|
||||||
.append("salt", getSalt())
|
|
||||||
.append("status", getStatus())
|
.append("status", getStatus())
|
||||||
.append("delFlag", getDelFlag())
|
.append("delFlag", getDelFlag())
|
||||||
.append("loginIp", getLoginIp())
|
.append("loginIp", getLoginIp())
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.system.api.RemoteLogService;
|
import com.ruoyi.system.api.RemoteLogService;
|
||||||
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.api.domain.SysOperLog;
|
import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,13 +26,13 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
||||||
return new RemoteLogService()
|
return new RemoteLogService()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveLog(SysOperLog sysOperLog)
|
public R<Boolean> saveLog(SysOperLog sysOperLog, String source)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveLogininfor(String username, String status, String message)
|
public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.system.api.RemoteUserService;
|
import com.ruoyi.system.api.RemoteUserService;
|
||||||
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,10 +26,16 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
return new RemoteUserService()
|
return new RemoteUserService()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public R<LoginUser> getUserInfo(String username)
|
public R<LoginUser> getUserInfo(String username, String source)
|
||||||
{
|
{
|
||||||
return R.fail("获取用户失败:" + throwable.getMessage());
|
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Boolean> registerUserInfo(SysUser sysUser, String source)
|
||||||
|
{
|
||||||
|
return R.fail("注册用户失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.auth.form.LoginBody;
|
import com.ruoyi.auth.form.LoginBody;
|
||||||
|
import com.ruoyi.auth.form.RegisterBody;
|
||||||
import com.ruoyi.auth.service.SysLoginService;
|
import com.ruoyi.auth.service.SysLoginService;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
@ -63,4 +64,12 @@ public class TokenController
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("register")
|
||||||
|
public R<?> register(@RequestBody RegisterBody registerBody)
|
||||||
|
{
|
||||||
|
// 用户注册
|
||||||
|
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.ruoyi.auth.form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册对象
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class RegisterBody extends LoginBody
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,14 +3,18 @@ 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.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
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.BaseException;
|
import com.ruoyi.common.core.exception.BaseException;
|
||||||
import com.ruoyi.common.core.utils.SecurityUtils;
|
import com.ruoyi.common.core.utils.SecurityUtils;
|
||||||
|
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.system.api.RemoteLogService;
|
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;
|
||||||
|
|
||||||
|
|
@ -36,25 +40,25 @@ public class SysLoginService
|
||||||
// 用户名或密码为空 错误
|
// 用户名或密码为空 错误
|
||||||
if (StringUtils.isAnyBlank(username, password))
|
if (StringUtils.isAnyBlank(username, password))
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||||
throw new BaseException("用户/密码必须填写");
|
throw new BaseException("用户/密码必须填写");
|
||||||
}
|
}
|
||||||
// 密码如果不在指定范围内 错误
|
// 密码如果不在指定范围内 错误
|
||||||
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)
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||||
throw new BaseException("用户密码不在指定范围");
|
throw new BaseException("用户密码不在指定范围");
|
||||||
}
|
}
|
||||||
// 用户名不在指定范围内 错误
|
// 用户名不在指定范围内 错误
|
||||||
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)
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||||
throw new BaseException("用户名不在指定范围");
|
throw new BaseException("用户名不在指定范围");
|
||||||
}
|
}
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
R<LoginUser> userResult = remoteUserService.getUserInfo(username);
|
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (R.FAIL == userResult.getCode())
|
if (R.FAIL == userResult.getCode())
|
||||||
{
|
{
|
||||||
|
|
@ -63,33 +67,93 @@ public class SysLoginService
|
||||||
|
|
||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
throw new BaseException("登录用户:" + username + " 不存在");
|
throw new BaseException("登录用户:" + 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()))
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||||
|
|
||||||
throw new BaseException("对不起,您的账号:" + username + " 已被删除");
|
throw new BaseException("对不起,您的账号:" + username + " 已被删除");
|
||||||
}
|
}
|
||||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||||
throw new BaseException("对不起,您的账号:" + username + " 已停用");
|
throw new BaseException("对不起,您的账号:" + username + " 已停用");
|
||||||
}
|
}
|
||||||
if (!SecurityUtils.matchesPassword(password, user.getPassword()))
|
if (!SecurityUtils.matchesPassword(password, user.getPassword()))
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误");
|
||||||
throw new BaseException("用户不存在/密码错误");
|
throw new BaseException("用户不存在/密码错误");
|
||||||
}
|
}
|
||||||
remoteLogService.saveLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logout(String loginName)
|
public void logout(String loginName)
|
||||||
{
|
{
|
||||||
remoteLogService.saveLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册
|
||||||
|
*/
|
||||||
|
public void register(String username, String password)
|
||||||
|
{
|
||||||
|
// 用户名或密码为空 错误
|
||||||
|
if (StringUtils.isAnyBlank(username, password))
|
||||||
|
{
|
||||||
|
throw new BaseException("用户/密码必须填写");
|
||||||
|
}
|
||||||
|
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||||
|
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
throw new BaseException("账户长度必须在2到20个字符之间");
|
||||||
|
}
|
||||||
|
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||||
|
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
throw new BaseException("密码长度必须在5到20个字符之间");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册用户信息
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setUserName(username);
|
||||||
|
sysUser.setNickName(username);
|
||||||
|
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||||
|
R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
if (R.FAIL == registerResult.getCode())
|
||||||
|
{
|
||||||
|
throw new BaseException(registerResult.getMsg());
|
||||||
|
}
|
||||||
|
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("0");
|
||||||
|
}
|
||||||
|
else if (Constants.LOGIN_FAIL.equals(status))
|
||||||
|
{
|
||||||
|
logininfor.setStatus("1");
|
||||||
|
}
|
||||||
|
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.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,33 +7,8 @@ package com.ruoyi.common.core.constant;
|
||||||
*/
|
*/
|
||||||
public class CacheConstants
|
public class CacheConstants
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 令牌自定义标识
|
|
||||||
*/
|
|
||||||
public static final String HEADER = "Authorization";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 令牌前缀
|
|
||||||
*/
|
|
||||||
public static final String TOKEN_PREFIX = "Bearer ";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限缓存前缀
|
* 权限缓存前缀
|
||||||
*/
|
*/
|
||||||
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID字段
|
|
||||||
*/
|
|
||||||
public static final String DETAILS_USER_ID = "user_id";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名字段
|
|
||||||
*/
|
|
||||||
public static final String DETAILS_USERNAME = "username";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权信息字段
|
|
||||||
*/
|
|
||||||
public static final String AUTHORIZATION_HEADER = "authorization";
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String GBK = "GBK";
|
public static final String GBK = "GBK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RMI 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_RMI = "rmi://";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http请求
|
* http请求
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.ruoyi.common.core.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限相关通用常量
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class SecurityConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 令牌自定义标识
|
||||||
|
*/
|
||||||
|
public static final String TOKEN_AUTHENTICATION = "Authorization";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌前缀
|
||||||
|
*/
|
||||||
|
public static final String TOKEN_PREFIX = "Bearer ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID字段
|
||||||
|
*/
|
||||||
|
public static final String DETAILS_USER_ID = "user_id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名字段
|
||||||
|
*/
|
||||||
|
public static final String DETAILS_USERNAME = "username";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权信息字段
|
||||||
|
*/
|
||||||
|
public static final String AUTHORIZATION_HEADER = "authorization";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求来源
|
||||||
|
*/
|
||||||
|
public static final String FROM_SOURCE = "from-source";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部请求
|
||||||
|
*/
|
||||||
|
public static final String INNER = "inner";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.ruoyi.common.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部认证异常
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class InnerAuthException extends RuntimeException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public InnerAuthException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,7 +17,7 @@ public class SecurityUtils
|
||||||
*/
|
*/
|
||||||
public static String getUsername()
|
public static String getUsername()
|
||||||
{
|
{
|
||||||
String username = ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME);
|
String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME);
|
||||||
return ServletUtils.urlDecode(username);
|
return ServletUtils.urlDecode(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class SecurityUtils
|
||||||
*/
|
*/
|
||||||
public static Long getUserId()
|
public static Long getUserId()
|
||||||
{
|
{
|
||||||
return Convert.toLong(ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USER_ID));
|
return Convert.toLong(ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,10 +42,18 @@ public class SecurityUtils
|
||||||
*/
|
*/
|
||||||
public static String getToken(HttpServletRequest request)
|
public static String getToken(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
String token = ServletUtils.getRequest().getHeader(CacheConstants.HEADER);
|
String token = request.getHeader(SecurityConstants.TOKEN_AUTHENTICATION);
|
||||||
if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX))
|
return replaceTokenPrefix(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替换token前缀
|
||||||
|
*/
|
||||||
|
public static String replaceTokenPrefix(String token)
|
||||||
|
{
|
||||||
|
if (StringUtils.isNotEmpty(token) && token.startsWith(SecurityConstants.TOKEN_PREFIX))
|
||||||
{
|
{
|
||||||
token = token.replace(CacheConstants.TOKEN_PREFIX, "");
|
token = token.replace(SecurityConstants.TOKEN_PREFIX, "");
|
||||||
}
|
}
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,19 @@ 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 javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端工具类
|
* 客户端工具类
|
||||||
|
|
@ -213,4 +221,62 @@ public class ServletUtils
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置webflux模型响应
|
||||||
|
*
|
||||||
|
* @param response ServerHttpResponse
|
||||||
|
* @param value 响应内容
|
||||||
|
* @return Mono<Void>
|
||||||
|
*/
|
||||||
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value)
|
||||||
|
{
|
||||||
|
return webFluxResponseWriter(response, HttpStatus.OK, value, R.FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置webflux模型响应
|
||||||
|
*
|
||||||
|
* @param response ServerHttpResponse
|
||||||
|
* @param code 响应状态码
|
||||||
|
* @param value 响应内容
|
||||||
|
* @return Mono<Void>
|
||||||
|
*/
|
||||||
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, Object value, int code)
|
||||||
|
{
|
||||||
|
return webFluxResponseWriter(response, HttpStatus.OK, value, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置webflux模型响应
|
||||||
|
*
|
||||||
|
* @param response ServerHttpResponse
|
||||||
|
* @param status http状态码
|
||||||
|
* @param code 响应状态码
|
||||||
|
* @param value 响应内容
|
||||||
|
* @return Mono<Void>
|
||||||
|
*/
|
||||||
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, HttpStatus status, Object value, int code)
|
||||||
|
{
|
||||||
|
return webFluxResponseWriter(response, MediaType.APPLICATION_JSON_VALUE, status, value, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置webflux模型响应
|
||||||
|
*
|
||||||
|
* @param response ServerHttpResponse
|
||||||
|
* @param contentType content-type
|
||||||
|
* @param status http状态码
|
||||||
|
* @param code 响应状态码
|
||||||
|
* @param value 响应内容
|
||||||
|
* @return Mono<Void>
|
||||||
|
*/
|
||||||
|
public static Mono<Void> webFluxResponseWriter(ServerHttpResponse response, String contentType, HttpStatus status, Object value, int code)
|
||||||
|
{
|
||||||
|
response.setStatusCode(status);
|
||||||
|
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, contentType);
|
||||||
|
R<?> result = R.fail(code, value.toString());
|
||||||
|
DataBuffer dataBuffer = response.bufferFactory().wrap(JSONObject.toJSONString(result).getBytes());
|
||||||
|
return response.writeWith(Mono.just(dataBuffer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,155 @@
|
||||||
|
package com.ruoyi.common.core.utils.html;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转义和反转义工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class EscapeUtil
|
||||||
|
{
|
||||||
|
public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)";
|
||||||
|
|
||||||
|
private static final char[][] TEXT = new char[64][];
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 64; i++)
|
||||||
|
{
|
||||||
|
TEXT[i] = new char[] { (char) i };
|
||||||
|
}
|
||||||
|
|
||||||
|
// special HTML characters
|
||||||
|
TEXT['\''] = "'".toCharArray(); // 单引号
|
||||||
|
TEXT['"'] = """.toCharArray(); // 双引号
|
||||||
|
TEXT['&'] = "&".toCharArray(); // &符
|
||||||
|
TEXT['<'] = "<".toCharArray(); // 小于号
|
||||||
|
TEXT['>'] = ">".toCharArray(); // 大于号
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转义文本中的HTML字符为安全的字符
|
||||||
|
*
|
||||||
|
* @param text 被转义的文本
|
||||||
|
* @return 转义后的文本
|
||||||
|
*/
|
||||||
|
public static String escape(String text)
|
||||||
|
{
|
||||||
|
return encode(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 还原被转义的HTML特殊字符
|
||||||
|
*
|
||||||
|
* @param content 包含转义符的HTML内容
|
||||||
|
* @return 转换后的字符串
|
||||||
|
*/
|
||||||
|
public static String unescape(String content)
|
||||||
|
{
|
||||||
|
return decode(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除所有HTML标签,但是不删除标签内的内容
|
||||||
|
*
|
||||||
|
* @param content 文本
|
||||||
|
* @return 清除标签后的文本
|
||||||
|
*/
|
||||||
|
public static String clean(String content)
|
||||||
|
{
|
||||||
|
return new HTMLFilter().filter(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape编码
|
||||||
|
*
|
||||||
|
* @param text 被编码的文本
|
||||||
|
* @return 编码后的字符
|
||||||
|
*/
|
||||||
|
private static String encode(String text)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
if ((text == null) || ((len = text.length()) == 0))
|
||||||
|
{
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
StringBuilder buffer = new StringBuilder(len + (len >> 2));
|
||||||
|
char c;
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
c = text.charAt(i);
|
||||||
|
if (c < 64)
|
||||||
|
{
|
||||||
|
buffer.append(TEXT[c]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape解码
|
||||||
|
*
|
||||||
|
* @param content 被转义的内容
|
||||||
|
* @return 解码后的字符串
|
||||||
|
*/
|
||||||
|
public static String decode(String content)
|
||||||
|
{
|
||||||
|
if (StringUtils.isEmpty(content))
|
||||||
|
{
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder tmp = new StringBuilder(content.length());
|
||||||
|
int lastPos = 0, pos = 0;
|
||||||
|
char ch;
|
||||||
|
while (lastPos < content.length())
|
||||||
|
{
|
||||||
|
pos = content.indexOf("%", lastPos);
|
||||||
|
if (pos == lastPos)
|
||||||
|
{
|
||||||
|
if (content.charAt(pos + 1) == 'u')
|
||||||
|
{
|
||||||
|
ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16);
|
||||||
|
tmp.append(ch);
|
||||||
|
lastPos = pos + 6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16);
|
||||||
|
tmp.append(ch);
|
||||||
|
lastPos = pos + 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pos == -1)
|
||||||
|
{
|
||||||
|
tmp.append(content.substring(lastPos));
|
||||||
|
lastPos = content.length();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp.append(content.substring(lastPos, pos));
|
||||||
|
lastPos = pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
String html = "<script>alert(1);</script>";
|
||||||
|
// String html = "<scr<script>ipt>alert(\"XSS\")</scr<script>ipt>";
|
||||||
|
// String html = "<123";
|
||||||
|
// String html = "123>";
|
||||||
|
System.out.println(EscapeUtil.clean(html));
|
||||||
|
System.out.println(EscapeUtil.escape(html));
|
||||||
|
System.out.println(EscapeUtil.unescape(html));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,570 @@
|
||||||
|
package com.ruoyi.common.core.utils.html;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML过滤器,用于去除XSS漏洞隐患。
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public final class HTMLFilter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* regex flag union representing /si modifiers in php
|
||||||
|
**/
|
||||||
|
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
|
||||||
|
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
|
||||||
|
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
|
||||||
|
private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
|
||||||
|
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
|
||||||
|
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
|
||||||
|
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
|
||||||
|
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
|
||||||
|
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
|
||||||
|
private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
|
||||||
|
private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
|
||||||
|
private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
|
||||||
|
private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
|
||||||
|
private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
|
||||||
|
private static final Pattern P_END_ARROW = Pattern.compile("^>");
|
||||||
|
private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||||
|
private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||||
|
private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||||
|
private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||||
|
private static final Pattern P_AMP = Pattern.compile("&");
|
||||||
|
private static final Pattern P_QUOTE = Pattern.compile("\"");
|
||||||
|
private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
|
||||||
|
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
|
||||||
|
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
|
||||||
|
|
||||||
|
// @xxx could grow large... maybe use sesat's ReferenceMap
|
||||||
|
private static final ConcurrentMap<String, Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>();
|
||||||
|
private static final ConcurrentMap<String, Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set of allowed html elements, along with allowed attributes for each element
|
||||||
|
**/
|
||||||
|
private final Map<String, List<String>> vAllowed;
|
||||||
|
/**
|
||||||
|
* counts of open tags for each (allowable) html element
|
||||||
|
**/
|
||||||
|
private final Map<String, Integer> vTagCounts = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* html elements which must always be self-closing (e.g. "<img />")
|
||||||
|
**/
|
||||||
|
private final String[] vSelfClosingTags;
|
||||||
|
/**
|
||||||
|
* html elements which must always have separate opening and closing tags (e.g. "<b></b>")
|
||||||
|
**/
|
||||||
|
private final String[] vNeedClosingTags;
|
||||||
|
/**
|
||||||
|
* set of disallowed html elements
|
||||||
|
**/
|
||||||
|
private final String[] vDisallowed;
|
||||||
|
/**
|
||||||
|
* attributes which should be checked for valid protocols
|
||||||
|
**/
|
||||||
|
private final String[] vProtocolAtts;
|
||||||
|
/**
|
||||||
|
* allowed protocols
|
||||||
|
**/
|
||||||
|
private final String[] vAllowedProtocols;
|
||||||
|
/**
|
||||||
|
* tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />")
|
||||||
|
**/
|
||||||
|
private final String[] vRemoveBlanks;
|
||||||
|
/**
|
||||||
|
* entities allowed within html markup
|
||||||
|
**/
|
||||||
|
private final String[] vAllowedEntities;
|
||||||
|
/**
|
||||||
|
* flag determining whether comments are allowed in input String.
|
||||||
|
*/
|
||||||
|
private final boolean stripComment;
|
||||||
|
private final boolean encodeQuotes;
|
||||||
|
/**
|
||||||
|
* flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "<b text </b>"
|
||||||
|
* becomes "<b> text </b>"). If set to false, unbalanced angle brackets will be html escaped.
|
||||||
|
*/
|
||||||
|
private final boolean alwaysMakeTags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
public HTMLFilter()
|
||||||
|
{
|
||||||
|
vAllowed = new HashMap<>();
|
||||||
|
|
||||||
|
final ArrayList<String> a_atts = new ArrayList<>();
|
||||||
|
a_atts.add("href");
|
||||||
|
a_atts.add("target");
|
||||||
|
vAllowed.put("a", a_atts);
|
||||||
|
|
||||||
|
final ArrayList<String> img_atts = new ArrayList<>();
|
||||||
|
img_atts.add("src");
|
||||||
|
img_atts.add("width");
|
||||||
|
img_atts.add("height");
|
||||||
|
img_atts.add("alt");
|
||||||
|
vAllowed.put("img", img_atts);
|
||||||
|
|
||||||
|
final ArrayList<String> no_atts = new ArrayList<>();
|
||||||
|
vAllowed.put("b", no_atts);
|
||||||
|
vAllowed.put("strong", no_atts);
|
||||||
|
vAllowed.put("i", no_atts);
|
||||||
|
vAllowed.put("em", no_atts);
|
||||||
|
|
||||||
|
vSelfClosingTags = new String[] { "img" };
|
||||||
|
vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" };
|
||||||
|
vDisallowed = new String[] {};
|
||||||
|
vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp.
|
||||||
|
vProtocolAtts = new String[] { "src", "href" };
|
||||||
|
vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" };
|
||||||
|
vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" };
|
||||||
|
stripComment = true;
|
||||||
|
encodeQuotes = true;
|
||||||
|
alwaysMakeTags = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map-parameter configurable constructor.
|
||||||
|
*
|
||||||
|
* @param conf map containing configuration. keys match field names.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public HTMLFilter(final Map<String, Object> conf)
|
||||||
|
{
|
||||||
|
|
||||||
|
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
|
||||||
|
assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
|
||||||
|
assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
|
||||||
|
assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
|
||||||
|
assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
|
||||||
|
assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
|
||||||
|
assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
|
||||||
|
assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
|
||||||
|
|
||||||
|
vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed"));
|
||||||
|
vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
|
||||||
|
vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
|
||||||
|
vDisallowed = (String[]) conf.get("vDisallowed");
|
||||||
|
vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
|
||||||
|
vProtocolAtts = (String[]) conf.get("vProtocolAtts");
|
||||||
|
vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
|
||||||
|
vAllowedEntities = (String[]) conf.get("vAllowedEntities");
|
||||||
|
stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
|
||||||
|
encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
|
||||||
|
alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reset()
|
||||||
|
{
|
||||||
|
vTagCounts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// my versions of some PHP library functions
|
||||||
|
public static String chr(final int decimal)
|
||||||
|
{
|
||||||
|
return String.valueOf((char) decimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String htmlSpecialChars(final String s)
|
||||||
|
{
|
||||||
|
String result = s;
|
||||||
|
result = regexReplace(P_AMP, "&", result);
|
||||||
|
result = regexReplace(P_QUOTE, """, result);
|
||||||
|
result = regexReplace(P_LEFT_ARROW, "<", result);
|
||||||
|
result = regexReplace(P_RIGHT_ARROW, ">", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given a user submitted input String, filter out any invalid or restricted html.
|
||||||
|
*
|
||||||
|
* @param input text (i.e. submitted by a user) than may contain html
|
||||||
|
* @return "clean" version of input, with only valid, whitelisted html elements allowed
|
||||||
|
*/
|
||||||
|
public String filter(final String input)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
String s = input;
|
||||||
|
|
||||||
|
s = escapeComments(s);
|
||||||
|
|
||||||
|
s = balanceHTML(s);
|
||||||
|
|
||||||
|
s = checkTags(s);
|
||||||
|
|
||||||
|
s = processRemoveBlanks(s);
|
||||||
|
|
||||||
|
// s = validateEntities(s);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlwaysMakeTags()
|
||||||
|
{
|
||||||
|
return alwaysMakeTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStripComments()
|
||||||
|
{
|
||||||
|
return stripComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String escapeComments(final String s)
|
||||||
|
{
|
||||||
|
final Matcher m = P_COMMENTS.matcher(s);
|
||||||
|
final StringBuffer buf = new StringBuffer();
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
final String match = m.group(1); // (.*?)
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String balanceHTML(String s)
|
||||||
|
{
|
||||||
|
if (alwaysMakeTags)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// try and form html
|
||||||
|
//
|
||||||
|
s = regexReplace(P_END_ARROW, "", s);
|
||||||
|
// 不追加结束标签
|
||||||
|
s = regexReplace(P_BODY_TO_END, "<$1>", s);
|
||||||
|
s = regexReplace(P_XML_CONTENT, "$1<$2", s);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// escape stray brackets
|
||||||
|
//
|
||||||
|
s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s);
|
||||||
|
s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s);
|
||||||
|
|
||||||
|
//
|
||||||
|
// the last regexp causes '<>' entities to appear
|
||||||
|
// (we need to do a lookahead assertion so that the last bracket can
|
||||||
|
// be used in the next pass of the regexp)
|
||||||
|
//
|
||||||
|
s = regexReplace(P_BOTH_ARROWS, "", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String checkTags(String s)
|
||||||
|
{
|
||||||
|
Matcher m = P_TAGS.matcher(s);
|
||||||
|
|
||||||
|
final StringBuffer buf = new StringBuffer();
|
||||||
|
while (m.find())
|
||||||
|
{
|
||||||
|
String replaceStr = m.group(1);
|
||||||
|
replaceStr = processTag(replaceStr);
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
|
||||||
|
// these get tallied in processTag
|
||||||
|
// (remember to reset before subsequent calls to filter method)
|
||||||
|
final StringBuilder sBuilder = new StringBuilder(buf.toString());
|
||||||
|
for (String key : vTagCounts.keySet())
|
||||||
|
{
|
||||||
|
for (int ii = 0; ii < vTagCounts.get(key); ii++)
|
||||||
|
{
|
||||||
|
sBuilder.append("</").append(key).append(">");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = sBuilder.toString();
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processRemoveBlanks(final String s)
|
||||||
|
{
|
||||||
|
String result = s;
|
||||||
|
for (String tag : vRemoveBlanks)
|
||||||
|
{
|
||||||
|
if (!P_REMOVE_PAIR_BLANKS.containsKey(tag))
|
||||||
|
{
|
||||||
|
P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
|
||||||
|
}
|
||||||
|
result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
|
||||||
|
if (!P_REMOVE_SELF_BLANKS.containsKey(tag))
|
||||||
|
{
|
||||||
|
P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
|
||||||
|
}
|
||||||
|
result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s)
|
||||||
|
{
|
||||||
|
Matcher m = regex_pattern.matcher(s);
|
||||||
|
return m.replaceAll(replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processTag(final String s)
|
||||||
|
{
|
||||||
|
// ending tags
|
||||||
|
Matcher m = P_END_TAG.matcher(s);
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
final String name = m.group(1).toLowerCase();
|
||||||
|
if (allowed(name))
|
||||||
|
{
|
||||||
|
if (false == inArray(name, vSelfClosingTags))
|
||||||
|
{
|
||||||
|
if (vTagCounts.containsKey(name))
|
||||||
|
{
|
||||||
|
vTagCounts.put(name, vTagCounts.get(name) - 1);
|
||||||
|
return "</" + name + ">";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// starting tags
|
||||||
|
m = P_START_TAG.matcher(s);
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
final String name = m.group(1).toLowerCase();
|
||||||
|
final String body = m.group(2);
|
||||||
|
String ending = m.group(3);
|
||||||
|
|
||||||
|
// debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
|
||||||
|
if (allowed(name))
|
||||||
|
{
|
||||||
|
final StringBuilder params = new StringBuilder();
|
||||||
|
|
||||||
|
final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
|
||||||
|
final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
|
||||||
|
final List<String> paramNames = new ArrayList<>();
|
||||||
|
final List<String> paramValues = new ArrayList<>();
|
||||||
|
while (m2.find())
|
||||||
|
{
|
||||||
|
paramNames.add(m2.group(1)); // ([a-z0-9]+)
|
||||||
|
paramValues.add(m2.group(3)); // (.*?)
|
||||||
|
}
|
||||||
|
while (m3.find())
|
||||||
|
{
|
||||||
|
paramNames.add(m3.group(1)); // ([a-z0-9]+)
|
||||||
|
paramValues.add(m3.group(3)); // ([^\"\\s']+)
|
||||||
|
}
|
||||||
|
|
||||||
|
String paramName, paramValue;
|
||||||
|
for (int ii = 0; ii < paramNames.size(); ii++)
|
||||||
|
{
|
||||||
|
paramName = paramNames.get(ii).toLowerCase();
|
||||||
|
paramValue = paramValues.get(ii);
|
||||||
|
|
||||||
|
// debug( "paramName='" + paramName + "'" );
|
||||||
|
// debug( "paramValue='" + paramValue + "'" );
|
||||||
|
// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
|
||||||
|
|
||||||
|
if (allowedAttribute(name, paramName))
|
||||||
|
{
|
||||||
|
if (inArray(paramName, vProtocolAtts))
|
||||||
|
{
|
||||||
|
paramValue = processParamProtocol(paramValue);
|
||||||
|
}
|
||||||
|
params.append(' ').append(paramName).append("=\"").append(paramValue).append("\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inArray(name, vSelfClosingTags))
|
||||||
|
{
|
||||||
|
ending = " /";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inArray(name, vNeedClosingTags))
|
||||||
|
{
|
||||||
|
ending = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ending == null || ending.length() < 1)
|
||||||
|
{
|
||||||
|
if (vTagCounts.containsKey(name))
|
||||||
|
{
|
||||||
|
vTagCounts.put(name, vTagCounts.get(name) + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vTagCounts.put(name, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ending = " /";
|
||||||
|
}
|
||||||
|
return "<" + name + params + ending + ">";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// comments
|
||||||
|
m = P_COMMENT.matcher(s);
|
||||||
|
if (!stripComment && m.find())
|
||||||
|
{
|
||||||
|
return "<" + m.group() + ">";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processParamProtocol(String s)
|
||||||
|
{
|
||||||
|
s = decodeEntities(s);
|
||||||
|
final Matcher m = P_PROTOCOL.matcher(s);
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
final String protocol = m.group(1);
|
||||||
|
if (!inArray(protocol, vAllowedProtocols))
|
||||||
|
{
|
||||||
|
// bad protocol, turn into local anchor link instead
|
||||||
|
s = "#" + s.substring(protocol.length() + 1);
|
||||||
|
if (s.startsWith("#//"))
|
||||||
|
{
|
||||||
|
s = "#" + s.substring(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String decodeEntities(String s)
|
||||||
|
{
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
|
Matcher m = P_ENTITY.matcher(s);
|
||||||
|
while (m.find())
|
||||||
|
{
|
||||||
|
final String match = m.group(1);
|
||||||
|
final int decimal = Integer.decode(match).intValue();
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
s = buf.toString();
|
||||||
|
|
||||||
|
buf = new StringBuffer();
|
||||||
|
m = P_ENTITY_UNICODE.matcher(s);
|
||||||
|
while (m.find())
|
||||||
|
{
|
||||||
|
final String match = m.group(1);
|
||||||
|
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
s = buf.toString();
|
||||||
|
|
||||||
|
buf = new StringBuffer();
|
||||||
|
m = P_ENCODE.matcher(s);
|
||||||
|
while (m.find())
|
||||||
|
{
|
||||||
|
final String match = m.group(1);
|
||||||
|
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
s = buf.toString();
|
||||||
|
|
||||||
|
s = validateEntities(s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String validateEntities(final String s)
|
||||||
|
{
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
|
// validate entities throughout the string
|
||||||
|
Matcher m = P_VALID_ENTITIES.matcher(s);
|
||||||
|
while (m.find())
|
||||||
|
{
|
||||||
|
final String one = m.group(1); // ([^&;]*)
|
||||||
|
final String two = m.group(2); // (?=(;|&|$))
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
|
||||||
|
return encodeQuotes(buf.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String encodeQuotes(final String s)
|
||||||
|
{
|
||||||
|
if (encodeQuotes)
|
||||||
|
{
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
Matcher m = P_VALID_QUOTES.matcher(s);
|
||||||
|
while (m.find())
|
||||||
|
{
|
||||||
|
final String one = m.group(1); // (>|^)
|
||||||
|
final String two = m.group(2); // ([^<]+?)
|
||||||
|
final String three = m.group(3); // (<|$)
|
||||||
|
// 不替换双引号为",防止json格式无效 regexReplace(P_QUOTE, """, two)
|
||||||
|
m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three));
|
||||||
|
}
|
||||||
|
m.appendTail(buf);
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String checkEntity(final String preamble, final String term)
|
||||||
|
{
|
||||||
|
|
||||||
|
return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidEntity(final String entity)
|
||||||
|
{
|
||||||
|
return inArray(entity, vAllowedEntities);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean inArray(final String s, final String[] array)
|
||||||
|
{
|
||||||
|
for (String item : array)
|
||||||
|
{
|
||||||
|
if (item != null && item.equals(s))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean allowed(final String name)
|
||||||
|
{
|
||||||
|
return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean allowedAttribute(final String name, final String paramName)
|
||||||
|
{
|
||||||
|
return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.common.log.service;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.system.api.RemoteLogService;
|
import com.ruoyi.system.api.RemoteLogService;
|
||||||
import com.ruoyi.system.api.domain.SysOperLog;
|
import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
|
|
||||||
|
|
@ -23,6 +24,6 @@ public class AsyncLogService
|
||||||
@Async
|
@Async
|
||||||
public void saveSysLog(SysOperLog sysOperLog)
|
public void saveSysLog(SysOperLog sysOperLog)
|
||||||
{
|
{
|
||||||
remoteLogService.saveLog(sysOperLog);
|
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.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,17 @@ public class RedisService
|
||||||
return redisTemplate.expire(key, timeout, unit);
|
return redisTemplate.expire(key, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 key是否存在
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public Boolean hasKey(String key)
|
||||||
|
{
|
||||||
|
return redisTemplate.hasKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的基本对象。
|
* 获得缓存的基本对象。
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.ruoyi.common.security.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部认证注解
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface InnerAuth
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 是否校验用户信息
|
||||||
|
*/
|
||||||
|
boolean isUser() default false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.ruoyi.common.security.aspect;
|
||||||
|
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.exception.InnerAuthException;
|
||||||
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部服务调用验证处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class InnerAuthAspect implements Ordered
|
||||||
|
{
|
||||||
|
@Around("@annotation(innerAuth)")
|
||||||
|
public Object innerAround(ProceedingJoinPoint point, InnerAuth innerAuth) throws Throwable
|
||||||
|
{
|
||||||
|
String source = ServletUtils.getRequest().getHeader(SecurityConstants.FROM_SOURCE);
|
||||||
|
// 内部请求验证
|
||||||
|
if (!StringUtils.equals(SecurityConstants.INNER, source))
|
||||||
|
{
|
||||||
|
throw new InnerAuthException("没有内部访问权限,不允许访问");
|
||||||
|
}
|
||||||
|
|
||||||
|
String userid = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID);
|
||||||
|
String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME);
|
||||||
|
// 用户信息验证
|
||||||
|
if (innerAuth.isUser() && (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)))
|
||||||
|
{
|
||||||
|
throw new InnerAuthException("没有设置用户信息,不允许访问 ");
|
||||||
|
}
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确保在权限认证aop执行前执行
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getOrder()
|
||||||
|
{
|
||||||
|
return Ordered.HIGHEST_PRECEDENCE + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,11 +2,11 @@ package com.ruoyi.common.security.feign;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.ip.IpUtils;
|
||||||
import feign.RequestInterceptor;
|
import feign.RequestInterceptor;
|
||||||
import feign.RequestTemplate;
|
import feign.RequestTemplate;
|
||||||
|
|
||||||
|
|
@ -26,20 +26,20 @@ public class FeignRequestInterceptor implements RequestInterceptor
|
||||||
{
|
{
|
||||||
Map<String, String> headers = ServletUtils.getHeaders(httpServletRequest);
|
Map<String, String> headers = ServletUtils.getHeaders(httpServletRequest);
|
||||||
// 传递用户信息请求头,防止丢失
|
// 传递用户信息请求头,防止丢失
|
||||||
String userId = headers.get(CacheConstants.DETAILS_USER_ID);
|
String userId = headers.get(SecurityConstants.DETAILS_USER_ID);
|
||||||
if (StringUtils.isNotEmpty(userId))
|
if (StringUtils.isNotEmpty(userId))
|
||||||
{
|
{
|
||||||
requestTemplate.header(CacheConstants.DETAILS_USER_ID, userId);
|
requestTemplate.header(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
}
|
}
|
||||||
String userName = headers.get(CacheConstants.DETAILS_USERNAME);
|
String userName = headers.get(SecurityConstants.DETAILS_USERNAME);
|
||||||
if (StringUtils.isNotEmpty(userName))
|
if (StringUtils.isNotEmpty(userName))
|
||||||
{
|
{
|
||||||
requestTemplate.header(CacheConstants.DETAILS_USERNAME, userName);
|
requestTemplate.header(SecurityConstants.DETAILS_USERNAME, userName);
|
||||||
}
|
}
|
||||||
String authentication = headers.get(CacheConstants.AUTHORIZATION_HEADER);
|
String authentication = headers.get(SecurityConstants.AUTHORIZATION_HEADER);
|
||||||
if (StringUtils.isNotEmpty(authentication))
|
if (StringUtils.isNotEmpty(authentication))
|
||||||
{
|
{
|
||||||
requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication);
|
requestTemplate.header(SecurityConstants.AUTHORIZATION_HEADER, authentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置客户端IP
|
// 配置客户端IP
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
import com.ruoyi.common.core.exception.BaseException;
|
import com.ruoyi.common.core.exception.BaseException;
|
||||||
import com.ruoyi.common.core.exception.CustomException;
|
import com.ruoyi.common.core.exception.CustomException;
|
||||||
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.PreAuthorizeException;
|
import com.ruoyi.common.core.exception.PreAuthorizeException;
|
||||||
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;
|
||||||
|
|
@ -73,7 +74,7 @@ public class GlobalExceptionHandler
|
||||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||||
return AjaxResult.error(message);
|
return AjaxResult.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限异常
|
* 权限异常
|
||||||
*/
|
*/
|
||||||
|
|
@ -82,7 +83,16 @@ public class GlobalExceptionHandler
|
||||||
{
|
{
|
||||||
return AjaxResult.error("没有权限,请联系管理员授权");
|
return AjaxResult.error("没有权限,请联系管理员授权");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部认证异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(InnerAuthException.class)
|
||||||
|
public AjaxResult InnerAuthException(InnerAuthException e)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 演示模式异常
|
* 演示模式异常
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,16 @@ public class TokenService
|
||||||
{
|
{
|
||||||
// 获取请求携带的令牌
|
// 获取请求携带的令牌
|
||||||
String token = SecurityUtils.getToken(request);
|
String token = SecurityUtils.getToken(request);
|
||||||
|
return getLoginUser(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户身份信息
|
||||||
|
*
|
||||||
|
* @return 用户信息
|
||||||
|
*/
|
||||||
|
public LoginUser getLoginUser(String token)
|
||||||
|
{
|
||||||
if (StringUtils.isNotEmpty(token))
|
if (StringUtils.isNotEmpty(token))
|
||||||
{
|
{
|
||||||
String userKey = getTokenKey(token);
|
String userKey = getTokenKey(token);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.ruoyi.common.security.service.TokenService,\
|
com.ruoyi.common.security.service.TokenService,\
|
||||||
com.ruoyi.common.security.aspect.PreAuthorizeAspect,\
|
com.ruoyi.common.security.aspect.PreAuthorizeAspect,\
|
||||||
|
com.ruoyi.common.security.aspect.InnerAuthAspect,\
|
||||||
com.ruoyi.common.security.handler.GlobalExceptionHandler
|
com.ruoyi.common.security.handler.GlobalExceptionHandler
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.ruoyi.gateway.config.properties;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码配置
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@RefreshScope
|
||||||
|
@ConfigurationProperties(prefix = "security.captcha")
|
||||||
|
public class CaptchaProperties
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 验证码开关
|
||||||
|
*/
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码类型(math 数组计算 char 字符)
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public Boolean getEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(Boolean enabled)
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@RefreshScope
|
@RefreshScope
|
||||||
@ConfigurationProperties(prefix = "ignore")
|
@ConfigurationProperties(prefix = "security.ignore")
|
||||||
public class IgnoreWhiteProperties
|
public class IgnoreWhiteProperties
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.ruoyi.gateway.config.properties;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XSS跨站脚本配置
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@RefreshScope
|
||||||
|
@ConfigurationProperties(prefix = "security.xss")
|
||||||
|
public class XssProperties
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Xss开关
|
||||||
|
*/
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排除路径
|
||||||
|
*/
|
||||||
|
private List<String> excludeUrls = new ArrayList<>();
|
||||||
|
|
||||||
|
public Boolean getEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(Boolean enabled)
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getExcludeUrls()
|
||||||
|
{
|
||||||
|
return excludeUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcludeUrls(List<String> excludeUrls)
|
||||||
|
{
|
||||||
|
this.excludeUrls = excludeUrls;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,19 +7,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
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.domain.R;
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
|
|
@ -35,7 +32,7 @@ import reactor.core.publisher.Mono;
|
||||||
public class AuthFilter implements GlobalFilter, Ordered
|
public class AuthFilter implements GlobalFilter, Ordered
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
||||||
|
|
||||||
private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60;
|
private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60;
|
||||||
|
|
||||||
// 排除过滤的 uri 地址,nacos自行添加
|
// 排除过滤的 uri 地址,nacos自行添加
|
||||||
|
|
@ -44,61 +41,75 @@ public class AuthFilter implements GlobalFilter, Ordered
|
||||||
|
|
||||||
@Resource(name = "stringRedisTemplate")
|
@Resource(name = "stringRedisTemplate")
|
||||||
private ValueOperations<String, String> sops;
|
private ValueOperations<String, String> sops;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
|
||||||
{
|
{
|
||||||
String url = exchange.getRequest().getURI().getPath();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
ServerHttpRequest.Builder mutate = request.mutate();
|
||||||
|
|
||||||
|
String url = request.getURI().getPath();
|
||||||
// 跳过不需要验证的路径
|
// 跳过不需要验证的路径
|
||||||
if (StringUtils.matches(url, ignoreWhite.getWhites()))
|
if (StringUtils.matches(url, ignoreWhite.getWhites()))
|
||||||
{
|
{
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
String token = getToken(exchange.getRequest());
|
String token = getToken(request);
|
||||||
if (StringUtils.isBlank(token))
|
if (StringUtils.isEmpty(token))
|
||||||
{
|
{
|
||||||
return setUnauthorizedResponse(exchange, "令牌不能为空");
|
return unauthorizedResponse(exchange, "令牌不能为空");
|
||||||
}
|
}
|
||||||
String userStr = sops.get(getTokenKey(token));
|
String userStr = sops.get(getTokenKey(token));
|
||||||
if (StringUtils.isNull(userStr))
|
if (StringUtils.isEmpty(userStr))
|
||||||
{
|
{
|
||||||
return setUnauthorizedResponse(exchange, "登录状态已过期");
|
return unauthorizedResponse(exchange, "登录状态已过期");
|
||||||
}
|
}
|
||||||
JSONObject obj = JSONObject.parseObject(userStr);
|
JSONObject cacheObj = JSONObject.parseObject(userStr);
|
||||||
String userid = obj.getString("userid");
|
String userid = cacheObj.getString("userid");
|
||||||
String username = obj.getString("username");
|
String username = cacheObj.getString("username");
|
||||||
if (StringUtils.isBlank(userid) || StringUtils.isBlank(username))
|
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username))
|
||||||
{
|
{
|
||||||
return setUnauthorizedResponse(exchange, "令牌验证失败");
|
return unauthorizedResponse(exchange, "令牌验证失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置过期时间
|
// 设置过期时间
|
||||||
redisService.expire(getTokenKey(token), EXPIRE_TIME);
|
redisService.expire(getTokenKey(token), EXPIRE_TIME);
|
||||||
// 设置用户信息到请求
|
// 设置用户信息到请求
|
||||||
ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid)
|
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
||||||
.header(CacheConstants.DETAILS_USERNAME, ServletUtils.urlEncode(username)).build();
|
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
||||||
ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build();
|
// 内部请求来源参数清除
|
||||||
|
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
||||||
return chain.filter(mutableExchange);
|
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mono<Void> setUnauthorizedResponse(ServerWebExchange exchange, String msg)
|
private void addHeader(ServerHttpRequest.Builder mutate, String name, Object value)
|
||||||
{
|
{
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
if (value == null)
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
{
|
||||||
response.setStatusCode(HttpStatus.OK);
|
return;
|
||||||
|
}
|
||||||
log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
|
String valueStr = value.toString();
|
||||||
|
String valueEncode = ServletUtils.urlEncode(valueStr);
|
||||||
return response.writeWith(Mono.fromSupplier(() -> {
|
mutate.header(name, valueEncode);
|
||||||
DataBufferFactory bufferFactory = response.bufferFactory();
|
|
||||||
return bufferFactory.wrap(JSON.toJSONBytes(R.fail(HttpStatus.UNAUTHORIZED.value(), msg)));
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeHeader(ServerHttpRequest.Builder mutate, String name)
|
||||||
|
{
|
||||||
|
mutate.headers(httpHeaders -> httpHeaders.remove(name)).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<Void> unauthorizedResponse(ServerWebExchange exchange, String msg)
|
||||||
|
{
|
||||||
|
log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
|
||||||
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), msg, HttpStatus.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存key
|
||||||
|
*/
|
||||||
private String getTokenKey(String token)
|
private String getTokenKey(String token)
|
||||||
{
|
{
|
||||||
return CacheConstants.LOGIN_TOKEN_KEY + token;
|
return CacheConstants.LOGIN_TOKEN_KEY + token;
|
||||||
|
|
@ -109,12 +120,8 @@ public class AuthFilter implements GlobalFilter, Ordered
|
||||||
*/
|
*/
|
||||||
private String getToken(ServerHttpRequest request)
|
private String getToken(ServerHttpRequest request)
|
||||||
{
|
{
|
||||||
String token = request.getHeaders().getFirst(CacheConstants.HEADER);
|
String token = request.getHeaders().getFirst(SecurityConstants.TOKEN_AUTHENTICATION);
|
||||||
if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX))
|
return SecurityUtils.replaceTokenPrefix(token);
|
||||||
{
|
|
||||||
token = token.replace(CacheConstants.TOKEN_PREFIX, "");
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,8 @@ import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 黑名单过滤器
|
* 黑名单过滤器
|
||||||
|
|
@ -27,10 +24,7 @@ public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUr
|
||||||
String url = exchange.getRequest().getURI().getPath();
|
String url = exchange.getRequest().getURI().getPath();
|
||||||
if (config.matchBlacklist(url))
|
if (config.matchBlacklist(url))
|
||||||
{
|
{
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求地址不允许访问");
|
||||||
response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
|
|
||||||
return exchange.getResponse().writeWith(
|
|
||||||
Mono.just(response.bufferFactory().wrap(JSON.toJSONBytes(AjaxResult.error("请求地址不允许访问")))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@ import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取body请求数据(解决流不能重复读取问题)
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheRequestFilter.Config>
|
public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheRequestFilter.Config>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,13 @@ import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFac
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
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.web.domain.AjaxResult;
|
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
||||||
import com.ruoyi.gateway.service.ValidateCodeService;
|
import com.ruoyi.gateway.service.ValidateCodeService;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码过滤器
|
* 验证码过滤器
|
||||||
|
|
@ -27,11 +25,14 @@ import reactor.core.publisher.Mono;
|
||||||
@Component
|
@Component
|
||||||
public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
{
|
{
|
||||||
private final static String AUTH_URL = "/auth/login";
|
private final static String[] VALIDATE_URL = new String[] { "/auth/login", "/auth/register" };
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CaptchaProperties captchaProperties;
|
||||||
|
|
||||||
private static final String CODE = "code";
|
private static final String CODE = "code";
|
||||||
|
|
||||||
private static final String UUID = "uuid";
|
private static final String UUID = "uuid";
|
||||||
|
|
@ -42,8 +43,8 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
return (exchange, chain) -> {
|
return (exchange, chain) -> {
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
|
||||||
// 非登录请求,不处理
|
// 非登录/注册请求或验证码关闭,不处理
|
||||||
if (!StringUtils.containsIgnoreCase(request.getURI().getPath(), AUTH_URL))
|
if (!StringUtils.containsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL) || !captchaProperties.getEnabled())
|
||||||
{
|
{
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
|
|
@ -56,10 +57,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage());
|
||||||
response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
|
|
||||||
return exchange.getResponse().writeWith(
|
|
||||||
Mono.just(response.bufferFactory().wrap(JSON.toJSONBytes(AjaxResult.error(e.getMessage())))));
|
|
||||||
}
|
}
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.ruoyi.gateway.filter;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
|
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.html.EscapeUtil;
|
||||||
|
import com.ruoyi.gateway.config.properties.XssProperties;
|
||||||
|
import io.netty.buffer.ByteBufAllocator;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跨站脚本过滤器
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
|
||||||
|
public class XssFilter implements GlobalFilter, Ordered
|
||||||
|
{
|
||||||
|
// 跨站脚本的 xss 配置,nacos自行添加
|
||||||
|
@Autowired
|
||||||
|
private XssProperties xss;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
|
||||||
|
{
|
||||||
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
// GET DELETE 不过滤
|
||||||
|
HttpMethod method = request.getMethod();
|
||||||
|
if (method == null || method.matches("GET") || method.matches("DELETE"))
|
||||||
|
{
|
||||||
|
return chain.filter(exchange);
|
||||||
|
}
|
||||||
|
// 非json类型,不过滤
|
||||||
|
if (!isJsonRequest(exchange))
|
||||||
|
{
|
||||||
|
return chain.filter(exchange);
|
||||||
|
}
|
||||||
|
// excludeUrls 不过滤
|
||||||
|
String url = request.getURI().getPath();
|
||||||
|
if (StringUtils.matches(url, xss.getExcludeUrls()))
|
||||||
|
{
|
||||||
|
return chain.filter(exchange);
|
||||||
|
}
|
||||||
|
ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange);
|
||||||
|
return chain.filter(exchange.mutate().request(httpRequestDecorator).build());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServerHttpRequestDecorator requestDecorator(ServerWebExchange exchange)
|
||||||
|
{
|
||||||
|
ServerHttpRequestDecorator serverHttpRequestDecorator = new ServerHttpRequestDecorator(exchange.getRequest())
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Flux<DataBuffer> getBody()
|
||||||
|
{
|
||||||
|
Flux<DataBuffer> body = super.getBody();
|
||||||
|
return body.map(dataBuffer -> {
|
||||||
|
byte[] content = new byte[dataBuffer.readableByteCount()];
|
||||||
|
dataBuffer.read(content);
|
||||||
|
DataBufferUtils.release(dataBuffer);
|
||||||
|
String bodyStr = new String(content, StandardCharsets.UTF_8);
|
||||||
|
// 防xss攻击过滤
|
||||||
|
bodyStr = EscapeUtil.clean(bodyStr);
|
||||||
|
// 转成字节
|
||||||
|
byte[] bytes = bodyStr.getBytes();
|
||||||
|
NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT);
|
||||||
|
DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length);
|
||||||
|
buffer.write(bytes);
|
||||||
|
return buffer;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpHeaders getHeaders()
|
||||||
|
{
|
||||||
|
HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
|
httpHeaders.putAll(super.getHeaders());
|
||||||
|
// 由于修改了请求体的body,导致content-length长度不确定,因此需要删除原先的content-length
|
||||||
|
httpHeaders.remove(HttpHeaders.CONTENT_LENGTH);
|
||||||
|
httpHeaders.set(HttpHeaders.TRANSFER_ENCODING, "chunked");
|
||||||
|
return httpHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
return serverHttpRequestDecorator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是Json请求
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*/
|
||||||
|
public boolean isJsonRequest(ServerWebExchange exchange)
|
||||||
|
{
|
||||||
|
String header = exchange.getRequest().getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
|
||||||
|
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder()
|
||||||
|
{
|
||||||
|
return -100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,14 +6,10 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
|
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,12 +51,6 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler
|
||||||
|
|
||||||
log.error("[网关异常处理]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), ex.getMessage());
|
log.error("[网关异常处理]请求路径:{},异常信息:{}", exchange.getRequest().getPath(), ex.getMessage());
|
||||||
|
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
return ServletUtils.webFluxResponseWriter(response, msg);
|
||||||
response.setStatusCode(HttpStatus.OK);
|
|
||||||
|
|
||||||
return response.writeWith(Mono.fromSupplier(() -> {
|
|
||||||
DataBufferFactory bufferFactory = response.bufferFactory();
|
|
||||||
return bufferFactory.wrap(JSON.toJSONBytes(R.fail(msg)));
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
package com.ruoyi.gateway.handler;
|
package com.ruoyi.gateway.handler;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
||||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import org.springframework.web.server.WebExceptionHandler;
|
import org.springframework.web.server.WebExceptionHandler;
|
||||||
|
|
@ -19,11 +17,7 @@ public class SentinelFallbackHandler implements WebExceptionHandler
|
||||||
{
|
{
|
||||||
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange)
|
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange)
|
||||||
{
|
{
|
||||||
ServerHttpResponse serverHttpResponse = exchange.getResponse();
|
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍后再试");
|
||||||
serverHttpResponse.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
|
|
||||||
byte[] datas = "{\"code\":429,\"msg\":\"请求超过最大数,请稍后再试\"}".getBytes(StandardCharsets.UTF_8);
|
|
||||||
DataBuffer buffer = serverHttpResponse.bufferFactory().wrap(datas);
|
|
||||||
return serverHttpResponse.writeWith(Mono.just(buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.sign.Base64;
|
import com.ruoyi.common.core.utils.sign.Base64;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
|
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
||||||
import com.ruoyi.gateway.service.ValidateCodeService;
|
import com.ruoyi.gateway.service.ValidateCodeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,8 +36,8 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
// 验证码类型
|
@Autowired
|
||||||
private String captchaType = "math";
|
private CaptchaProperties captchaProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成验证码
|
* 生成验证码
|
||||||
|
|
@ -44,6 +45,14 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult createCapcha() throws IOException, CaptchaException
|
public AjaxResult createCapcha() throws IOException, CaptchaException
|
||||||
{
|
{
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
boolean captchaOnOff = captchaProperties.getEnabled();
|
||||||
|
ajax.put("captchaOnOff", captchaOnOff);
|
||||||
|
if (!captchaOnOff)
|
||||||
|
{
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtils.simpleUUID();
|
String uuid = IdUtils.simpleUUID();
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
|
|
@ -51,6 +60,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||||
String capStr = null, code = null;
|
String capStr = null, code = null;
|
||||||
BufferedImage image = null;
|
BufferedImage image = null;
|
||||||
|
|
||||||
|
String captchaType = captchaProperties.getType();
|
||||||
// 生成验证码
|
// 生成验证码
|
||||||
if ("math".equals(captchaType))
|
if ("math".equals(captchaType))
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +87,6 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid", uuid);
|
||||||
ajax.put("img", Base64.encode(os.toByteArray()));
|
ajax.put("img", Base64.encode(os.toByteArray()));
|
||||||
return ajax;
|
return ajax;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.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.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.file.config;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
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;
|
||||||
|
|
||||||
|
|
@ -33,4 +34,17 @@ public class ResourcesConfig implements WebMvcConfigurer
|
||||||
registry.addResourceHandler(localFilePrefix + "/**")
|
registry.addResourceHandler(localFilePrefix + "/**")
|
||||||
.addResourceLocations("file:" + localFilePath + File.separator);
|
.addResourceLocations("file:" + localFilePath + File.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启跨域
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
// 设置允许跨域的路由
|
||||||
|
registry.addMapping(localFilePrefix + "/**")
|
||||||
|
// 设置允许跨域请求的域名
|
||||||
|
.allowedOrigins("*")
|
||||||
|
// 设置允许的方法
|
||||||
|
.allowedMethods("GET");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,8 @@ public class VelocityUtils
|
||||||
*/
|
*/
|
||||||
public static String getParentMenuId(JSONObject paramsObj)
|
public static String getParentMenuId(JSONObject paramsObj)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
|
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
|
||||||
|
&& StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID)))
|
||||||
{
|
{
|
||||||
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
|
return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -111,6 +111,6 @@ public class ${ClassName}Controller extends BaseController
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
|
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ public interface ${ClassName}Mapper
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}
|
* 查询${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
*/
|
*/
|
||||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
|
|
@ -49,27 +49,27 @@ public interface ${ClassName}Mapper
|
||||||
/**
|
/**
|
||||||
* 删除${functionName}
|
* 删除${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除${functionName}
|
* 批量删除${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除${subTable.functionName}
|
* 批量删除${subTable.functionName}
|
||||||
*
|
*
|
||||||
* @param customerIds 需要删除的数据ID
|
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
public int delete${subClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增${subTable.functionName}
|
* 批量新增${subTable.functionName}
|
||||||
|
|
@ -81,7 +81,7 @@ public interface ${ClassName}Mapper
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过${functionName}ID删除${subTable.functionName}信息
|
* 通过${functionName}主键删除${subTable.functionName}信息
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ public interface I${ClassName}Service
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}
|
* 查询${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
*/
|
*/
|
||||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
|
|
@ -46,16 +46,16 @@ public interface I${ClassName}Service
|
||||||
/**
|
/**
|
||||||
* 批量删除${functionName}
|
* 批量删除${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除${functionName}信息
|
* 删除${functionName}信息
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,13 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}
|
* 查询${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField});
|
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -108,34 +108,34 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||||
/**
|
/**
|
||||||
* 批量删除${functionName}
|
* 批量删除${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
@Transactional
|
@Transactional
|
||||||
#end
|
#end
|
||||||
@Override
|
@Override
|
||||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||||
#end
|
#end
|
||||||
return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除${functionName}信息
|
* 删除${functionName}信息
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||||
#end
|
#end
|
||||||
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
|
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||||
}
|
}
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||||
public void insert${subClassName}(${ClassName} ${className})
|
public void insert${subClassName}(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||||
Long ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||||
if (StringUtils.isNotNull(${subclassName}List))
|
if (StringUtils.isNotNull(${subclassName}List))
|
||||||
{
|
{
|
||||||
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||||
#if($table.crud || $table.tree)
|
#if($table.crud || $table.tree)
|
||||||
<include refid="select${ClassName}Vo"/>
|
<include refid="select${ClassName}Vo"/>
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
|
|
@ -102,11 +102,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="delete${ClassName}ById" parameterType="${pkColumn.javaType}">
|
<delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
|
||||||
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="delete${ClassName}ByIds" parameterType="String">
|
<delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
|
||||||
delete from ${tableName} where ${pkColumn.columnName} in
|
delete from ${tableName} where ${pkColumn.columnName} in
|
||||||
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
||||||
#{${pkColumn.javaField}}
|
#{${pkColumn.javaField}}
|
||||||
|
|
@ -121,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="Long">
|
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
|
||||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.exception.job.TaskException;
|
import com.ruoyi.common.core.exception.job.TaskException;
|
||||||
import com.ruoyi.common.core.utils.SecurityUtils;
|
import com.ruoyi.common.core.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
|
@ -79,14 +81,22 @@ public class SysJobController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "monitor:job:add")
|
@PreAuthorize(hasPermi = "monitor:job:add")
|
||||||
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException
|
||||||
{
|
{
|
||||||
if (!CronUtils.isValid(sysJob.getCronExpression()))
|
if (!CronUtils.isValid(job.getCronExpression()))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("cron表达式不正确");
|
return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确");
|
||||||
}
|
}
|
||||||
sysJob.setCreateBy(SecurityUtils.getUsername());
|
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
||||||
return toAjax(jobService.insertJob(sysJob));
|
{
|
||||||
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
||||||
|
}
|
||||||
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
||||||
|
{
|
||||||
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
||||||
|
}
|
||||||
|
job.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(jobService.insertJob(job));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -95,14 +105,22 @@ public class SysJobController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "monitor:job:edit")
|
@PreAuthorize(hasPermi = "monitor:job:edit")
|
||||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException
|
||||||
{
|
{
|
||||||
if (!CronUtils.isValid(sysJob.getCronExpression()))
|
if (!CronUtils.isValid(job.getCronExpression()))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("cron表达式不正确");
|
return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确");
|
||||||
}
|
}
|
||||||
sysJob.setUpdateBy(SecurityUtils.getUsername());
|
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
||||||
return toAjax(jobService.updateJob(sysJob));
|
{
|
||||||
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
||||||
|
}
|
||||||
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
||||||
|
{
|
||||||
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
||||||
|
}
|
||||||
|
job.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(jobService.updateJob(job));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,20 +8,18 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
import com.ruoyi.common.security.annotation.PreAuthorize;
|
import com.ruoyi.common.security.annotation.PreAuthorize;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,26 +70,10 @@ public class SysLogininforController extends BaseController
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InnerAuth
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestParam("username") String username, @RequestParam("status") String status,
|
public AjaxResult add(@RequestBody SysLogininfor logininfor)
|
||||||
@RequestParam("message") String message)
|
|
||||||
{
|
{
|
||||||
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
|
||||||
|
|
||||||
// 封装对象
|
|
||||||
SysLogininfor logininfor = new SysLogininfor();
|
|
||||||
logininfor.setUserName(username);
|
|
||||||
logininfor.setIpaddr(ip);
|
|
||||||
logininfor.setMsg(message);
|
|
||||||
// 日志状态
|
|
||||||
if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status))
|
|
||||||
{
|
|
||||||
logininfor.setStatus("0");
|
|
||||||
}
|
|
||||||
else if (Constants.LOGIN_FAIL.equals(status))
|
|
||||||
{
|
|
||||||
logininfor.setStatus("1");
|
|
||||||
}
|
|
||||||
return toAjax(logininforService.insertLogininfor(logininfor));
|
return toAjax(logininforService.insertLogininfor(logininfor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
import com.ruoyi.common.security.annotation.PreAuthorize;
|
import com.ruoyi.common.security.annotation.PreAuthorize;
|
||||||
import com.ruoyi.system.api.domain.SysOperLog;
|
import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.system.service.ISysOperLogService;
|
||||||
|
|
@ -69,6 +70,7 @@ public class SysOperlogController extends BaseController
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InnerAuth
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody SysOperLog operLog)
|
public AjaxResult add(@RequestBody SysOperLog operLog)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,12 @@ public class SysProfileController extends BaseController
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
|
LoginUser loginUser = tokenService.getLoginUser();
|
||||||
|
SysUser sysUser = loginUser.getSysUser();
|
||||||
|
user.setUserId(sysUser.getUserId());
|
||||||
|
user.setPassword(null);
|
||||||
if (userService.updateUserProfile(user) > 0)
|
if (userService.updateUserProfile(user) > 0)
|
||||||
{
|
{
|
||||||
LoginUser loginUser = tokenService.getLoginUser();
|
|
||||||
// 更新缓存用户信息
|
// 更新缓存用户信息
|
||||||
loginUser.getSysUser().setNickName(user.getNickName());
|
loginUser.getSysUser().setNickName(user.getNickName());
|
||||||
loginUser.getSysUser().setPhonenumber(user.getPhonenumber());
|
loginUser.getSysUser().setPhonenumber(user.getPhonenumber());
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
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.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
@ -26,10 +27,12 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
import com.ruoyi.common.security.annotation.PreAuthorize;
|
import com.ruoyi.common.security.annotation.PreAuthorize;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
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;
|
||||||
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import com.ruoyi.system.service.ISysPermissionService;
|
import com.ruoyi.system.service.ISysPermissionService;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
|
|
@ -56,6 +59,9 @@ public class SysUserController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPermissionService permissionService;
|
private ISysPermissionService permissionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysConfigService configService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -100,6 +106,7 @@ public class SysUserController extends BaseController
|
||||||
/**
|
/**
|
||||||
* 获取当前用户信息
|
* 获取当前用户信息
|
||||||
*/
|
*/
|
||||||
|
@InnerAuth
|
||||||
@GetMapping("/info/{username}")
|
@GetMapping("/info/{username}")
|
||||||
public R<LoginUser> info(@PathVariable("username") String username)
|
public R<LoginUser> info(@PathVariable("username") String username)
|
||||||
{
|
{
|
||||||
|
|
@ -119,6 +126,25 @@ public class SysUserController extends BaseController
|
||||||
return R.ok(sysUserVo);
|
return R.ok(sysUserVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户信息
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@PostMapping("/register")
|
||||||
|
public R<Boolean> register(@RequestBody SysUser sysUser)
|
||||||
|
{
|
||||||
|
String username = sysUser.getUserName();
|
||||||
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||||
|
{
|
||||||
|
return R.fail("当前系统没有开启注册功能!");
|
||||||
|
}
|
||||||
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
|
||||||
|
{
|
||||||
|
return R.fail("保存用户'" + username + "'失败,注册账号已存在");
|
||||||
|
}
|
||||||
|
return R.ok(userService.registerUser(sysUser));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*
|
*
|
||||||
|
|
@ -217,6 +243,10 @@ public class SysUserController extends BaseController
|
||||||
@DeleteMapping("/{userIds}")
|
@DeleteMapping("/{userIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||||
{
|
{
|
||||||
|
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId()))
|
||||||
|
{
|
||||||
|
return AjaxResult.error("当前用户不能删除");
|
||||||
|
}
|
||||||
return toAjax(userService.deleteUserByIds(userIds));
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统访问日志情况信息 数据层
|
* 系统访问日志情况信息 数据层
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统访问日志情况信息 服务层
|
* 系统访问日志情况信息 服务层
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,14 @@ public interface ISysUserService
|
||||||
*/
|
*/
|
||||||
public int insertUser(SysUser user);
|
public int insertUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean registerUser(SysUser user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||||
}
|
}
|
||||||
int result = deptMapper.updateDept(dept);
|
int result = deptMapper.updateDept(dept);
|
||||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
|
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||||
|
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||||
{
|
{
|
||||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||||
updateParentDeptStatusNormal(dept);
|
updateParentDeptStatusNormal(dept);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.ruoyi.system.service.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.mapper.SysLogininforMapper;
|
import com.ruoyi.system.mapper.SysLogininforMapper;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,17 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean registerUser(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.insertUser(user) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存用户信息
|
* 修改保存用户信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ruoyi",
|
"name": "ruoyi",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"description": "若依管理系统",
|
"description": "若依管理系统",
|
||||||
"author": "若依",
|
"author": "若依",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,18 @@ export function login(username, password, code, uuid) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册方法
|
||||||
|
export function register(data) {
|
||||||
|
return request({
|
||||||
|
url: '/auth/register',
|
||||||
|
headers: {
|
||||||
|
isToken: false
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 刷新方法
|
// 刷新方法
|
||||||
export function refreshToken() {
|
export function refreshToken() {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import Layout from '@/layout'
|
||||||
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
||||||
icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
|
icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
|
||||||
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
||||||
|
activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -42,6 +43,11 @@ export const constantRoutes = [
|
||||||
component: (resolve) => require(['@/views/login'], resolve),
|
component: (resolve) => require(['@/views/login'], resolve),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/register',
|
||||||
|
component: (resolve) => require(['@/views/register'], resolve),
|
||||||
|
hidden: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/404',
|
path: '/404',
|
||||||
component: (resolve) => require(['@/views/error/404'], resolve),
|
component: (resolve) => require(['@/views/error/404'], resolve),
|
||||||
|
|
@ -80,7 +86,7 @@ export const constantRoutes = [
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/auth',
|
path: '/system/user-auth',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -88,12 +94,12 @@ export const constantRoutes = [
|
||||||
path: 'role/:userId(\\d+)',
|
path: 'role/:userId(\\d+)',
|
||||||
component: (resolve) => require(['@/views/system/user/authRole'], resolve),
|
component: (resolve) => require(['@/views/system/user/authRole'], resolve),
|
||||||
name: 'AuthRole',
|
name: 'AuthRole',
|
||||||
meta: { title: '分配角色'}
|
meta: { title: '分配角色', activeMenu: '/system/user'}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/auth',
|
path: '/system/role-auth',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -101,46 +107,46 @@ export const constantRoutes = [
|
||||||
path: 'user/:roleId(\\d+)',
|
path: 'user/:roleId(\\d+)',
|
||||||
component: (resolve) => require(['@/views/system/role/authUser'], resolve),
|
component: (resolve) => require(['@/views/system/role/authUser'], resolve),
|
||||||
name: 'AuthUser',
|
name: 'AuthUser',
|
||||||
meta: { title: '分配用户'}
|
meta: { title: '分配用户', activeMenu: '/system/role'}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/dict',
|
path: '/system/dict-data',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'type/data/:dictId(\\d+)',
|
path: 'index/:dictId(\\d+)',
|
||||||
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
||||||
name: 'Data',
|
name: 'Data',
|
||||||
meta: { title: '字典数据', icon: '' }
|
meta: { title: '字典数据', activeMenu: '/system/dict'}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/job',
|
path: '/monitor/job-log',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'log',
|
path: 'index',
|
||||||
component: (resolve) => require(['@/views/monitor/job/log'], resolve),
|
component: (resolve) => require(['@/views/monitor/job/log'], resolve),
|
||||||
name: 'JobLog',
|
name: 'JobLog',
|
||||||
meta: { title: '调度日志' }
|
meta: { title: '调度日志', activeMenu: '/monitor/job'}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/gen',
|
path: '/tool/gen-edit',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'edit/:tableId(\\d+)',
|
path: 'index/:tableId(\\d+)',
|
||||||
component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
|
component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
|
||||||
name: 'GenEdit',
|
name: 'GenEdit',
|
||||||
meta: { title: '修改生成配置' }
|
meta: { title: '修改生成配置', activeMenu: '/tool/gen'}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,22 +23,7 @@ service.interceptors.request.use(config => {
|
||||||
}
|
}
|
||||||
// get请求映射params参数
|
// get请求映射params参数
|
||||||
if (config.method === 'get' && config.params) {
|
if (config.method === 'get' && config.params) {
|
||||||
let url = config.url + '?';
|
let url = config.url + '?' + tansParams(config.params);
|
||||||
for (const propName of Object.keys(config.params)) {
|
|
||||||
const value = config.params[propName];
|
|
||||||
var part = encodeURIComponent(propName) + "=";
|
|
||||||
if (value !== null && typeof(value) !== "undefined") {
|
|
||||||
if (typeof value === 'object') {
|
|
||||||
for (const key of Object.keys(value)) {
|
|
||||||
let params = propName + '[' + key + ']';
|
|
||||||
var subPart = encodeURIComponent(params) + "=";
|
|
||||||
url += subPart + encodeURIComponent(value[key]) + "&";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
url += part + encodeURIComponent(value) + "&";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = url.slice(0, -1);
|
url = url.slice(0, -1);
|
||||||
config.params = {};
|
config.params = {};
|
||||||
config.url = url;
|
config.url = url;
|
||||||
|
|
@ -66,7 +51,7 @@ service.interceptors.response.use(res => {
|
||||||
location.href = '/index';
|
location.href = '/index';
|
||||||
})
|
})
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
return Promise.reject('error')
|
return Promise.reject()
|
||||||
} else if (code === 500) {
|
} else if (code === 500) {
|
||||||
Message({
|
Message({
|
||||||
message: msg,
|
message: msg,
|
||||||
|
|
|
||||||
|
|
@ -179,11 +179,21 @@ export function handleTree(data, id, parentId, children) {
|
||||||
* @param {*} params 参数
|
* @param {*} params 参数
|
||||||
*/
|
*/
|
||||||
export function tansParams(params) {
|
export function tansParams(params) {
|
||||||
let result = ''
|
let result = ''
|
||||||
Object.keys(params).forEach((key) => {
|
for (const propName of Object.keys(params)) {
|
||||||
if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) {
|
const value = params[propName];
|
||||||
result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + '&'
|
var part = encodeURIComponent(propName) + "=";
|
||||||
}
|
if (value !== null && typeof(value) !== "undefined") {
|
||||||
})
|
if (typeof value === 'object') {
|
||||||
return result
|
for (const key of Object.keys(value)) {
|
||||||
|
let params = propName + '[' + key + ']';
|
||||||
|
var subPart = encodeURIComponent(params) + "=";
|
||||||
|
result += subPart + encodeURIComponent(value[key]) + "&";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result += part + encodeURIComponent(value) + "&";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,11 @@ export function resolveBlob(res, mimeType) {
|
||||||
var result = patt.exec(contentDisposition)
|
var result = patt.exec(contentDisposition)
|
||||||
var fileName = result[1]
|
var fileName = result[1]
|
||||||
fileName = fileName.replace(/\"/g, '')
|
fileName = fileName.replace(/\"/g, '')
|
||||||
|
aLink.style.display = 'none'
|
||||||
aLink.href = URL.createObjectURL(blob)
|
aLink.href = URL.createObjectURL(blob)
|
||||||
aLink.setAttribute('download', fileName) // 设置下载文件名称
|
aLink.setAttribute('download', fileName) // 设置下载文件名称
|
||||||
document.body.appendChild(aLink)
|
document.body.appendChild(aLink)
|
||||||
aLink.click()
|
aLink.click()
|
||||||
|
URL.revokeObjectURL(aLink.href);//清除引用
|
||||||
document.body.removeChild(aLink);
|
document.body.removeChild(aLink);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,9 +119,9 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<i class="el-icon-user-solid"></i> QQ群:<s>满42799195</s>
|
<i class="el-icon-user-solid"></i> QQ群:<s>满42799195</s>
|
||||||
<s>满170157040</s> <s>满130643120</s>
|
<s>满170157040</s> <s>满130643120</s> <s>满225920371</s>
|
||||||
<a href="https://jq.qq.com/?_wv=1027&k=0Ck3PvTe" target="_blank">
|
<a href="https://jq.qq.com/?_wv=1027&k=Kg9CdVdx" target="_blank">
|
||||||
225920371</a
|
201705537</a
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -146,6 +146,61 @@
|
||||||
<span>更新日志</span>
|
<span>更新日志</span>
|
||||||
</div>
|
</div>
|
||||||
<el-collapse accordion>
|
<el-collapse accordion>
|
||||||
|
<el-collapse-item title="v3.1.0 - 2021-08-02">
|
||||||
|
<ol>
|
||||||
|
<li>支持配置XSS跨站脚本过滤</li>
|
||||||
|
<li>支持配置验证码开关&类型</li>
|
||||||
|
<li>新增是否开启用户注册功能</li>
|
||||||
|
<li>用户管理新增分配角色功能</li>
|
||||||
|
<li>角色管理新增分配用户功能</li>
|
||||||
|
<li>系统布局配置支持动态标题开关</li>
|
||||||
|
<li>增加字典标签样式回显dict组件</li>
|
||||||
|
<li>FileUpload组件支持多文件上传</li>
|
||||||
|
<li>ImageUpload组件支持多图片上传</li>
|
||||||
|
<li>封装通用iframe组件</li>
|
||||||
|
<li>菜单路由配置支持内链访问</li>
|
||||||
|
<li>全局注册通用组件</li>
|
||||||
|
<li>富文本默认上传返回url类型</li>
|
||||||
|
<li>富文本新增上传文件大小限制</li>
|
||||||
|
<li>增加自定义弹窗拖拽指令</li>
|
||||||
|
<li>顶部菜单排除隐藏的默认路由</li>
|
||||||
|
<li>跳转路由高亮相对应的菜单栏</li>
|
||||||
|
<li>日志列表支持排序操作</li>
|
||||||
|
<li>分页组件新增pagerCount属性</li>
|
||||||
|
<li>定时任务屏蔽http(s)远程调用</li>
|
||||||
|
<li>文件服务本地资源允许跨域访问</li>
|
||||||
|
<li>升级spring-boot到最新版本2.5.3</li>
|
||||||
|
<li>升级spring-boot-admin到最新版2.4.3</li>
|
||||||
|
<li>升级spring-boot-mybatis到最新版2.2.0</li>
|
||||||
|
<li>升级nacos到最新版2.0.3</li>
|
||||||
|
<li>升级pagehelper到最新版1.3.1</li>
|
||||||
|
<li>升级minio到最新版本8.2.2</li>
|
||||||
|
<li>升级tobato到最新版本1.27.2</li>
|
||||||
|
<li>升级dynamic-ds到最新版本3.4.1</li>
|
||||||
|
<li>升级commons.io到最新版本v2.11.0</li>
|
||||||
|
<li>升级common-pool到最新版本2.10.0</li>
|
||||||
|
<li>升级commons.fileupload到最新版本v1.4</li>
|
||||||
|
<li>升级element-ui到最新版本2.15.3</li>
|
||||||
|
<li>优化统一网关错误码响应</li>
|
||||||
|
<li>修复导出含params属性对象参数问题</li>
|
||||||
|
<li>修复任意账户越权问题</li>
|
||||||
|
<li>修复定时任务日志执行状态显示</li>
|
||||||
|
<li>修改登录失效返回值code401</li>
|
||||||
|
<li>用户信息长度校验限制</li>
|
||||||
|
<li>角色&菜单新增字段属性提示信息</li>
|
||||||
|
<li>修复用户搜索分页变量错误</li>
|
||||||
|
<li>优化部门父级启用状态</li>
|
||||||
|
<li>启用部门状态排除顶级节点</li>
|
||||||
|
<li>定时任务新增更多操作</li>
|
||||||
|
<li>优化代码生成模板</li>
|
||||||
|
<li>优化顶部菜单显示样式</li>
|
||||||
|
<li>优化导入用户显示样式</li>
|
||||||
|
<li>优化用户不能删除自己</li>
|
||||||
|
<li>密码框新增显示切换密码图标</li>
|
||||||
|
<li>BLOB下载时清除URL对象引用</li>
|
||||||
|
<li>其他细节优化</li>
|
||||||
|
</ol>
|
||||||
|
</el-collapse-item>
|
||||||
<el-collapse-item title="v3.0.0 - 2021-06-10">
|
<el-collapse-item title="v3.0.0 - 2021-06-10">
|
||||||
<ol>
|
<ol>
|
||||||
<li>新增菜单导航显示风格TopNav(false为左侧导航菜单,true为顶部导航菜单)</li>
|
<li>新增菜单导航显示风格TopNav(false为左侧导航菜单,true为顶部导航菜单)</li>
|
||||||
|
|
@ -505,7 +560,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 版本号
|
// 版本号
|
||||||
version: "3.0.0",
|
version: "3.1.0",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="code">
|
<el-form-item prop="code" v-if="captchaOnOff">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="loginForm.code"
|
v-model="loginForm.code"
|
||||||
auto-complete="off"
|
auto-complete="off"
|
||||||
|
|
@ -44,6 +44,9 @@
|
||||||
<span v-if="!loading">登 录</span>
|
<span v-if="!loading">登 录</span>
|
||||||
<span v-else>登 录 中...</span>
|
<span v-else>登 录 中...</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<div style="float: right;" v-if="register">
|
||||||
|
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
||||||
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
|
|
@ -73,14 +76,18 @@ export default {
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
username: [
|
username: [
|
||||||
{ required: true, trigger: "blur", message: "用户名不能为空" }
|
{ required: true, trigger: "blur", message: "请输入您的账号" }
|
||||||
],
|
],
|
||||||
password: [
|
password: [
|
||||||
{ required: true, trigger: "blur", message: "密码不能为空" }
|
{ required: true, trigger: "blur", message: "请输入您的密码" }
|
||||||
],
|
],
|
||||||
code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
|
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
|
// 验证码开关
|
||||||
|
captchaOnOff: true,
|
||||||
|
// 注册开关
|
||||||
|
register: false,
|
||||||
redirect: undefined
|
redirect: undefined
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -99,8 +106,11 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
getCode() {
|
getCode() {
|
||||||
getCodeImg().then(res => {
|
getCodeImg().then(res => {
|
||||||
this.codeUrl = "data:image/gif;base64," + res.img;
|
this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
|
||||||
this.loginForm.uuid = res.uuid;
|
if (this.captchaOnOff) {
|
||||||
|
this.codeUrl = "data:image/gif;base64," + res.img;
|
||||||
|
this.loginForm.uuid = res.uuid;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCookie() {
|
getCookie() {
|
||||||
|
|
@ -130,7 +140,9 @@ export default {
|
||||||
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.getCode();
|
if (this.captchaOnOff) {
|
||||||
|
this.getCode();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ export default {
|
||||||
/** 任务日志列表查询 */
|
/** 任务日志列表查询 */
|
||||||
handleJobLog(row) {
|
handleJobLog(row) {
|
||||||
const jobId = row.jobId || 0;
|
const jobId = row.jobId || 0;
|
||||||
this.$router.push({ path: '/job/log', query: { jobId: jobId } })
|
this.$router.push({ path: '/monitor/job-log/index', query: { jobId: jobId } })
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,208 @@
|
||||||
|
<template>
|
||||||
|
<div class="register">
|
||||||
|
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
|
||||||
|
<h3 class="title">若依后台管理系统</h3>
|
||||||
|
<el-form-item prop="username">
|
||||||
|
<el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
|
||||||
|
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="password">
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.password"
|
||||||
|
type="password"
|
||||||
|
auto-complete="off"
|
||||||
|
placeholder="密码"
|
||||||
|
@keyup.enter.native="handleRegister"
|
||||||
|
>
|
||||||
|
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="confirmPassword">
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.confirmPassword"
|
||||||
|
type="password"
|
||||||
|
auto-complete="off"
|
||||||
|
placeholder="确认密码"
|
||||||
|
@keyup.enter.native="handleRegister"
|
||||||
|
>
|
||||||
|
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="code" v-if="captchaOnOff">
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.code"
|
||||||
|
auto-complete="off"
|
||||||
|
placeholder="验证码"
|
||||||
|
style="width: 63%"
|
||||||
|
@keyup.enter.native="handleRegister"
|
||||||
|
>
|
||||||
|
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
||||||
|
</el-input>
|
||||||
|
<div class="register-code">
|
||||||
|
<img :src="codeUrl" @click="getCode" class="register-code-img"/>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item style="width:100%;">
|
||||||
|
<el-button
|
||||||
|
:loading="loading"
|
||||||
|
size="medium"
|
||||||
|
type="primary"
|
||||||
|
style="width:100%;"
|
||||||
|
@click.native.prevent="handleRegister"
|
||||||
|
>
|
||||||
|
<span v-if="!loading">注 册</span>
|
||||||
|
<span v-else>注 册 中...</span>
|
||||||
|
</el-button>
|
||||||
|
<div style="float: right;">
|
||||||
|
<router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<!-- 底部 -->
|
||||||
|
<div class="el-register-footer">
|
||||||
|
<span>Copyright © 2018-2021 ruoyi.vip All Rights Reserved.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getCodeImg, register } from "@/api/login";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Register",
|
||||||
|
data() {
|
||||||
|
const equalToPassword = (rule, value, callback) => {
|
||||||
|
if (this.registerForm.password !== value) {
|
||||||
|
callback(new Error("两次输入的密码不一致"));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
codeUrl: "",
|
||||||
|
registerForm: {
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
confirmPassword: "",
|
||||||
|
code: "",
|
||||||
|
uuid: ""
|
||||||
|
},
|
||||||
|
registerRules: {
|
||||||
|
username: [
|
||||||
|
{ required: true, trigger: "blur", message: "请输入您的账号" },
|
||||||
|
{ min: 2, max: 20, message: '用户账号长度必须介于 2 和 20 之间', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
password: [
|
||||||
|
{ required: true, trigger: "blur", message: "请输入您的密码" },
|
||||||
|
{ min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
confirmPassword: [
|
||||||
|
{ required: true, trigger: "blur", message: "请再次输入您的密码" },
|
||||||
|
{ required: true, validator: equalToPassword, trigger: "blur" }
|
||||||
|
],
|
||||||
|
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
captchaOnOff: true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getCode();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getCode() {
|
||||||
|
getCodeImg().then(res => {
|
||||||
|
this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
|
||||||
|
if (this.captchaOnOff) {
|
||||||
|
this.codeUrl = "data:image/gif;base64," + res.img;
|
||||||
|
this.registerForm.uuid = res.uuid;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRegister() {
|
||||||
|
this.$refs.registerForm.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true;
|
||||||
|
register(this.registerForm).then(res => {
|
||||||
|
const username = this.registerForm.username;
|
||||||
|
this.$alert("<font color='red'>恭喜你,您的账号 " + username + " 注册成功!</font>", '系统提示', {
|
||||||
|
dangerouslyUseHTMLString: true
|
||||||
|
}).then(() => {
|
||||||
|
this.$router.push("/login");
|
||||||
|
}).catch(() => {});
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false;
|
||||||
|
if (this.captchaOnOff) {
|
||||||
|
this.getCode();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style rel="stylesheet/scss" lang="scss">
|
||||||
|
.register {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100%;
|
||||||
|
background-image: url("../assets/images/login-background.jpg");
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
margin: 0px auto 30px auto;
|
||||||
|
text-align: center;
|
||||||
|
color: #707070;
|
||||||
|
}
|
||||||
|
|
||||||
|
.register-form {
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #ffffff;
|
||||||
|
width: 400px;
|
||||||
|
padding: 25px 25px 5px 25px;
|
||||||
|
.el-input {
|
||||||
|
height: 38px;
|
||||||
|
input {
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.input-icon {
|
||||||
|
height: 39px;
|
||||||
|
width: 14px;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.register-tip {
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
color: #bfbfbf;
|
||||||
|
}
|
||||||
|
.register-code {
|
||||||
|
width: 33%;
|
||||||
|
height: 38px;
|
||||||
|
float: right;
|
||||||
|
img {
|
||||||
|
cursor: pointer;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.el-register-footer {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
font-family: Arial;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
.register-code-img {
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -117,7 +117,7 @@
|
||||||
<el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true" />
|
<el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
|
<el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<router-link :to="'/dict/type/data/' + scope.row.dictId" class="link-type">
|
<router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type">
|
||||||
<span>{{ scope.row.dictType }}</span>
|
<span>{{ scope.row.dictType }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ export default {
|
||||||
/** 分配用户操作 */
|
/** 分配用户操作 */
|
||||||
handleAuthUser: function(row) {
|
handleAuthUser: function(row) {
|
||||||
const roleId = row.roleId;
|
const roleId = row.roleId;
|
||||||
this.$router.push("/auth/user/" + roleId);
|
this.$router.push("/system/role-auth/user/" + roleId);
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function() {
|
submitForm: function() {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
// 角色编号
|
// 角色编号
|
||||||
roleId: {
|
roleId: {
|
||||||
type: Number
|
type: [Number, String]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ export default {
|
||||||
/** 分配角色操作 */
|
/** 分配角色操作 */
|
||||||
handleAuthRole: function(row) {
|
handleAuthRole: function(row) {
|
||||||
const userId = row.userId;
|
const userId = row.userId;
|
||||||
this.$router.push("/auth/role/" + userId);
|
this.$router.push("/system/user-auth/role/" + userId);
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function() {
|
submitForm: function() {
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ export default {
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleEditTable(row) {
|
handleEditTable(row) {
|
||||||
const tableId = row.tableId || this.ids[0];
|
const tableId = row.tableId || this.ids[0];
|
||||||
this.$router.push("/gen/edit/" + tableId);
|
this.$router.push("/tool/gen-edit/index/" + tableId);
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-visual</artifactId>
|
<artifactId>ruoyi-visual</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,216 +1,216 @@
|
||||||
DROP DATABASE IF EXISTS `ry-config`;
|
DROP DATABASE IF EXISTS `ry-config`;
|
||||||
|
|
||||||
CREATE DATABASE `ry-config` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
CREATE DATABASE `ry-config` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
USE `ry-config`;
|
USE `ry-config`;
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = config_info */
|
/* 表名称 = config_info */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `config_info` (
|
CREATE TABLE `config_info` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
`group_id` varchar(255) DEFAULT NULL,
|
`group_id` varchar(255) DEFAULT NULL,
|
||||||
`content` longtext NOT NULL COMMENT 'content',
|
`content` longtext NOT NULL COMMENT 'content',
|
||||||
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
`src_user` text COMMENT 'source user',
|
`src_user` text COMMENT 'source user',
|
||||||
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
|
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
|
||||||
`app_name` varchar(128) DEFAULT NULL,
|
`app_name` varchar(128) DEFAULT NULL,
|
||||||
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
`c_desc` varchar(256) DEFAULT NULL,
|
`c_desc` varchar(256) DEFAULT NULL,
|
||||||
`c_use` varchar(64) DEFAULT NULL,
|
`c_use` varchar(64) DEFAULT NULL,
|
||||||
`effect` varchar(64) DEFAULT NULL,
|
`effect` varchar(64) DEFAULT NULL,
|
||||||
`type` varchar(64) DEFAULT NULL,
|
`type` varchar(64) DEFAULT NULL,
|
||||||
`c_schema` text,
|
`c_schema` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
|
UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
|
||||||
|
|
||||||
insert into config_info(id, data_id, group_id, content, md5, gmt_create, gmt_modified, src_user, src_ip, app_name, tenant_id, c_desc, c_use, effect, type, c_schema) values
|
insert into config_info(id, data_id, group_id, content, md5, gmt_create, gmt_modified, src_user, src_ip, app_name, tenant_id, c_desc, c_use, effect, type, c_schema) values
|
||||||
(1,'application-dev.yml','DEFAULT_GROUP','spring:\n main:\n allow-bean-definition-overriding: true\n autoconfigure:\n exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure\n\n#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n','c07e6f7321493f6d5390d0a08bffb75a','2019-11-29 16:31:20','2020-12-21 15:29:24',NULL,'0:0:0:0:0:0:0:1','','','通用配置','null','null','yaml','null'),
|
(1,'application-dev.yml','DEFAULT_GROUP','spring:\n main:\n allow-bean-definition-overriding: true\n autoconfigure:\n exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure\n\n#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n','c07e6f7321493f6d5390d0a08bffb75a','2019-11-29 16:31:20','2020-12-21 15:29:24',NULL,'0:0:0:0:0:0:0:1','','','通用配置','null','null','yaml','null'),
|
||||||
(2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n cloud:\r\n gateway:\r\n discovery:\r\n locator:\r\n lowerCaseServiceId: true\r\n enabled: true\r\n routes:\r\n # 认证中心\r\n - id: ruoyi-auth\r\n uri: lb://ruoyi-auth\r\n predicates:\r\n - Path=/auth/**\r\n filters:\r\n # 验证码处理\r\n - CacheRequestFilter\r\n - ValidateCodeFilter\r\n - StripPrefix=1\r\n # 代码生成\r\n - id: ruoyi-gen\r\n uri: lb://ruoyi-gen\r\n predicates:\r\n - Path=/code/**\r\n filters:\r\n - StripPrefix=1\r\n # 定时任务\r\n - id: ruoyi-job\r\n uri: lb://ruoyi-job\r\n predicates:\r\n - Path=/schedule/**\r\n filters:\r\n - StripPrefix=1\r\n # 系统模块\r\n - id: ruoyi-system\r\n uri: lb://ruoyi-system\r\n predicates:\r\n - Path=/system/**\r\n filters:\r\n - StripPrefix=1\r\n # 文件服务\r\n - id: ruoyi-file\r\n uri: lb://ruoyi-file\r\n predicates:\r\n - Path=/file/**\r\n filters:\r\n - StripPrefix=1\r\n\r\n# 不校验白名单\r\nignore:\r\n whites:\r\n - /auth/logout\r\n - /auth/login\r\n - /*/v2/api-docs\r\n - /csrf\r\n','ef4a58daf989827334b3aac1c9d68392','2020-05-14 14:17:55','2020-11-18 17:53:23',NULL,'0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','null'),
|
(2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password: \n cloud:\n gateway:\n discovery:\n locator:\n lowerCaseServiceId: true\n enabled: true\n routes:\n # 认证中心\n - id: ruoyi-auth\n uri: lb://ruoyi-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - CacheRequestFilter\n - ValidateCodeFilter\n - StripPrefix=1\n # 代码生成\n - id: ruoyi-gen\n uri: lb://ruoyi-gen\n predicates:\n - Path=/code/**\n filters:\n - StripPrefix=1\n # 定时任务\n - id: ruoyi-job\n uri: lb://ruoyi-job\n predicates:\n - Path=/schedule/**\n filters:\n - StripPrefix=1\n # 系统模块\n - id: ruoyi-system\n uri: lb://ruoyi-system\n predicates:\n - Path=/system/**\n filters:\n - StripPrefix=1\n # 文件服务\n - id: ruoyi-file\n uri: lb://ruoyi-file\n predicates:\n - Path=/file/**\n filters:\n - StripPrefix=1\n\n# 安全配置\nsecurity:\n # 验证码\n captcha:\n enabled: true\n type: math\n # 防止XSS攻击\n xss:\n enabled: true\n excludeUrls:\n - /system/notice\n # 不校验白名单\n ignore:\n whites:\n - /auth/logout\n - /auth/login\n - /auth/register\n - /*/v2/api-docs\n - /csrf\n','2f5a6b5a4ccf20b5801c5cf842456ec6','2020-05-14 14:17:55','2021-07-30 09:07:14',NULL,'0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','null'),
|
||||||
(3,'ruoyi-auth-dev.yml','DEFAULT_GROUP','spring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n','b7354e1eb62c2d846d44a796d9ec6930','2020-11-20 00:00:00','2021-02-28 21:06:58',NULL,'0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','null'),
|
(3,'ruoyi-auth-dev.yml','DEFAULT_GROUP','spring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n','b7354e1eb62c2d846d44a796d9ec6930','2020-11-20 00:00:00','2021-02-28 21:06:58',NULL,'0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','null'),
|
||||||
(4,'ruoyi-monitor-dev.yml','DEFAULT_GROUP','# spring\r\nspring: \r\n security:\r\n user:\r\n name: ruoyi\r\n password: 123456\r\n boot:\r\n admin:\r\n ui:\r\n title: 若依服务状态监控\r\n','d8997d0707a2fd5d9fc4e8409da38129','2020-11-20 00:00:00','2020-12-21 16:28:07',NULL,'0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','null'),
|
(4,'ruoyi-monitor-dev.yml','DEFAULT_GROUP','# spring\r\nspring: \r\n security:\r\n user:\r\n name: ruoyi\r\n password: 123456\r\n boot:\r\n admin:\r\n ui:\r\n title: 若依服务状态监控\r\n','d8997d0707a2fd5d9fc4e8409da38129','2020-11-20 00:00:00','2020-12-21 16:28:07',NULL,'0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','null'),
|
||||||
(5,'ruoyi-system-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n druid:\r\n stat-view-servlet:\r\n enabled: true\r\n loginUsername: admin\r\n loginPassword: 123456\r\n dynamic:\r\n druid:\r\n initial-size: 5\r\n min-idle: 5\r\n maxActive: 20\r\n maxWait: 60000\r\n timeBetweenEvictionRunsMillis: 60000\r\n minEvictableIdleTimeMillis: 300000\r\n validationQuery: SELECT 1 FROM DUAL\r\n testWhileIdle: true\r\n testOnBorrow: false\r\n testOnReturn: false\r\n poolPreparedStatements: true\r\n maxPoolPreparedStatementPerConnectionSize: 20\r\n filters: stat,slf4j\r\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\r\n datasource:\r\n # 主库数据源\r\n master:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n # 从库数据源\r\n # slave:\r\n # username: \r\n # password: \r\n # url: \r\n # driver-class-name: \r\n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\r\n\r\n# seata配置\r\nseata:\r\n # 默认关闭,如需启用spring.datasource.dynami.seata需要同时开启\r\n enabled: false\r\n # Seata 应用编号,默认为 ${spring.application.name}\r\n application-id: ${spring.application.name}\r\n # Seata 事务组编号,用于 TC 集群名\r\n tx-service-group: ${spring.application.name}-group\r\n # 关闭自动代理\r\n enable-auto-data-source-proxy: false\r\n # 服务配置项\r\n service:\r\n # 虚拟组和分组的映射\r\n vgroup-mapping:\r\n ruoyi-system-group: default\r\n config:\r\n type: nacos\r\n nacos:\r\n serverAddr: 127.0.0.1:8848\r\n group: SEATA_GROUP\r\n namespace:\r\n registry:\r\n type: nacos\r\n nacos:\r\n application: seata-server\r\n server-addr: 127.0.0.1:8848\r\n namespace:\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.system\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 系统模块接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip','ac8913dee679e65bb7d482df5f267d4e','2020-11-20 00:00:00','2021-01-27 10:42:25',NULL,'0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','null'),
|
(5,'ruoyi-system-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n druid:\r\n stat-view-servlet:\r\n enabled: true\r\n loginUsername: admin\r\n loginPassword: 123456\r\n dynamic:\r\n druid:\r\n initial-size: 5\r\n min-idle: 5\r\n maxActive: 20\r\n maxWait: 60000\r\n timeBetweenEvictionRunsMillis: 60000\r\n minEvictableIdleTimeMillis: 300000\r\n validationQuery: SELECT 1 FROM DUAL\r\n testWhileIdle: true\r\n testOnBorrow: false\r\n testOnReturn: false\r\n poolPreparedStatements: true\r\n maxPoolPreparedStatementPerConnectionSize: 20\r\n filters: stat,slf4j\r\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\r\n datasource:\r\n # 主库数据源\r\n master:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n # 从库数据源\r\n # slave:\r\n # username: \r\n # password: \r\n # url: \r\n # driver-class-name: \r\n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\r\n\r\n# seata配置\r\nseata:\r\n # 默认关闭,如需启用spring.datasource.dynami.seata需要同时开启\r\n enabled: false\r\n # Seata 应用编号,默认为 ${spring.application.name}\r\n application-id: ${spring.application.name}\r\n # Seata 事务组编号,用于 TC 集群名\r\n tx-service-group: ${spring.application.name}-group\r\n # 关闭自动代理\r\n enable-auto-data-source-proxy: false\r\n # 服务配置项\r\n service:\r\n # 虚拟组和分组的映射\r\n vgroup-mapping:\r\n ruoyi-system-group: default\r\n config:\r\n type: nacos\r\n nacos:\r\n serverAddr: 127.0.0.1:8848\r\n group: SEATA_GROUP\r\n namespace:\r\n registry:\r\n type: nacos\r\n nacos:\r\n application: seata-server\r\n server-addr: 127.0.0.1:8848\r\n namespace:\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.system\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 系统模块接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip','ac8913dee679e65bb7d482df5f267d4e','2020-11-20 00:00:00','2021-01-27 10:42:25',NULL,'0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','null'),
|
||||||
(6,'ruoyi-gen-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource: \r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.gen.domain\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 代码生成接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n\r\n# 代码生成\r\ngen: \r\n # 作者\r\n author: ruoyi\r\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\r\n packageName: com.ruoyi.system\r\n # 自动去除表前缀,默认是false\r\n autoRemovePre: false\r\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\r\n tablePrefix: sys_\r\n','8c79f64a4cca9b821a03dc8b27a2d8eb','2020-11-20 00:00:00','2021-01-26 10:36:45',NULL,'0:0:0:0:0:0:0:1','','','代码生成','null','null','yaml','null'),
|
(6,'ruoyi-gen-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource: \r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.gen.domain\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 代码生成接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n\r\n# 代码生成\r\ngen: \r\n # 作者\r\n author: ruoyi\r\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\r\n packageName: com.ruoyi.system\r\n # 自动去除表前缀,默认是false\r\n autoRemovePre: false\r\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\r\n tablePrefix: sys_\r\n','8c79f64a4cca9b821a03dc8b27a2d8eb','2020-11-20 00:00:00','2021-01-26 10:36:45',NULL,'0:0:0:0:0:0:0:1','','','代码生成','null','null','yaml','null'),
|
||||||
(7,'ruoyi-job-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.job.domain\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 定时任务接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n','d6dfade9a2c93c463ae857cd503cb172','2020-11-20 00:00:00','2021-01-26 10:36:04',NULL,'0:0:0:0:0:0:0:1','','','定时任务','null','null','yaml','null'),
|
(7,'ruoyi-job-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.job.domain\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 定时任务接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n','d6dfade9a2c93c463ae857cd503cb172','2020-11-20 00:00:00','2021-01-26 10:36:04',NULL,'0:0:0:0:0:0:0:1','','','定时任务','null','null','yaml','null'),
|
||||||
(8,'ruoyi-file-dev.yml','DEFAULT_GROUP','# 本地文件上传 \r\nfile:\r\n domain: http://127.0.0.1:9300\r\n path: D:/ruoyi/uploadPath\r\n prefix: /statics\r\n\r\n# FastDFS配置\r\nfdfs:\r\n domain: http://8.129.231.12\r\n soTimeout: 3000\r\n connectTimeout: 2000\r\n trackerList: 8.129.231.12:22122\r\n\r\n# Minio配置\r\nminio:\r\n url: http://8.129.231.12:9000\r\n accessKey: minioadmin\r\n secretKey: minioadmin\r\n bucketName: test','5382b93f3d8059d6068c0501fdd41195','2020-11-20 00:00:00','2020-12-21 21:01:59',NULL,'0:0:0:0:0:0:0:1','','','文件服务','null','null','yaml','null'),
|
(8,'ruoyi-file-dev.yml','DEFAULT_GROUP','# 本地文件上传 \r\nfile:\r\n domain: http://127.0.0.1:9300\r\n path: D:/ruoyi/uploadPath\r\n prefix: /statics\r\n\r\n# FastDFS配置\r\nfdfs:\r\n domain: http://8.129.231.12\r\n soTimeout: 3000\r\n connectTimeout: 2000\r\n trackerList: 8.129.231.12:22122\r\n\r\n# Minio配置\r\nminio:\r\n url: http://8.129.231.12:9000\r\n accessKey: minioadmin\r\n secretKey: minioadmin\r\n bucketName: test','5382b93f3d8059d6068c0501fdd41195','2020-11-20 00:00:00','2020-12-21 21:01:59',NULL,'0:0:0:0:0:0:0:1','','','文件服务','null','null','yaml','null'),
|
||||||
(9,'sentinel-ruoyi-gateway','DEFAULT_GROUP','[\r\n {\r\n \"resource\": \"ruoyi-auth\",\r\n \"count\": 500,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-system\",\r\n \"count\": 1000,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-gen\",\r\n \"count\": 200,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-job\",\r\n \"count\": 300,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n }\r\n]','9f3a3069261598f74220bc47958ec252','2020-11-20 00:00:00','2020-11-20 00:00:00',NULL,'0:0:0:0:0:0:0:1','','','限流策略','null','null','json','null');
|
(9,'sentinel-ruoyi-gateway','DEFAULT_GROUP','[\r\n {\r\n \"resource\": \"ruoyi-auth\",\r\n \"count\": 500,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-system\",\r\n \"count\": 1000,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-gen\",\r\n \"count\": 200,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-job\",\r\n \"count\": 300,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n }\r\n]','9f3a3069261598f74220bc47958ec252','2020-11-20 00:00:00','2020-11-20 00:00:00',NULL,'0:0:0:0:0:0:0:1','','','限流策略','null','null','json','null');
|
||||||
|
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = config_info_aggr */
|
/* 表名称 = config_info_aggr */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `config_info_aggr` (
|
CREATE TABLE `config_info_aggr` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
`group_id` varchar(255) NOT NULL COMMENT 'group_id',
|
`group_id` varchar(255) NOT NULL COMMENT 'group_id',
|
||||||
`datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
|
`datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
|
||||||
`content` longtext NOT NULL COMMENT '内容',
|
`content` longtext NOT NULL COMMENT '内容',
|
||||||
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
|
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
|
||||||
`app_name` varchar(128) DEFAULT NULL,
|
`app_name` varchar(128) DEFAULT NULL,
|
||||||
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
|
UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
|
||||||
|
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = config_info_beta */
|
/* 表名称 = config_info_beta */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `config_info_beta` (
|
CREATE TABLE `config_info_beta` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||||
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||||
`content` longtext NOT NULL COMMENT 'content',
|
`content` longtext NOT NULL COMMENT 'content',
|
||||||
`beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
|
`beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
|
||||||
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
`src_user` text COMMENT 'source user',
|
`src_user` text COMMENT 'source user',
|
||||||
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
|
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
|
||||||
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
|
UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = config_info_tag */
|
/* 表名称 = config_info_tag */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `config_info_tag` (
|
CREATE TABLE `config_info_tag` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||||
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
||||||
`tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
|
`tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
|
||||||
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||||
`content` longtext NOT NULL COMMENT 'content',
|
`content` longtext NOT NULL COMMENT 'content',
|
||||||
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
`src_user` text COMMENT 'source user',
|
`src_user` text COMMENT 'source user',
|
||||||
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
|
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
|
UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = config_tags_relation */
|
/* 表名称 = config_tags_relation */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `config_tags_relation` (
|
CREATE TABLE `config_tags_relation` (
|
||||||
`id` bigint(20) NOT NULL COMMENT 'id',
|
`id` bigint(20) NOT NULL COMMENT 'id',
|
||||||
`tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
|
`tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
|
||||||
`tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
|
`tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
|
||||||
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||||
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
||||||
`nid` bigint(20) NOT NULL AUTO_INCREMENT,
|
`nid` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
PRIMARY KEY (`nid`),
|
PRIMARY KEY (`nid`),
|
||||||
UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
|
UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
|
||||||
KEY `idx_tenant_id` (`tenant_id`)
|
KEY `idx_tenant_id` (`tenant_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = group_capacity */
|
/* 表名称 = group_capacity */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `group_capacity` (
|
CREATE TABLE `group_capacity` (
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
`group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
|
`group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
|
||||||
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
|
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
|
||||||
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
|
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
|
||||||
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
|
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
|
||||||
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
|
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
|
||||||
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
|
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
|
||||||
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
|
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
|
||||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_group_id` (`group_id`)
|
UNIQUE KEY `uk_group_id` (`group_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 表名称 = his_config_info */
|
/* 表名称 = his_config_info */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `his_config_info` (
|
CREATE TABLE `his_config_info` (
|
||||||
`id` bigint(64) unsigned NOT NULL,
|
`id` bigint(64) unsigned NOT NULL,
|
||||||
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`data_id` varchar(255) NOT NULL,
|
`data_id` varchar(255) NOT NULL,
|
||||||
`group_id` varchar(128) NOT NULL,
|
`group_id` varchar(128) NOT NULL,
|
||||||
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||||
`content` longtext NOT NULL,
|
`content` longtext NOT NULL,
|
||||||
`md5` varchar(32) DEFAULT NULL,
|
`md5` varchar(32) DEFAULT NULL,
|
||||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`src_user` text,
|
`src_user` text,
|
||||||
`src_ip` varchar(50) DEFAULT NULL,
|
`src_ip` varchar(50) DEFAULT NULL,
|
||||||
`op_type` char(10) DEFAULT NULL,
|
`op_type` char(10) DEFAULT NULL,
|
||||||
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
PRIMARY KEY (`nid`),
|
PRIMARY KEY (`nid`),
|
||||||
KEY `idx_gmt_create` (`gmt_create`),
|
KEY `idx_gmt_create` (`gmt_create`),
|
||||||
KEY `idx_gmt_modified` (`gmt_modified`),
|
KEY `idx_gmt_modified` (`gmt_modified`),
|
||||||
KEY `idx_did` (`data_id`)
|
KEY `idx_did` (`data_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
|
||||||
|
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* 数据库全名 = nacos_config */
|
/* 数据库全名 = nacos_config */
|
||||||
/* 表名称 = tenant_capacity */
|
/* 表名称 = tenant_capacity */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
CREATE TABLE `tenant_capacity` (
|
CREATE TABLE `tenant_capacity` (
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
`tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
|
`tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
|
||||||
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
|
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
|
||||||
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
|
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
|
||||||
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
|
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
|
||||||
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
|
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
|
||||||
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
|
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
|
||||||
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
|
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
|
||||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_tenant_id` (`tenant_id`)
|
UNIQUE KEY `uk_tenant_id` (`tenant_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE `tenant_info` (
|
CREATE TABLE `tenant_info` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`kp` varchar(128) NOT NULL COMMENT 'kp',
|
`kp` varchar(128) NOT NULL COMMENT 'kp',
|
||||||
`tenant_id` varchar(128) default '' COMMENT 'tenant_id',
|
`tenant_id` varchar(128) default '' COMMENT 'tenant_id',
|
||||||
`tenant_name` varchar(128) default '' COMMENT 'tenant_name',
|
`tenant_name` varchar(128) default '' COMMENT 'tenant_name',
|
||||||
`tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
|
`tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
|
||||||
`create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
|
`create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
|
||||||
`gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
|
`gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
|
||||||
`gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
|
`gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
|
UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
|
||||||
KEY `idx_tenant_id` (`tenant_id`)
|
KEY `idx_tenant_id` (`tenant_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
|
||||||
|
|
||||||
CREATE TABLE `users` (
|
CREATE TABLE `users` (
|
||||||
`username` varchar(50) NOT NULL PRIMARY KEY,
|
`username` varchar(50) NOT NULL PRIMARY KEY,
|
||||||
`password` varchar(500) NOT NULL,
|
`password` varchar(500) NOT NULL,
|
||||||
`enabled` boolean NOT NULL
|
`enabled` boolean NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `roles` (
|
CREATE TABLE `roles` (
|
||||||
`username` varchar(50) NOT NULL,
|
`username` varchar(50) NOT NULL,
|
||||||
`role` varchar(50) NOT NULL,
|
`role` varchar(50) NOT NULL,
|
||||||
UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
|
UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `permissions` (
|
CREATE TABLE `permissions` (
|
||||||
`role` varchar(50) NOT NULL,
|
`role` varchar(50) NOT NULL,
|
||||||
`resource` varchar(255) NOT NULL,
|
`resource` varchar(255) NOT NULL,
|
||||||
`action` varchar(8) NOT NULL,
|
`action` varchar(8) NOT NULL,
|
||||||
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
|
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
||||||
|
|
||||||
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
|
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
|
||||||
Loading…
Reference in New Issue