From 6a79e1068ba93065e072d92fe4eb81d574417739 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 3 Aug 2022 10:10:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=8E=A5=E5=8F=A3=E5=90=8E=EF=BC=8C=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=EF=BC=8C=E5=88=A0=E9=99=A4=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=EF=BC=8C=E5=86=8D=E6=AC=A1=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=EF=BC=8C=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --bug=1015643 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015643 --- .../api/service/ApiModuleService.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index e7b8e70b66..59adb05f60 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -1166,36 +1166,38 @@ public class ApiModuleService extends NodeTreeService { //如果导入的有重名,覆盖,接口ID替换成系统内的 caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId()); List caseWithBLOBs = oldCaseNameMap.get(name); - ApiTestCaseWithBLOBs apiTestCaseWithBLOBs1 = caseWithBLOBs.get(0); - if (apiTestCaseWithBLOBs1 != null) { - if (caseWithBLOBs.size() > 1) { - for (int i = 0; i < caseWithBLOBs.size(); i++) { - int version = 0; - if (caseWithBLOBs.get(i).getVersion() != null) { - version = caseWithBLOBs.get(i).getVersion() + 1; - } - if (i == 0) { - caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); - caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum()); - caseWithBLOBs1.setVersion(version); - } else { - ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs(); - BeanUtils.copyBean(apiTestCaseWithBLOBs, caseWithBLOBs1); - apiTestCaseWithBLOBs.setId(caseWithBLOBs.get(i).getId()); - apiTestCaseWithBLOBs.setNum(caseWithBLOBs.get(i).getNum()); - apiTestCaseWithBLOBs.setVersion(version); - apiTestCaseWithBLOBs.setVersionId("create_repeat"); - optionDataCases.add(apiTestCaseWithBLOBs); + if (CollectionUtils.isNotEmpty(caseWithBLOBs)) { + ApiTestCaseWithBLOBs apiTestCaseWithBLOBs1 = caseWithBLOBs.get(0); + if (apiTestCaseWithBLOBs1 != null) { + if (caseWithBLOBs.size() > 1) { + for (int i = 0; i < caseWithBLOBs.size(); i++) { + int version = 0; + if (caseWithBLOBs.get(i).getVersion() != null) { + version = caseWithBLOBs.get(i).getVersion() + 1; + } + if (i == 0) { + caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); + caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum()); + caseWithBLOBs1.setVersion(version); + } else { + ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs(); + BeanUtils.copyBean(apiTestCaseWithBLOBs, caseWithBLOBs1); + apiTestCaseWithBLOBs.setId(caseWithBLOBs.get(i).getId()); + apiTestCaseWithBLOBs.setNum(caseWithBLOBs.get(i).getNum()); + apiTestCaseWithBLOBs.setVersion(version); + apiTestCaseWithBLOBs.setVersionId("create_repeat"); + optionDataCases.add(apiTestCaseWithBLOBs); + } } + } else { + caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); + caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum()); + caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : apiTestCaseWithBLOBs1.getVersion() + 1); } + oldCaseNameMap.remove(name); } else { - caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); - caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum()); - caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : apiTestCaseWithBLOBs1.getVersion() + 1); + caseWithBLOBs1.setVersion(0); } - oldCaseNameMap.remove(name); - } else { - caseWithBLOBs1.setVersion(0); } }); } else {