refactor(接口测试): 优化本地附件csv的清理逻辑
This commit is contained in:
parent
656cde481c
commit
3002749f2d
|
@ -488,10 +488,23 @@ public class ApiScenarioService {
|
||||||
.filter(ScenarioVariable::isEnable).collect(toList());
|
.filter(ScenarioVariable::isEnable).collect(toList());
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(oldVariables) && CollectionUtils.isNotEmpty(newVariables)) {
|
if (CollectionUtils.isNotEmpty(oldVariables) && CollectionUtils.isNotEmpty(newVariables)) {
|
||||||
List<String> ids = newVariables.get(0).getFiles().stream().map(BodyFile::getId).collect(toList());
|
List<String> ids = newVariables.stream()
|
||||||
oldVariables.get(0).getFiles().forEach(item -> {
|
.flatMap(nv -> Optional.ofNullable(nv.getFiles()).orElse(List.of()).stream())
|
||||||
if (!ids.contains(item.getId())) {
|
.map(BodyFile::getId)
|
||||||
ApiFileUtil.deleteBodyFiles(item.getId() + "_" + item.getName());
|
.toList();
|
||||||
|
oldVariables.forEach(item ->{
|
||||||
|
if (CollectionUtils.isNotEmpty(item.getFiles()) &&
|
||||||
|
StringUtils.isNotBlank(item.getFiles().get(0).getId()) &&
|
||||||
|
!ids.contains(item.getFiles().get(0).getId())) {
|
||||||
|
ApiFileUtil.deleteBodyFiles(item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(newVariables) && CollectionUtils.isNotEmpty(oldVariables)) {
|
||||||
|
oldVariables.forEach(item ->{
|
||||||
|
if (CollectionUtils.isNotEmpty(item.getFiles()) &&
|
||||||
|
StringUtils.isNotBlank(item.getFiles().get(0).getId())) {
|
||||||
|
ApiFileUtil.deleteBodyFiles(item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue