pull/131/head
caohong 4 years ago
commit cdcbae57f2

@ -17,25 +17,26 @@
<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.3.7.RELEASE</spring-boot.version> <spring-boot.version>2.5.0</spring-boot.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version> <spring-cloud.version>2020.0.2</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.5.RELEASE</spring-cloud-alibaba.version> <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<spring-boot-admin.version>2.3.1</spring-boot-admin.version> <spring-boot-admin.version>2.4.1</spring-boot-admin.version>
<spring-boot.mybatis>2.1.4</spring-boot.mybatis> <spring-boot.mybatis>2.1.4</spring-boot.mybatis>
<swagger.fox.version>2.9.2</swagger.fox.version> <swagger.fox.version>2.9.2</swagger.fox.version>
<swagger.core.version>1.5.24</swagger.core.version> <swagger.core.version>1.5.24</swagger.core.version>
<tobato.version>1.26.5</tobato.version> <tobato.version>1.26.5</tobato.version>
<kaptcha.version>2.3.2</kaptcha.version> <kaptcha.version>2.3.2</kaptcha.version>
<pagehelper.boot.version>1.3.0</pagehelper.boot.version> <pagehelper.boot.version>1.3.0</pagehelper.boot.version>
<druid.version>1.2.4</druid.version> <druid.version>1.2.6</druid.version>
<dynamic-ds.version>3.2.1</dynamic-ds.version> <dynamic-ds.version>3.3.2</dynamic-ds.version>
<commons.io.version>2.5</commons.io.version> <commons.io.version>2.5</commons.io.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version> <commons.fileupload.version>1.3.3</commons.fileupload.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
<fastjson.version>1.2.75</fastjson.version> <fastjson.version>1.2.76</fastjson.version>
<minio.version>8.0.3</minio.version> <minio.version>8.2.1</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.6.2</common-pool.version>
<commons-collections.version>3.2.2</commons-collections.version>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
@ -150,6 +151,13 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- Collection 增强Java集合框架 -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons-collections.version}</version>
</dependency>
<!-- JSON 解析器和生成器 --> <!-- JSON 解析器和生成器 -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
@ -234,7 +242,11 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<dependencies> <dependencies>
<!-- bootstrap 启动器 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -2,12 +2,12 @@ package com.ruoyi.system.api.factory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteFileService; import com.ruoyi.system.api.RemoteFileService;
import com.ruoyi.system.api.domain.SysFile; import com.ruoyi.system.api.domain.SysFile;
import feign.hystrix.FallbackFactory;
/** /**
* *

@ -2,11 +2,11 @@ package com.ruoyi.system.api.factory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
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.SysOperLog; import com.ruoyi.system.api.domain.SysOperLog;
import feign.hystrix.FallbackFactory;
/** /**
* *

@ -2,11 +2,11 @@ package com.ruoyi.system.api.factory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
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.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import feign.hystrix.FallbackFactory;
/** /**
* *

@ -17,23 +17,29 @@
<dependencies> <dependencies>
<!-- SpringCloud Openfeign --> <!-- SpringCloud Openfeign -->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<!-- SpringCloud Loadbalancer -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<!-- Spring Context Support --> <!-- Spring Context Support -->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId> <artifactId>spring-context-support</artifactId>
</dependency> </dependency>
<!-- Spring Web --> <!-- Spring Web -->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
</dependency> </dependency>
<!-- Apache Commons Pool2 --> <!-- Apache Commons Pool2 -->
<dependency> <dependency>

@ -22,7 +22,7 @@ public class ExceptionUtil
return str; return str;
} }
public static String getRootErrorMseeage(Exception e) public static String getRootErrorMessage(Exception e)
{ {
Throwable root = ExceptionUtils.getRootCause(e); Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root); root = (root == null ? e : root);

@ -236,6 +236,30 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return str.substring(start, end); return str.substring(start, end);
} }
/**
*
*
* @param str value
* @return
*/
public static boolean hasText(String str)
{
return (str != null && !str.isEmpty() && containsText(str));
}
private static boolean containsText(CharSequence str)
{
int strLen = str.length();
for (int i = 0; i < strLen; i++)
{
if (!Character.isWhitespace(str.charAt(i)))
{
return true;
}
}
return false;
}
/** /**
* , {} <br> * , {} <br>
* {} <br> * {} <br>

@ -68,6 +68,7 @@ public class DataScopeAspect
@Before("dataScopePointCut()") @Before("dataScopePointCut()")
public void doBefore(JoinPoint point) throws Throwable public void doBefore(JoinPoint point) throws Throwable
{ {
clearDataScope(point);
handleDataScope(point); handleDataScope(point);
} }
@ -169,4 +170,17 @@ public class DataScopeAspect
} }
return null; return null;
} }
/**
* sqlparams.dataScope
*/
private void clearDataScope(final JoinPoint joinPoint)
{
Object params = joinPoint.getArgs()[0];
if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
{
BaseEntity baseEntity = (BaseEntity) params;
baseEntity.getParams().put(DATA_SCOPE, "");
}
}
} }

@ -190,7 +190,7 @@ public class LogAspect
{ {
for (int i = 0; i < paramsArray.length; i++) for (int i = 0; i < paramsArray.length; i++)
{ {
if (!isFilterObject(paramsArray[i])) if (StringUtils.isNotNull(paramsArray[i]) && !isFilterObject(paramsArray[i]))
{ {
try try
{ {

@ -8,8 +8,10 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
/** /**
* redis * redis
@ -21,7 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class RedisConfig extends CachingConfigurerSupport public class RedisConfig extends CachingConfigurerSupport
{ {
@Bean @Bean
@SuppressWarnings(value = { "unchecked", "rawtypes", "deprecation" }) @SuppressWarnings(value = { "unchecked", "rawtypes" })
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
{ {
RedisTemplate<Object, Object> template = new RedisTemplate<>(); RedisTemplate<Object, Object> template = new RedisTemplate<>();
@ -31,12 +33,17 @@ public class RedisConfig extends CachingConfigurerSupport
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
serializer.setObjectMapper(mapper); serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);
// 使用StringRedisSerializer来序列化和反序列化redis的key值 // 使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer()); template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(serializer);
// Hash的key也采用StringRedisSerializer的序列化方式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(serializer);
template.afterPropertiesSet(); template.afterPropertiesSet();
return template; return template;
} }

@ -11,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.PatternMatchUtils; import org.springframework.util.PatternMatchUtils;
import org.springframework.util.StringUtils;
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.security.annotation.PreAuthorize; import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
@ -50,7 +50,7 @@ public class PreAuthorizeAspect
return point.proceed(); return point.proceed();
} }
if (!StringUtils.isEmpty(annotation.hasPermi())) if (StringUtils.isNotEmpty(annotation.hasPermi()))
{ {
if (hasPermi(annotation.hasPermi())) if (hasPermi(annotation.hasPermi()))
{ {
@ -58,7 +58,7 @@ public class PreAuthorizeAspect
} }
throw new PreAuthorizeException(); throw new PreAuthorizeException();
} }
else if (!StringUtils.isEmpty(annotation.lacksPermi())) else if (StringUtils.isNotEmpty(annotation.lacksPermi()))
{ {
if (lacksPermi(annotation.lacksPermi())) if (lacksPermi(annotation.lacksPermi()))
{ {
@ -74,7 +74,7 @@ public class PreAuthorizeAspect
} }
throw new PreAuthorizeException(); throw new PreAuthorizeException();
} }
else if (!StringUtils.isEmpty(annotation.hasRole())) else if (StringUtils.isNotEmpty(annotation.hasRole()))
{ {
if (hasRole(annotation.hasRole())) if (hasRole(annotation.hasRole()))
{ {
@ -82,7 +82,7 @@ public class PreAuthorizeAspect
} }
throw new PreAuthorizeException(); throw new PreAuthorizeException();
} }
else if (!StringUtils.isEmpty(annotation.lacksRole())) else if (StringUtils.isNotEmpty(annotation.lacksRole()))
{ {
if (lacksRole(annotation.lacksRole())) if (lacksRole(annotation.lacksRole()))
{ {
@ -111,7 +111,7 @@ public class PreAuthorizeAspect
public boolean hasPermi(String permission) public boolean hasPermi(String permission)
{ {
LoginUser userInfo = tokenService.getLoginUser(); LoginUser userInfo = tokenService.getLoginUser();
if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions())) if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
{ {
return false; return false;
} }
@ -138,7 +138,7 @@ public class PreAuthorizeAspect
public boolean hasAnyPermi(String[] permissions) public boolean hasAnyPermi(String[] permissions)
{ {
LoginUser userInfo = tokenService.getLoginUser(); LoginUser userInfo = tokenService.getLoginUser();
if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions())) if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
{ {
return false; return false;
} }
@ -162,7 +162,7 @@ public class PreAuthorizeAspect
public boolean hasRole(String role) public boolean hasRole(String role)
{ {
LoginUser userInfo = tokenService.getLoginUser(); LoginUser userInfo = tokenService.getLoginUser();
if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles())) if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
{ {
return false; return false;
} }
@ -196,7 +196,7 @@ public class PreAuthorizeAspect
public boolean hasAnyRoles(String[] roles) public boolean hasAnyRoles(String[] roles)
{ {
LoginUser userInfo = tokenService.getLoginUser(); LoginUser userInfo = tokenService.getLoginUser();
if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles())) if (StringUtils.isNull(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
{ {
return false; return false;
} }
@ -220,6 +220,6 @@ public class PreAuthorizeAspect
private boolean hasPermissions(Collection<String> authorities, String permission) private boolean hasPermissions(Collection<String> authorities, String permission)
{ {
return authorities.stream().filter(StringUtils::hasText) return authorities.stream().filter(StringUtils::hasText)
.anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x)); .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(x, permission));
} }
} }

@ -1,11 +1,9 @@
package com.ruoyi.gateway.config; package com.ruoyi.gateway.config;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
import com.ruoyi.gateway.handler.SentinelFallbackHandler; import com.ruoyi.gateway.handler.SentinelFallbackHandler;
/** /**
@ -22,11 +20,4 @@ public class GatewayConfig
{ {
return new SentinelFallbackHandler(); return new SentinelFallbackHandler();
} }
@Bean
@Order(-1)
public GlobalFilter sentinelGatewayFilter()
{
return new SentinelGatewayFilter();
}
} }

@ -54,6 +54,12 @@
<artifactId>velocity</artifactId> <artifactId>velocity</artifactId>
</dependency> </dependency>
<!-- Commons Collections -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<!-- Mysql Connector --> <!-- Mysql Connector -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>

@ -1,7 +1,7 @@
package com.ruoyi.gen; package com.ruoyi.gen;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig; import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients; import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@ -14,7 +14,7 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomConfig @EnableCustomConfig
@EnableCustomSwagger2 @EnableCustomSwagger2
@EnableRyFeignClients @EnableRyFeignClients
@SpringCloudApplication @SpringBootApplication
public class RuoYiGenApplication public class RuoYiGenApplication
{ {
public static void main(String[] args) public static void main(String[] args)

@ -83,7 +83,7 @@ public interface ${ClassName}Mapper
/** /**
* 通过${functionName}ID删除${subTable.functionName}信息 * 通过${functionName}ID删除${subTable.functionName}信息
* *
* @param roleId 角色ID * @param ${pkColumn.javaField} ${functionName}ID
* @return 结果 * @return 结果
*/ */
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField}); public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});

@ -1,7 +1,7 @@
package com.ruoyi.job; package com.ruoyi.job;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig; import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients; import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@ -14,7 +14,7 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomConfig @EnableCustomConfig
@EnableCustomSwagger2 @EnableCustomSwagger2
@EnableRyFeignClients @EnableRyFeignClients
@SpringCloudApplication @SpringBootApplication
public class RuoYiJobApplication public class RuoYiJobApplication
{ {
public static void main(String[] args) public static void main(String[] args)

@ -1,6 +1,5 @@
package com.ruoyi.job.domain; package com.ruoyi.job.domain;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
@ -19,7 +18,7 @@ import com.ruoyi.job.util.CronUtils;
* *
* @author ruoyi * @author ruoyi
*/ */
public class SysJob extends BaseEntity implements Serializable public class SysJob extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

@ -1,7 +1,7 @@
package com.ruoyi.system; package com.ruoyi.system;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig; import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients; import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@ -14,7 +14,7 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomConfig @EnableCustomConfig
@EnableCustomSwagger2 @EnableCustomSwagger2
@EnableRyFeignClients @EnableRyFeignClients
@SpringCloudApplication @SpringBootApplication
public class RuoYiSystemApplication public class RuoYiSystemApplication
{ {
public static void main(String[] args) public static void main(String[] args)

@ -117,18 +117,19 @@ public class SysConfigController extends BaseController
@DeleteMapping("/{configIds}") @DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds) public AjaxResult remove(@PathVariable Long[] configIds)
{ {
return toAjax(configService.deleteConfigByIds(configIds)); configService.deleteConfigByIds(configIds);
return success();
} }
/** /**
* *
*/ */
@PreAuthorize(hasPermi = "system:config:remove") @PreAuthorize(hasPermi = "system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.CLEAN) @Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/clearCache") @DeleteMapping("/refreshCache")
public AjaxResult clearCache() public AjaxResult refreshCache()
{ {
configService.clearCache(); configService.resetConfigCache();
return AjaxResult.success(); return AjaxResult.success();
} }
} }

@ -117,6 +117,7 @@ public class SysDictDataController extends BaseController
@DeleteMapping("/{dictCodes}") @DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes) public AjaxResult remove(@PathVariable Long[] dictCodes)
{ {
return toAjax(dictDataService.deleteDictDataByIds(dictCodes)); dictDataService.deleteDictDataByIds(dictCodes);
return success();
} }
} }

@ -106,18 +106,19 @@ public class SysDictTypeController extends BaseController
@DeleteMapping("/{dictIds}") @DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds) public AjaxResult remove(@PathVariable Long[] dictIds)
{ {
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds)); dictTypeService.deleteDictTypeByIds(dictIds);
return success();
} }
/** /**
* *
*/ */
@PreAuthorize(hasPermi = "system:dict:remove") @PreAuthorize(hasPermi = "system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.CLEAN) @Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/clearCache") @DeleteMapping("/refreshCache")
public AjaxResult clearCache() public AjaxResult refreshCache()
{ {
dictTypeService.clearCache(); dictTypeService.resetDictCache();
return AjaxResult.success(); return AjaxResult.success();
} }

@ -57,12 +57,22 @@ public interface ISysConfigService
* @param configIds ID * @param configIds ID
* @return * @return
*/ */
public int deleteConfigByIds(Long[] configIds); public void deleteConfigByIds(Long[] configIds);
/** /**
* *
*/ */
public void clearCache(); public void loadingConfigCache();
/**
*
*/
public void clearConfigCache();
/**
*
*/
public void resetConfigCache();
/** /**
* *

@ -41,7 +41,7 @@ public interface ISysDictDataService
* @param dictCodes ID * @param dictCodes ID
* @return * @return
*/ */
public int deleteDictDataByIds(Long[] dictCodes); public void deleteDictDataByIds(Long[] dictCodes);
/** /**
* *

@ -56,12 +56,22 @@ public interface ISysDictTypeService
* @param dictIds ID * @param dictIds ID
* @return * @return
*/ */
public int deleteDictTypeByIds(Long[] dictIds); public void deleteDictTypeByIds(Long[] dictIds);
/** /**
* *
*/ */
public void clearCache(); public void loadingDictCache();
/**
*
*/
public void clearDictCache();
/**
*
*/
public void resetDictCache();
/** /**
* *

@ -35,11 +35,7 @@ public class SysConfigServiceImpl implements ISysConfigService
@PostConstruct @PostConstruct
public void init() public void init()
{ {
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig()); loadingConfigCache();
for (SysConfig config : configsList)
{
redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
} }
/** /**
@ -134,7 +130,7 @@ public class SysConfigServiceImpl implements ISysConfigService
* @return * @return
*/ */
@Override @Override
public int deleteConfigByIds(Long[] configIds) public void deleteConfigByIds(Long[] configIds)
{ {
for (Long configId : configIds) for (Long configId : configIds)
{ {
@ -143,26 +139,44 @@ public class SysConfigServiceImpl implements ISysConfigService
{ {
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
} }
configMapper.deleteConfigById(configId);
redisService.deleteObject(getCacheKey(config.getConfigKey()));
} }
int count = configMapper.deleteConfigByIds(configIds); }
if (count > 0)
/**
*
*/
@Override
public void loadingConfigCache()
{
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
for (SysConfig config : configsList)
{ {
Collection<String> keys = redisService.keys(Constants.SYS_CONFIG_KEY + "*"); redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
redisService.deleteObject(keys);
} }
return count;
} }
/** /**
* *
*/ */
@Override @Override
public void clearCache() public void clearConfigCache()
{ {
Collection<String> keys = redisService.keys(Constants.SYS_CONFIG_KEY + "*"); Collection<String> keys = redisService.keys(Constants.SYS_CONFIG_KEY + "*");
redisService.deleteObject(keys); redisService.deleteObject(keys);
} }
/**
*
*/
@Override
public void resetConfigCache()
{
clearConfigCache();
loadingConfigCache();
}
/** /**
* *
* *

@ -63,29 +63,31 @@ public class SysDictDataServiceImpl implements ISysDictDataService
* @return * @return
*/ */
@Override @Override
public int deleteDictDataByIds(Long[] dictCodes) public void deleteDictDataByIds(Long[] dictCodes)
{ {
int row = dictDataMapper.deleteDictDataByIds(dictCodes); for (Long dictCode : dictCodes)
if (row > 0)
{ {
DictUtils.clearDictCache(); SysDictData data = selectDictDataById(dictCode);
dictDataMapper.deleteDictDataById(dictCode);
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
DictUtils.setDictCache(data.getDictType(), dictDatas);
} }
return row;
} }
/** /**
* *
* *
* @param dictData * @param data
* @return * @return
*/ */
@Override @Override
public int insertDictData(SysDictData dictData) public int insertDictData(SysDictData data)
{ {
int row = dictDataMapper.insertDictData(dictData); int row = dictDataMapper.insertDictData(data);
if (row > 0) if (row > 0)
{ {
DictUtils.clearDictCache(); List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
DictUtils.setDictCache(data.getDictType(), dictDatas);
} }
return row; return row;
} }
@ -93,16 +95,17 @@ public class SysDictDataServiceImpl implements ISysDictDataService
/** /**
* *
* *
* @param dictData * @param data
* @return * @return
*/ */
@Override @Override
public int updateDictData(SysDictData dictData) public int updateDictData(SysDictData data)
{ {
int row = dictDataMapper.updateDictData(dictData); int row = dictDataMapper.updateDictData(data);
if (row > 0) if (row > 0)
{ {
DictUtils.clearDictCache(); List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
DictUtils.setDictCache(data.getDictType(), dictDatas);
} }
return row; return row;
} }

