From b8edfe2532ecf77d63daa4b7f233c21a8f1e8ab7 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 20 Jan 2022 17:11:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=BC=E5=85=A5=E6=97=B6case=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009804 --user=刘瑞斌 【接口测试】ms格式的接口,不覆盖,导入后用例版本不是所选版本 https://www.tapd.cn/55049933/s/1095093 --- .../api/service/ApiDefinitionService.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 9e47e563c9..51299f2b62 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -712,6 +712,11 @@ public class ApiDefinitionService { } batchMapper.insert(apiDefinition); String requestStr = setImportHashTree(apiDefinition); + + // case 设置版本 + cases.forEach(c -> { + c.setVersionId(apiDefinition.getVersionId()); + }); reSetImportCasesApiId(cases, originId, apiDefinition.getId()); reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum()); apiDefinition.setRequest(requestStr); @@ -759,6 +764,10 @@ public class ApiDefinitionService { } else { apiDefinition.setVersionId(defaultVersion); } + // case 设置版本 + cases.forEach(c -> { + c.setVersionId(apiDefinition.getVersionId()); + }); apiDefinition.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId())); reSetImportCasesApiId(cases, originId, apiDefinition.getId()); reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum()); @@ -798,7 +807,10 @@ public class ApiDefinitionService { apiDefinition.setNum(existApi.getNum()); //id 不变 apiDefinition.setRefId(existApi.getRefId()); apiDefinition.setVersionId(apiTestImportRequest.getUpdateVersionId()); - + // case 设置版本 + cases.forEach(c -> { + c.setVersionId(apiDefinition.getVersionId()); + }); if (!StringUtils.equalsIgnoreCase(apiTestImportRequest.getPlatform(), ApiImportPlatform.Metersphere.name())) { apiDefinition.setTags(existApi.getTags()); // 其他格式 tag 不变,MS 格式替换 }