【7.0.4】【config】更新系统初始化配置

pull/22/head
fengshuonan 2021-07-09 16:27:48 +08:00
parent 9ae7bba7ce
commit df963a5943
2 changed files with 15 additions and 1 deletions

View File

@ -90,7 +90,12 @@ public enum ConfigExceptionEnum implements AbstractExceptionEnum {
/**
*
*/
CONFIG_INIT_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + ConfigConstants.CONFIG_EXCEPTION_STEP_CODE + "11", "初始化配置失败,参数为空");
CONFIG_INIT_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + ConfigConstants.CONFIG_EXCEPTION_STEP_CODE + "11", "初始化配置失败,参数为空"),
/**
*
*/
CONFIG_INIT_ALREADY(RuleConstants.BUSINESS_ERROR_TYPE_CODE + ConfigConstants.CONFIG_EXCEPTION_STEP_CODE + "12", "初始化配置失败,系统配置已经初始化");
/**
*

View File

@ -152,6 +152,15 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
throw new ConfigException(ConfigExceptionEnum.CONFIG_INIT_ERROR);
}
// 如果当前已经初始化过配置,则不能初始化
LambdaQueryWrapper<SysConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SysConfig::getConfigCode, RuleConstants.SYSTEM_CONFIG_INIT_FLAG_NAME);
SysConfig tempSysConfig = this.getOne(lambdaQueryWrapper, false);
String alreadyInit = tempSysConfig.getConfigValue();
if (Convert.toBool(alreadyInit)) {
throw new ConfigException(ConfigExceptionEnum.CONFIG_INIT_ALREADY);
}
// 添加系统已经初始化的配置
Map<String, String> sysConfigs = configInitRequest.getSysConfigs();
sysConfigs.put(RuleConstants.SYSTEM_CONFIG_INIT_FLAG_NAME, "true");