优化代码结构

This commit is contained in:
zhaojun1998
2020-01-11 22:48:28 +08:00
parent 921cb1a115
commit 7c04c3d6b8
17 changed files with 257 additions and 94 deletions

View File

@@ -72,6 +72,7 @@ public class SystemConfigService {
return systemConfigDTO;
}
public void updateSystemConfig(SystemConfigDTO systemConfigDTO) throws Exception {
List<SystemConfig> systemConfigList = new ArrayList<>();
@@ -106,10 +107,11 @@ public class SystemConfigService {
if (oldEnableCache && !curEnableCache) {
log.debug("检测到关闭了缓存, 正在清理缓存数据及关闭自动刷新");
currentFileService.clearCache();
currentFileService.clearFileCache();
}
}
public void updateUsernameAndPwd(String username, String password) {
SystemConfig usernameConfig = systemConfigRepository.findByKey(SystemConfigConstant.USERNAME);
usernameConfig.setValue(username);
@@ -124,16 +126,27 @@ public class SystemConfigService {
systemConfigRepository.save(systemConfig);
}
public void updateCacheEnableConfig(Boolean isEnable) {
SystemConfig enableConfig = systemConfigRepository.findByKey(SystemConfigConstant.ENABLE_CACHE);
enableConfig.setValue(isEnable.toString());
systemConfigRepository.save(enableConfig);
configCache.remove(SYSTEM_CONFIG_CACHE_KEY);
}
public AbstractFileService getCurrentFileService() {
StorageTypeEnum storageStrategy = getCurrentStorageStrategy();
return StorageTypeFactory.getStorageTypeService(storageStrategy);
}
public StorageTypeEnum getCurrentStorageStrategy() {
SystemConfigDTO systemConfigDTO = getSystemConfig();
return systemConfigDTO.getStorageStrategy();
}
public boolean getEnableCache() {
SystemConfigDTO systemConfigDTO = getSystemConfig();
return systemConfigDTO.getEnableCache();