Skip to content

Commit

Permalink
#448 code review update
Browse files Browse the repository at this point in the history
  • Loading branch information
kfchu committed Jul 26, 2018
1 parent dbad516 commit 269ae1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public SuccessResponseEntity getConfigs() throws IOException, SaturnJobConsoleEx
//获取配置meta
Map<String, List<JobConfigMeta>> jobConfigGroups = getSystemConfigMeta();
//返回所有配置信息
List<SystemConfig> systemConfigs = systemConfigService.getAllSystemConfigs();
List<SystemConfig> systemConfigs = systemConfigService.getSystemConfigsDirectly(null);
//剔除EXECUTOR_CONFIGS
removeExecutorConfigs(systemConfigs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public Integer createConfig(SystemConfig systemConfig) throws SaturnJobConsoleEx
}
}

if (systemConfig != null && systemConfigs.size() > 0 && found) {
if (found) {
throw new SaturnJobConsoleException(
String.format("systemConfig %s already existed", systemConfig.getProperty()));
}
Expand All @@ -224,22 +224,14 @@ public Integer createConfig(SystemConfig systemConfig) throws SaturnJobConsoleEx
public Integer updateConfig(SystemConfig systemConfig) throws SaturnJobConsoleException {
List<String> properties = new ArrayList<>();
properties.add(systemConfig.getProperty());
List<SystemConfig> systemConfigs = systemConfig4SqlService.selectByProperty(systemConfig.getProperty());
List<SystemConfig> systemConfigs = systemConfig4SqlService.selectByPropertiesAndLastly(properties);

SystemConfig targetConfig = null;
for (int i = 0; i < systemConfigs.size(); i++) {
SystemConfig config = systemConfigs.get(i);
if (StringUtils.equals(config.getProperty(), systemConfig.getProperty())) {
targetConfig = config;
break;
}
}
if (targetConfig == null) {
if (systemConfigs.size() == 0) {
throw new SaturnJobConsoleException(
String.format("systemConfig %s not existed, update fail", systemConfig.getProperty()));
}

SystemConfig config = targetConfig;
SystemConfig config = systemConfigs.get(0);
config.setProperty(systemConfig.getProperty());
config.setValue(systemConfig.getValue());
int result = systemConfig4SqlService.updateById(config);
Expand Down

0 comments on commit 269ae1d

Please sign in to comment.