This commit is contained in:
六如
2024-12-26 09:37:50 +08:00
parent 054560ae64
commit 150379c5f9
44 changed files with 26 additions and 1482 deletions

View File

@@ -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());
}
/**
* 获取配置信息