@ -35,12 +35,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
@PostConstruct @PostConstruct
public void init() public void init()
{ {
List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll(); loadingDictCache();
for (SysDictType dictType : dictTypeList)
{
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
DictUtils.setDictCache(dictType.getDictType(), dictDatas);
}
} }
/** /**
@ -120,7 +115,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
* @return * @return
*/ */
@Override @Override
public int deleteDictTypeByIds(Long[] dictIds) public void deleteDictTypeByIds(Long[] dictIds)
{ {
for (Long dictId : dictIds) for (Long dictId : dictIds)
{ {
@ -129,37 +124,54 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
{ {
throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName())); throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
} }
dictTypeMapper.deleteDictTypeById(dictId);
DictUtils.removeDictCache(dictType.getDictType());
} }
int count = dictTypeMapper.deleteDictTypeByIds(dictIds); }
if (count > 0)
/**
*
*/
public void loadingDictCache()
{
List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
for (SysDictType dictType : dictTypeList)
{ {
DictUtils.clearDictCache(); List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
DictUtils.setDictCache(dictType.getDictType(), dictDatas);
} }
return count;
} }
/** /**
* *
*/ */
@Override public void clearDictCache()
public void clearCache()
{ {
DictUtils.clearDictCache(); DictUtils.clearDictCache();
} }
/**
*
*/
public void resetDictCache()
{
clearDictCache();
loadingDictCache();
}
/** /**
* *
* *
* @param dictType * @param dict
* @return * @return
*/ */
@Override @Override
public int insertDictType(SysDictType dictType) public int insertDictType(SysDictType dict)
{ {
int row = dictTypeMapper.insertDictType(dictType); int row = dictTypeMapper.insertDictType(dict);
if (row > 0) if (row > 0)
{ {
DictUtils.clearDictCache(); DictUtils.setDictCache(dict.getDictType(), null);
} }
return row; return row;
} }
@ -167,19 +179,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
/** /**
* *
* *
* @param dictType * @param dict
* @return * @return
*/ */
@Override @Override
@Transactional @Transactional
public int updateDictType(SysDictType dictType) public int updateDictType(SysDictType dict)
{ {
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
int row = dictTypeMapper.updateDictType(dictType); int row = dictTypeMapper.updateDictType(dict);
if (row > 0) if (row > 0)
{ {
DictUtils.clearDictCache(); List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
DictUtils.setDictCache(dict.getDictType(), dictDatas);
} }
return row; return row;
} }

@ -43,6 +43,16 @@ public class DictUtils
return null; return null;
} }
/**
*
*
* @param key
*/
public static void removeDictCache(String key)
{
SpringUtils.getBean(RedisService.class).deleteObject(getCacheKey(key));
}
/** /**
* *
*/ */

@ -147,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
where dept_id in (${ancestors}) where find_in_set(#{deptId}, ancestors)
</update> </update>
<delete id="deleteDeptById" parameterType="Long"> <delete id="deleteDeptById" parameterType="Long">

File diff suppressed because one or more lines are too long

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= webpackConfig.name %></title> <title><%= webpackConfig.name %></title>
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
<style> <style>
html, html,
body, body,

@ -51,10 +51,10 @@ export function delConfig(configId) {
}) })
} }
// 清理参数缓存 // 刷新参数缓存
export function clearCache() { export function refreshCache() {
return request({ return request({
url: '/system/config/clearCache', url: '/system/config/refreshCache',
method: 'delete' method: 'delete'
}) })
} }

@ -43,10 +43,10 @@ export function delType(dictId) {
}) })
} }
// 清理参数缓存 // 刷新字典缓存
export function clearCache() { export function refreshCache() {
return request({ return request({
url: '/system/dict/type/clearCache', url: '/system/dict/type/refreshCache',
method: 'delete' method: 'delete'
}) })
} }

@ -98,9 +98,9 @@
plain plain
icon="el-icon-refresh" icon="el-icon-refresh"
size="mini" size="mini"
@click="handleClearCache" @click="handleRefreshCache"
v-hasPermi="['system:config:remove']" v-hasPermi="['system:config:remove']"
>清理缓存</el-button> >刷新缓存</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -180,7 +180,7 @@
</template> </template>
<script> <script>
import { listConfig, getConfig, delConfig, addConfig, updateConfig, clearCache } from "@/api/system/config"; import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
export default { export default {
name: "Config", name: "Config",
@ -343,10 +343,10 @@ export default {
...this.queryParams ...this.queryParams
}, `config_${new Date().getTime()}.xlsx`) }, `config_${new Date().getTime()}.xlsx`)
}, },
/** 清理缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleClearCache() { handleRefreshCache() {
clearCache().then(response => { refreshCache().then(() => {
this.msgSuccess("清理成功"); this.msgSuccess("刷新成功");
}); });
} }
} }

@ -104,9 +104,9 @@
plain plain
icon="el-icon-refresh" icon="el-icon-refresh"
size="mini" size="mini"
@click="handleClearCache" @click="handleRefreshCache"
v-hasPermi="['system:dict:remove']" v-hasPermi="['system:dict:remove']"
>清理缓存</el-button> >刷新缓存</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -188,7 +188,7 @@
</template> </template>
<script> <script>
import { listType, getType, delType, addType, updateType, clearCache } from "@/api/system/dict/type"; import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type";
export default { export default {
name: "Dict", name: "Dict",
@ -347,10 +347,10 @@ export default {
...this.queryParams ...this.queryParams
}, `type_${new Date().getTime()}.xlsx`) }, `type_${new Date().getTime()}.xlsx`)
}, },
/** 清理缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleClearCache() { handleRefreshCache() {
clearCache().then(response => { refreshCache().then(() => {
this.msgSuccess("清理成功"); this.msgSuccess("刷新成功");
}); });
} }
} }

@ -1,8 +1,8 @@
package com.ruoyi.modules.monitor; package com.ruoyi.modules.monitor;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
/** /**
* *
@ -10,7 +10,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
* @author ruoyi * @author ruoyi
*/ */
@EnableAdminServer @EnableAdminServer
@SpringCloudApplication @SpringBootApplication
public class RuoYiMonitorApplication public class RuoYiMonitorApplication
{ {
public static void main(String[] args) public static void main(String[] args)

Loading…
Cancel
Save