|
@@ -27,8 +27,7 @@ import java.util.List;
|
|
|
* @author xunmei
|
|
* @author xunmei
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
-public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService
|
|
|
|
|
-{
|
|
|
|
|
|
|
+public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private SysConfigMapper configMapper;
|
|
private SysConfigMapper configMapper;
|
|
|
|
|
|
|
@@ -37,25 +36,25 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* 项目启动时,初始化参数到缓存
|
|
* 项目启动时,初始化参数到缓存
|
|
|
*/
|
|
*/
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
|
- public void init()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void init() {
|
|
|
loadingConfigCache();
|
|
loadingConfigCache();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public SysConfig findFirstByCode(String code) {
|
|
public SysConfig findFirstByCode(String code) {
|
|
|
return configMapper.selectOne(new QueryWrapper<SysConfig>().eq("config_key", code));
|
|
return configMapper.selectOne(new QueryWrapper<SysConfig>().eq("config_key", code));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public TableDataInfo<SysConfig> selectPage(SysConfig sysConfig) {
|
|
public TableDataInfo<SysConfig> selectPage(SysConfig sysConfig) {
|
|
|
|
|
|
|
|
Page<SysConfig> page;
|
|
Page<SysConfig> page;
|
|
|
- if (sysConfig.getPageNum()!=null&&sysConfig.getPageSize()!=null)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (sysConfig.getPageNum() != null && sysConfig.getPageSize() != null) {
|
|
|
page = new Page<>(sysConfig.getPageNum(), sysConfig.getPageSize());
|
|
page = new Page<>(sysConfig.getPageNum(), sysConfig.getPageSize());
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
page = new Page<>();
|
|
page = new Page<>();
|
|
|
}
|
|
}
|
|
|
- page = configMapper.selectPage( page,new QueryWrapper<>(sysConfig));
|
|
|
|
|
|
|
+ page = configMapper.selectPage(page, new QueryWrapper<>(sysConfig));
|
|
|
return TableDataInfo.build(page);
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -66,13 +65,20 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @return 参数配置信息
|
|
* @return 参数配置信息
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public SysConfig selectConfigById(Long configId)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public SysConfig selectConfigById(Long configId) {
|
|
|
SysConfig config = new SysConfig();
|
|
SysConfig config = new SysConfig();
|
|
|
config.setConfigId(configId);
|
|
config.setConfigId(configId);
|
|
|
return configMapper.selectConfig(config);
|
|
return configMapper.selectConfig(config);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public SysConfig selectIsDisplayPassword() {
|
|
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
|
+ queryWrapper.eq("config_key", "is_display_password");
|
|
|
|
|
+ SysConfig sysConfig = baseMapper.selectOne(queryWrapper);
|
|
|
|
|
+ return sysConfig;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据键名查询参数配置信息
|
|
* 根据键名查询参数配置信息
|
|
|
*
|
|
*
|
|
@@ -80,19 +86,16 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @return 参数键值
|
|
* @return 参数键值
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public String selectConfigByKey(String configKey)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public String selectConfigByKey(String configKey) {
|
|
|
String configValue = Convert.toStr(RedisUtils.getCacheObject(getCacheKey(configKey)));
|
|
String configValue = Convert.toStr(RedisUtils.getCacheObject(getCacheKey(configKey)));
|
|
|
//String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey)));
|
|
//String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey)));
|
|
|
- if (StringUtils.isNotEmpty(configValue))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(configValue)) {
|
|
|
return configValue;
|
|
return configValue;
|
|
|
}
|
|
}
|
|
|
SysConfig config = new SysConfig();
|
|
SysConfig config = new SysConfig();
|
|
|
config.setConfigKey(configKey);
|
|
config.setConfigKey(configKey);
|
|
|
SysConfig retConfig = configMapper.selectConfig(config);
|
|
SysConfig retConfig = configMapper.selectConfig(config);
|
|
|
- if (StringUtils.isNotNull(retConfig))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (StringUtils.isNotNull(retConfig)) {
|
|
|
RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
|
RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
|
|
//redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
|
//redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
|
|
return retConfig.getConfigValue();
|
|
return retConfig.getConfigValue();
|
|
@@ -107,8 +110,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @return 参数配置集合
|
|
* @return 参数配置集合
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<SysConfig> selectConfigList(SysConfig config)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public List<SysConfig> selectConfigList(SysConfig config) {
|
|
|
return configMapper.selectConfigList(config);
|
|
return configMapper.selectConfigList(config);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -119,11 +121,9 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int insertConfig(SysConfig config)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int insertConfig(SysConfig config) {
|
|
|
int row = configMapper.insertConfig(config);
|
|
int row = configMapper.insertConfig(config);
|
|
|
- if (row > 0)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (row > 0) {
|
|
|
RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
//redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
//redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
}
|
|
}
|
|
@@ -137,18 +137,15 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int updateConfig(SysConfig config)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int updateConfig(SysConfig config) {
|
|
|
SysConfig temp = configMapper.selectConfigById(config.getConfigId());
|
|
SysConfig temp = configMapper.selectConfigById(config.getConfigId());
|
|
|
- if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) {
|
|
|
RedisUtils.deleteObject(getCacheKey(temp.getConfigKey()));
|
|
RedisUtils.deleteObject(getCacheKey(temp.getConfigKey()));
|
|
|
//redisService.deleteObject(getCacheKey(temp.getConfigKey()));
|
|
//redisService.deleteObject(getCacheKey(temp.getConfigKey()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int row = configMapper.updateConfig(config);
|
|
int row = configMapper.updateConfig(config);
|
|
|
- if (row > 0)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (row > 0) {
|
|
|
RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
//redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
//redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
}
|
|
}
|
|
@@ -161,13 +158,10 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @param configIds 需要删除的参数ID
|
|
* @param configIds 需要删除的参数ID
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void deleteConfigByIds(Long[] configIds)
|
|
|
|
|
- {
|
|
|
|
|
- for (Long configId : configIds)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void deleteConfigByIds(Long[] configIds) {
|
|
|
|
|
+ for (Long configId : configIds) {
|
|
|
SysConfig config = selectConfigById(configId);
|
|
SysConfig config = selectConfigById(configId);
|
|
|
- if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
|
|
|
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
|
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
|
|
}
|
|
}
|
|
|
configMapper.deleteConfigById(configId);
|
|
configMapper.deleteConfigById(configId);
|
|
@@ -180,11 +174,9 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* 加载参数缓存数据
|
|
* 加载参数缓存数据
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void loadingConfigCache()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void loadingConfigCache() {
|
|
|
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
|
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
|
|
- for (SysConfig config : configsList)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ for (SysConfig config : configsList) {
|
|
|
RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
//redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
//redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
|
|
}
|
|
}
|
|
@@ -194,8 +186,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* 清空参数缓存数据
|
|
* 清空参数缓存数据
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void clearConfigCache()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void clearConfigCache() {
|
|
|
/*Collection<String> keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*");
|
|
/*Collection<String> keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*");
|
|
|
redisService.deleteObject(keys);*/
|
|
redisService.deleteObject(keys);*/
|
|
|
RedisUtils.deleteByPrefix(CacheConstants.SYS_CONFIG_KEY);
|
|
RedisUtils.deleteByPrefix(CacheConstants.SYS_CONFIG_KEY);
|
|
@@ -205,8 +196,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* 重置参数缓存数据
|
|
* 重置参数缓存数据
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void resetConfigCache()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void resetConfigCache() {
|
|
|
clearConfigCache();
|
|
clearConfigCache();
|
|
|
loadingConfigCache();
|
|
loadingConfigCache();
|
|
|
}
|
|
}
|
|
@@ -218,12 +208,10 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean checkConfigKeyUnique(SysConfig config)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public boolean checkConfigKeyUnique(SysConfig config) {
|
|
|
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
|
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
|
|
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
|
|
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
|
|
|
- if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
}
|
|
}
|
|
|
return UserConstants.UNIQUE;
|
|
return UserConstants.UNIQUE;
|
|
@@ -235,8 +223,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|
|
* @param configKey 参数键
|
|
* @param configKey 参数键
|
|
|
* @return 缓存键key
|
|
* @return 缓存键key
|
|
|
*/
|
|
*/
|
|
|
- private String getCacheKey(String configKey)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ private String getCacheKey(String configKey) {
|
|
|
return CacheConstants.SYS_CONFIG_KEY + configKey;
|
|
return CacheConstants.SYS_CONFIG_KEY + configKey;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|