【7.3.0】增加配置修改的回调事件

pull/40/MERGE
fengshuonan 2022-10-22 21:39:31 +08:00
parent 8f87e6ac9c
commit 511ac5680c
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package cn.stylefeng.roses.kernel.rule.callback;
/**
*
*
* @author fengshuonan
* @date 2022/10/22 21:35
*/
public interface ConfigUpdateCallback {
/**
*
*
* @param code SYS_SERVER_DEPLOY_HOST
* @param value
* @author fengshuonan
* @date 2022/10/22 21:36
*/
void configUpdate(String code, String value);
}

View File

@ -45,6 +45,7 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.rule.callback.ConfigUpdateCallback;
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
@ -125,6 +126,16 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
// 4.更新对应常量context
ConfigContext.me().putConfig(sysConfigParam.getConfigCode(), sysConfigParam.getConfigValue());
// 5.发布属性修改的事件
try {
Map<String, ConfigUpdateCallback> beansOfType = SpringUtil.getBeansOfType(ConfigUpdateCallback.class);
for (ConfigUpdateCallback value : beansOfType.values()) {
value.configUpdate(sysConfig.getConfigCode(), sysConfig.getConfigValue());
}
} catch (Exception e) {
// 忽略找不到Bean的异常
}
}
@Override