| | |
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.exception.ServiceException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.project.system.domain.SysConfig;
|
| | |
| | | @PostConstruct
|
| | | public void init()
|
| | | {
|
| | | List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
| | | for (SysConfig config : configsList)
|
| | | {
|
| | | redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
| | | }
|
| | | loadingConfigCache();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return retConfig.getConfigValue();
|
| | | }
|
| | | return StringUtils.EMPTY;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取验证码开关
|
| | | * |
| | | * @return true开启,false关闭
|
| | | */
|
| | | @Override
|
| | | public boolean selectCaptchaOnOff()
|
| | | {
|
| | | String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff");
|
| | | if (StringUtils.isEmpty(captchaOnOff))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return Convert.toBool(captchaOnOff);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * 批量删除参数信息
|
| | | *
|
| | | * @param configIds 需要删除的参数ID
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public int deleteConfigByIds(Long[] configIds)
|
| | | public void deleteConfigByIds(Long[] configIds)
|
| | | {
|
| | | int count = configMapper.deleteConfigByIds(configIds);
|
| | | if (count > 0)
|
| | | for (Long configId : configIds)
|
| | | {
|
| | | Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
| | | redisCache.deleteObject(keys);
|
| | | SysConfig config = selectConfigById(configId);
|
| | | if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
|
| | | {
|
| | | throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
| | | }
|
| | | configMapper.deleteConfigById(configId);
|
| | | redisCache.deleteObject(getCacheKey(config.getConfigKey()));
|
| | | }
|
| | | return count;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 清空缓存数据
|
| | | * 加载参数缓存数据
|
| | | */
|
| | | @Override
|
| | | public void clearCache()
|
| | | public void loadingConfigCache()
|
| | | {
|
| | | List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
| | | for (SysConfig config : configsList)
|
| | | {
|
| | | redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 清空参数缓存数据
|
| | | */
|
| | | @Override
|
| | | public void clearConfigCache()
|
| | | {
|
| | | Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
| | | redisCache.deleteObject(keys);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 重置参数缓存数据
|
| | | */
|
| | | @Override
|
| | | public void resetConfigCache()
|
| | | {
|
| | | clearConfigCache();
|
| | | loadingConfigCache();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 校验参数键名是否唯一
|
| | | *
|
| | | * @param config 参数配置信息
|