mirror of
https://gitee.com/ZhongBangKeJi/crmeb_java.git
synced 2026-04-23 12:08:33 +08:00
config 数据redis化
This commit is contained in:
@@ -131,6 +131,10 @@ public class Constants {
|
|||||||
public static final String WE_CHAT_MESSAGE_KEY_PROGRAM = "we_chat_program_message_list";
|
public static final String WE_CHAT_MESSAGE_KEY_PROGRAM = "we_chat_program_message_list";
|
||||||
public static final String WE_CHAT_MESSAGE_INDUSTRY_KEY = "we_chat_message_industry";
|
public static final String WE_CHAT_MESSAGE_INDUSTRY_KEY = "we_chat_message_industry";
|
||||||
|
|
||||||
|
//config表数据redis
|
||||||
|
public static final String CONFIG_LIST = "config_list"; //配置列表
|
||||||
|
|
||||||
|
|
||||||
//快递信息缓存
|
//快递信息缓存
|
||||||
public static final String LOGISTICS_KEY = "logistics_";
|
public static final String LOGISTICS_KEY = "logistics_";
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package com.utils;
|
package com.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
|
||||||
import org.springframework.data.redis.core.ListOperations;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.core.SetOperations;
|
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis工具类
|
* redis工具类
|
||||||
@@ -182,6 +178,16 @@ public class RedisUtil {
|
|||||||
return hash.get(key, hashKey);
|
return hash.get(key, hashKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 哈希数量
|
||||||
|
* @param key string key
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @return Object
|
||||||
|
* @since 2020-04-13
|
||||||
|
*/
|
||||||
|
public Long getHashSize(String key) {
|
||||||
|
return redisTemplate.opsForHash().size(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表添加左边添加
|
* 列表添加左边添加
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.springframework.context.annotation.Primary;
|
|||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
@@ -86,22 +85,23 @@ public class RedisConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<Object,Object> redisTemplate(){
|
public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
|
||||||
RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
|
//设置序列化
|
||||||
template.setConnectionFactory(taskConnectionFactory());
|
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||||
|
|
||||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer =
|
|
||||||
new Jackson2JsonRedisSerializer(Object.class);
|
|
||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||||
|
//配置redisTemplate
|
||||||
template.setKeySerializer(new StringRedisSerializer());
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
|
||||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
RedisSerializer stringSerializer = new StringRedisSerializer();
|
||||||
template.afterPropertiesSet();
|
redisTemplate.setKeySerializer(stringSerializer);//key序列化
|
||||||
return template;
|
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);//value序列化
|
||||||
|
redisTemplate.setHashKeySerializer(stringSerializer);//Hash key序列化
|
||||||
|
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);//Hash value序列化
|
||||||
|
redisTemplate.afterPropertiesSet();
|
||||||
|
return redisTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,6 @@ public interface SystemConfigService extends IService<SystemConfig> {
|
|||||||
|
|
||||||
String getValueByKey(String key);
|
String getValueByKey(String key);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据key更新值
|
|
||||||
* @param key key
|
|
||||||
* @return 更新结果
|
|
||||||
*/
|
|
||||||
boolean setValueByKey(String key, String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同时获取多个配置
|
* 同时获取多个配置
|
||||||
* @param keys 多个配置key
|
* @param keys 多个配置key
|
||||||
@@ -32,14 +25,10 @@ public interface SystemConfigService extends IService<SystemConfig> {
|
|||||||
*/
|
*/
|
||||||
List<String> getValuesByKes(List<String> keys);
|
List<String> getValuesByKes(List<String> keys);
|
||||||
|
|
||||||
boolean updateValueByName(String name, String value);
|
|
||||||
|
|
||||||
boolean updateOrSaveValueByName(String name, String value);
|
boolean updateOrSaveValueByName(String name, String value);
|
||||||
|
|
||||||
String getValueByKeyException(String key);
|
String getValueByKeyException(String key);
|
||||||
|
|
||||||
String getValueByKeyNotStatus(String key);
|
|
||||||
|
|
||||||
boolean saveForm(SystemFormCheckRequest systemFormCheckRequest);
|
boolean saveForm(SystemFormCheckRequest systemFormCheckRequest);
|
||||||
|
|
||||||
HashMap<String, String> info(Integer formId);
|
HashMap<String, String> info(Integer formId);
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.zbkj.crmeb.system.service.impl;
|
package com.zbkj.crmeb.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.common.PageParamRequest;
|
import com.common.PageParamRequest;
|
||||||
|
import com.constants.Constants;
|
||||||
import com.exception.CrmebException;
|
import com.exception.CrmebException;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.utils.RedisUtil;
|
||||||
import com.zbkj.crmeb.system.dao.SystemConfigDao;
|
import com.zbkj.crmeb.system.dao.SystemConfigDao;
|
||||||
import com.zbkj.crmeb.system.model.SystemConfig;
|
import com.zbkj.crmeb.system.model.SystemConfig;
|
||||||
import com.zbkj.crmeb.system.request.SystemFormCheckRequest;
|
import com.zbkj.crmeb.system.request.SystemFormCheckRequest;
|
||||||
@@ -39,6 +40,11 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SystemAttachmentService systemAttachmentService;
|
private SystemAttachmentService systemAttachmentService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
private static final String redisKey = Constants.CONFIG_LIST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索列表
|
* 搜索列表
|
||||||
* @param pageParamRequest PageParamRequest 分页参数
|
* @param pageParamRequest PageParamRequest 分页参数
|
||||||
@@ -71,38 +77,10 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getValueByKey(String name) {
|
public String getValueByKey(String name) {
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
return get(name);
|
||||||
lambdaQueryWrapper.select(SystemConfig::getValue).eq(SystemConfig::getName, name);
|
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getStatus, false);
|
|
||||||
|
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
|
||||||
|
|
||||||
String value = null;
|
|
||||||
if(null != systemConfig && StringUtils.isNotBlank(systemConfig.getValue())){
|
|
||||||
value = systemConfig.getValue();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据key更新值
|
|
||||||
* @param key key
|
|
||||||
* @return 更新结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean setValueByKey(String key, String value) {
|
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getValue, value);
|
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getStatus, false);
|
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
|
||||||
systemConfig.setValue(value);
|
|
||||||
LambdaUpdateWrapper<SystemConfig> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
||||||
lambdaUpdateWrapper.set(SystemConfig::getValue, value);
|
|
||||||
lambdaUpdateWrapper.eq(SystemConfig::getName, key);
|
|
||||||
return dao.update(systemConfig, lambdaUpdateWrapper) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同时获取多个配置
|
* 同时获取多个配置
|
||||||
* @param keys 多个配置key
|
* @param keys 多个配置key
|
||||||
@@ -126,32 +104,12 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getValueByKeyException(String name) {
|
public String getValueByKeyException(String name) {
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
String value = get(name);
|
||||||
lambdaQueryWrapper.select(SystemConfig::getValue, SystemConfig::getTitle).
|
if(null == value){
|
||||||
eq(SystemConfig::getStatus, false).
|
|
||||||
eq(SystemConfig::getName, name);
|
|
||||||
|
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
|
||||||
if(null == systemConfig){
|
|
||||||
throw new CrmebException("没有找到"+ name +"数据");
|
throw new CrmebException("没有找到"+ name +"数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtils.isBlank(systemConfig.getValue())){
|
return value;
|
||||||
throw new CrmebException("配置项 " + systemConfig.getTitle() + " 没有配置, 请配置!");
|
|
||||||
}
|
|
||||||
return systemConfig.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValueByKeyNotStatus(String key) {
|
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
lambdaQueryWrapper.select(SystemConfig::getValue).eq(SystemConfig::getName, key);
|
|
||||||
|
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
|
||||||
if(StringUtils.isBlank(systemConfig.getValue())){
|
|
||||||
systemConfig.setValue(null);
|
|
||||||
}
|
|
||||||
return systemConfig.getValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,6 +148,8 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
//删除之前隐藏的数据
|
//删除之前隐藏的数据
|
||||||
deleteStatusByFormId(systemFormCheckRequest.getId());
|
deleteStatusByFormId(systemFormCheckRequest.getId());
|
||||||
|
|
||||||
|
async(systemConfigList);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +168,7 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
SystemConfig systemConfig = new SystemConfig();
|
SystemConfig systemConfig = new SystemConfig();
|
||||||
systemConfig.setStatus(true);
|
systemConfig.setStatus(true);
|
||||||
update(systemConfig, lambdaQueryWrapper);
|
update(systemConfig, lambdaQueryWrapper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,32 +181,11 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
//删除已经隐藏的数据
|
//删除已经隐藏的数据
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getFormId, formId).eq(SystemConfig::getStatus, true);
|
lambdaQueryWrapper.eq(SystemConfig::getFormId, formId).eq(SystemConfig::getStatus, true);
|
||||||
|
List<SystemConfig> systemConfigList = dao.selectList(lambdaQueryWrapper);
|
||||||
dao.delete(lambdaQueryWrapper);
|
dao.delete(lambdaQueryWrapper);
|
||||||
|
async(systemConfigList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据menu name更新 value
|
|
||||||
* @param name menu name
|
|
||||||
* @param value 值
|
|
||||||
* @author Mr.Zhang
|
|
||||||
* @since 2020-04-16
|
|
||||||
* @return JSONObject
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean updateValueByName(String name, String value){
|
|
||||||
value = systemAttachmentService.clearPrefix(value);
|
|
||||||
|
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getName, name).eq(SystemConfig::getValue, value);
|
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
|
||||||
if(systemConfig != null){
|
|
||||||
systemConfig.setValue(systemAttachmentService.clearPrefix(value));
|
|
||||||
updateById(systemConfig);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存或更新配置数据
|
* 保存或更新配置数据
|
||||||
@@ -265,33 +205,18 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
}else if(systemConfigs.size() == 1){
|
}else if(systemConfigs.size() == 1){
|
||||||
systemConfigs.get(0).setValue(value);
|
systemConfigs.get(0).setValue(value);
|
||||||
updateById(systemConfigs.get(0));
|
updateById(systemConfigs.get(0));
|
||||||
|
asyncRedis(name);
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
save(new SystemConfig().setName(name).setValue(value));
|
save(new SystemConfig().setName(name).setValue(value));
|
||||||
|
asyncRedis(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据name查询数据
|
|
||||||
* @param id Integer id
|
|
||||||
* @author Mr.Zhang
|
|
||||||
* @since 2020-04-16
|
|
||||||
* @return JSONObject
|
|
||||||
*/
|
|
||||||
private SystemConfig getVoByIdException(Integer id){
|
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getStatus, false).eq(SystemConfig::getId, id);
|
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
|
||||||
if(systemConfig == null){
|
|
||||||
throw new CrmebException("没有找到相对应的数据!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return systemConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据id查询数据
|
* 根据formId查询数据
|
||||||
* @param formId Integer id
|
* @param formId Integer id
|
||||||
* @author Mr.Zhang
|
* @author Mr.Zhang
|
||||||
* @since 2020-04-16
|
* @since 2020-04-16
|
||||||
@@ -322,10 +247,99 @@ public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigDao, System
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkName(String name){
|
public boolean checkName(String name){
|
||||||
|
String value = get(name);
|
||||||
|
return value == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把数据同步到redis
|
||||||
|
* @param name name
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-16
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
private void asyncRedis(String name){
|
||||||
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(SystemConfig::getName, name);
|
lambdaQueryWrapper.eq(SystemConfig::getName, name);
|
||||||
SystemConfig systemConfig = dao.selectOne(lambdaQueryWrapper);
|
List<SystemConfig> systemConfigList = dao.selectList(lambdaQueryWrapper);
|
||||||
return systemConfig == null;
|
if(systemConfigList.size() == 0){
|
||||||
|
//说明数据已经被删除了
|
||||||
|
deleteRedis(name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async(systemConfigList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把数据同步到redis
|
||||||
|
* @param systemConfigList List<SystemConfig> 需要同步的数据
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-16
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
private void async(List<SystemConfig> systemConfigList){
|
||||||
|
for (SystemConfig systemConfig : systemConfigList) {
|
||||||
|
if(systemConfig.getStatus()){
|
||||||
|
//隐藏之后,删除redis的数据
|
||||||
|
deleteRedis(systemConfig.getName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
redisUtil.hmSet(redisKey, systemConfig.getName(), systemConfig.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把数据同步到redis
|
||||||
|
* @param name String
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-16
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
private void deleteRedis(String name){
|
||||||
|
redisUtil.hmDelete(redisKey, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把数据同步到redis
|
||||||
|
* @param name String
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-16
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
private String get(String name){
|
||||||
|
setRedisByVoList();
|
||||||
|
Object data = redisUtil.hmGet(redisKey, name);
|
||||||
|
if(null == data || StringUtils.isBlank(data.toString())){
|
||||||
|
//没有找到数据
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//去数据库查找,然后写入redis
|
||||||
|
|
||||||
|
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把数据同步到redis, 此方法适用于redis为空的时候进行一次批量输入
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-16
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
private void setRedisByVoList(){
|
||||||
|
//检测redis是否为空
|
||||||
|
Long size = redisUtil.getHashSize(redisKey);
|
||||||
|
if(size > 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(SystemConfig::getStatus, false);
|
||||||
|
List<SystemConfig> systemConfigList = dao.selectList(lambdaQueryWrapper);
|
||||||
|
async(systemConfigList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class AsyncServiceImpl implements AsyncService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return systemConfigService.getValueByKeyNotStatus(pre+"UploadUrl");
|
return systemConfigService.getValueByKey(pre+"UploadUrl");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user