mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -2,10 +2,8 @@ package com.gitee.sop.website.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.BaseLambdaService;
|
||||
import com.gitee.sop.website.common.config.IConfig;
|
||||
import com.gitee.sop.website.common.util.CopyUtil;
|
||||
import com.gitee.sop.website.dao.entity.SysConfig;
|
||||
import com.gitee.sop.website.dao.mapper.SysConfigMapper;
|
||||
import com.gitee.sop.website.service.sys.dto.SystemConfigDTO;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -13,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -37,41 +34,6 @@ public class SysConfigService extends BaseLambdaService<SysConfig, SysConfigMapp
|
||||
}
|
||||
});
|
||||
|
||||
public void save(Collection<SystemConfigDTO> configs) {
|
||||
configs.forEach(this::setConfig);
|
||||
}
|
||||
|
||||
public String getRawValue(String key) {
|
||||
return this.query()
|
||||
.eq(SysConfig::getConfigKey, key)
|
||||
.getValue(SysConfig::getConfigValue);
|
||||
}
|
||||
|
||||
public void setConfig(String key, String value) {
|
||||
setConfig(key, value, "");
|
||||
}
|
||||
|
||||
public void setConfig(String key, String value, String remark) {
|
||||
SystemConfigDTO systemConfigDTO = new SystemConfigDTO();
|
||||
systemConfigDTO.setConfigKey(key);
|
||||
systemConfigDTO.setConfigValue(value);
|
||||
systemConfigDTO.setRemark(remark);
|
||||
setConfig(systemConfigDTO);
|
||||
}
|
||||
|
||||
public void setConfig(SystemConfigDTO systemConfigDTO) {
|
||||
Objects.requireNonNull(systemConfigDTO.getConfigKey(), "need key");
|
||||
Objects.requireNonNull(systemConfigDTO.getConfigValue(), "need value");
|
||||
SysConfig systemConfig = get(SysConfig::getConfigKey, systemConfigDTO.getConfigKey());
|
||||
if (systemConfig == null) {
|
||||
systemConfig = CopyUtil.copyBean(systemConfigDTO, SysConfig::new);
|
||||
this.save(systemConfig);
|
||||
} else {
|
||||
CopyUtil.copyPropertiesIgnoreNull(systemConfigDTO, systemConfig);
|
||||
this.update(systemConfig);
|
||||
}
|
||||
configCache.invalidate(systemConfigDTO.getConfigKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息
|
||||
|
Reference in New Issue
Block a user