33333333333
This commit is contained in:
@@ -13,9 +13,11 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -89,15 +91,21 @@ public class SystemConfigManager {
|
||||
return Long.valueOf(value);
|
||||
}
|
||||
|
||||
private final Map<String,String> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 获取配置信息
|
||||
* @param systemConfig
|
||||
* @return
|
||||
*/
|
||||
public String getSystemConfig(SystemConfigEnum systemConfig){
|
||||
String value = (String) redisTemplate.opsForHash().get(RedisHttpConstant.SYSTEM_CONFIG, systemConfig.name());
|
||||
if(StringUtils.isBlank(value)){
|
||||
return systemConfig.getDefaultValue();
|
||||
String value = CACHE.get(systemConfig.name());
|
||||
if(value == null){
|
||||
value = (String) redisTemplate.opsForHash().get(RedisHttpConstant.SYSTEM_CONFIG, systemConfig.name());
|
||||
if(StringUtils.isBlank(value)){
|
||||
value = systemConfig.getDefaultValue();
|
||||
}
|
||||
CACHE.put(systemConfig.name(), value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -155,6 +163,7 @@ public class SystemConfigManager {
|
||||
sensitiveService.setSensitive(value.equals("1"));
|
||||
}
|
||||
redisTemplate.opsForHash().put(RedisHttpConstant.SYSTEM_CONFIG, key,value);
|
||||
CACHE.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user