feat(sj_1.0.0): 优化导出

This commit is contained in:
opensnail 2024-05-27 18:23:00 +08:00
parent 6dfe183128
commit 50483b5c2a
3 changed files with 3 additions and 11 deletions

View File

@ -101,9 +101,9 @@ public class GroupConfigController {
return groupConfigService.getTablePartitionList();
}
@PostMapping("/import")
@PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@LoginRequired
public void importScene(@RequestParam("file") MultipartFile file) throws IOException {
public void importScene(@RequestPart("file") MultipartFile file) throws IOException {
if (file.isEmpty()) {
throw new SnailJobCommonException("Please select a file to upload");
}

View File

@ -417,13 +417,9 @@ public class GroupConfigServiceImpl implements GroupConfigService {
List<GroupConfig> groupConfigs = accessTemplate.getGroupConfigAccess().list(
new LambdaQueryWrapper<GroupConfig>()
.eq(GroupConfig::getNamespaceId, namespaceId)
.in(GroupConfig::getId, groupIds)
.in(CollUtil.isNotEmpty(groupIds), GroupConfig::getId, groupIds)
);
SetView<Long> notExistedGroupIdSet = Sets.difference(groupIds,
StreamUtils.toSet(groupConfigs, GroupConfig::getId));
Assert.isTrue(groupIds.size() == groupConfigs.size(), () -> new SnailJobServerException("导出失败. 组ID{}不存在", notExistedGroupIdSet));
return JsonUtil.toJsonString(GroupConfigConverter.INSTANCE.toGroupConfigRequestVOs(groupConfigs));
}

View File

@ -194,10 +194,6 @@ public class SceneConfigServiceImpl implements SceneConfigService {
.in(CollUtil.isNotEmpty(sceneIds), RetrySceneConfig::getId, sceneIds)
);
SetView<Long> notExistedSceneIdSet = Sets.difference(sceneIds,
StreamUtils.toSet(sceneConfigs, RetrySceneConfig::getId));
Assert.isTrue(sceneIds.size() == sceneConfigs.size(), () -> new SnailJobServerException("导出失败. 场景ID{}不存在", notExistedSceneIdSet));
return JsonUtil.toJsonString(SceneConfigConverter.INSTANCE.toSceneConfigRequestVOs(sceneConfigs));
}