|
@@ -1,14 +1,8 @@
|
|
|
package com.usky.dxtop.service.impl;
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
-
|
|
|
import com.usky.dxtop.common.constant.Constants;
|
|
|
import com.usky.dxtop.common.constant.UserConstants;
|
|
|
-import com.usky.dxtop.common.core.redis.RedisCache;
|
|
|
import com.usky.dxtop.common.core.text.Convert;
|
|
|
-
|
|
|
import com.usky.dxtop.common.exception.CustomException;
|
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
|
import com.usky.dxtop.mapper.SysConfigMapper;
|
|
@@ -17,6 +11,8 @@ import com.usky.dxtop.service.ISysConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 参数配置 服务层实现
|
|
@@ -28,13 +24,12 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
{
|
|
|
@Autowired
|
|
|
private SysConfigMapper configMapper;
|
|
|
- @Autowired
|
|
|
- private RedisCache redisCache;
|
|
|
+// @Autowired
|
|
|
+// private RedisCache redisCache;
|
|
|
|
|
|
/**
|
|
|
* 项目启动时,初始化参数到缓存
|
|
|
*/
|
|
|
- @PostConstruct
|
|
|
public void init()
|
|
|
{
|
|
|
loadingConfigCache();
|
|
@@ -63,18 +58,13 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
@Override
|
|
|
public String selectConfigByKey(String configKey)
|
|
|
{
|
|
|
- String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
|
|
|
- if (StringUtils.isNotEmpty(configValue))
|
|
|
- {
|
|
|
- return configValue;
|
|
|
- }
|
|
|
SysConfig config = new SysConfig();
|
|
|
config.setConfigKey(configKey);
|
|
|
SysConfig retConfig = configMapper.selectConfig(config);
|
|
|
if (StringUtils.isNotNull(retConfig))
|
|
|
{
|
|
|
- redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
|
|
return retConfig.getConfigValue();
|
|
|
+
|
|
|
}
|
|
|
return StringUtils.EMPTY;
|
|
|
}
|
|
@@ -117,10 +107,6 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
public int insertConfig(SysConfig config)
|
|
|
{
|
|
|
int row = configMapper.insertConfig(config);
|
|
|
- if (row > 0)
|
|
|
- {
|
|
|
- redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
- }
|
|
|
return row;
|
|
|
}
|
|
|
|
|
@@ -134,10 +120,6 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
public int updateConfig(SysConfig config)
|
|
|
{
|
|
|
int row = configMapper.updateConfig(config);
|
|
|
- if (row > 0)
|
|
|
- {
|
|
|
- redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
- }
|
|
|
return row;
|
|
|
}
|
|
|
|
|
@@ -158,7 +140,6 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
|
|
}
|
|
|
configMapper.deleteConfigById(configId);
|
|
|
- redisCache.deleteObject(getCacheKey(config.getConfigKey()));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -168,11 +149,11 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
@Override
|
|
|
public void loadingConfigCache()
|
|
|
{
|
|
|
- List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
|
|
- for (SysConfig config : configsList)
|
|
|
- {
|
|
|
- redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
- }
|
|
|
+// List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
|
|
+// for (SysConfig config : configsList)
|
|
|
+// {
|
|
|
+// redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -181,8 +162,8 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|
|
@Override
|
|
|
public void clearConfigCache()
|
|
|
{
|
|
|
- Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
|
|
- redisCache.deleteObject(keys);
|
|
|
+// Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
|
|
+// redisCache.deleteObject(keys);
|
|
|
}
|
|
|
|
|
|
/**
|