diff --git a/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/enums/ConfigExceptionEnum.java b/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/enums/ConfigExceptionEnum.java index 977ac7768..4fc9aa7bf 100644 --- a/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/enums/ConfigExceptionEnum.java +++ b/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/enums/ConfigExceptionEnum.java @@ -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", "初始化配置失败,系统配置已经初始化"); /** * 错误编码 diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java index a69071406..6752471ec 100644 --- a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java @@ -152,6 +152,15 @@ public class SysConfigServiceImpl extends ServiceImpl 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 sysConfigs = configInitRequest.getSysConfigs(); sysConfigs.put(RuleConstants.SYSTEM_CONFIG_INIT_FLAG_NAME, "true");