mirror of https://gitee.com/stylefeng/roses
【8.0】【config】新增一个更新缓存配置接口
parent
c0ac0225d1
commit
13d8b973b6
|
@ -0,0 +1,23 @@
|
||||||
|
package cn.stylefeng.roses.kernel.config.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置的操作API
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/10/4 22:05
|
||||||
|
*/
|
||||||
|
public interface ConfigServiceApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新系统配置的值,通过配置的编码
|
||||||
|
* <p>
|
||||||
|
* 同时更新数据库的和缓存的配置
|
||||||
|
*
|
||||||
|
* @param code 配置编码
|
||||||
|
* @param value 配置值
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/10/4 22:05
|
||||||
|
*/
|
||||||
|
void updateConfigByCode(String code, String value);
|
||||||
|
|
||||||
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
package cn.stylefeng.roses.kernel.config.modular.service;
|
package cn.stylefeng.roses.kernel.config.modular.service;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.config.api.ConfigServiceApi;
|
||||||
import cn.stylefeng.roses.kernel.config.api.InitConfigApi;
|
import cn.stylefeng.roses.kernel.config.api.InitConfigApi;
|
||||||
import cn.stylefeng.roses.kernel.config.api.pojo.ConfigInitRequest;
|
import cn.stylefeng.roses.kernel.config.api.pojo.ConfigInitRequest;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
||||||
|
@ -38,7 +39,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2020/4/14 11:14
|
* @since 2020/4/14 11:14
|
||||||
*/
|
*/
|
||||||
public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
|
public interface SysConfigService extends IService<SysConfig>, InitConfigApi, ConfigServiceApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加系统参数配置
|
* 添加系统参数配置
|
||||||
|
@ -65,7 +66,7 @@ public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
|
||||||
* @date 2023/07/03 21:29
|
* @date 2023/07/03 21:29
|
||||||
*/
|
*/
|
||||||
void batchDelete(SysConfigParam sysConfigParam);
|
void batchDelete(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除系统参数配置
|
* 删除系统参数配置
|
||||||
*
|
*
|
||||||
|
|
|
@ -336,4 +336,17 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateConfigByCode(String code, String value) {
|
||||||
|
|
||||||
|
// 更新系统配置的值
|
||||||
|
LambdaUpdateWrapper<SysConfig> sysConfigLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
sysConfigLambdaUpdateWrapper.eq(SysConfig::getConfigCode, code);
|
||||||
|
sysConfigLambdaUpdateWrapper.set(SysConfig::getConfigValue, value);
|
||||||
|
this.update(sysConfigLambdaUpdateWrapper);
|
||||||
|
|
||||||
|
// 更新缓存中的值
|
||||||
|
ConfigContext.me().putConfig(code, value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue