From 57b164f47d5b4ffd6b5c09777dce77bcfceb2c5f Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 13 Jul 2022 15:13:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9C=BA=E6=99=AF=E8=A6=86=E7=9B=96=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=8A=A5=E9=94=99=E4=BB=A5=E5=8F=8A=E5=88=9B=E5=BB=BA?= =?UTF-8?q?case=E6=8A=A5=E9=94=99=E4=BB=A5=E5=8F=8A=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --bug=1014815 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014815 --bug=1014816 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014816 --bug=1014820 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014820 --bug=1014814 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014814 --- .../metersphere/api/service/ApiAutomationService.java | 4 ++-- .../metersphere/api/service/ApiDefinitionService.java | 11 ++++++++++- .../metersphere/commons/constants/APITestStatus.java | 2 +- .../io/metersphere/track/service/TestCaseService.java | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 984ad82d85..0d6a435caa 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1195,7 +1195,7 @@ public class ApiAutomationService { if (CollectionUtils.isEmpty(sameRequest)) { scenarioWithBLOBs.setId(UUID.randomUUID().toString()); scenarioWithBLOBs.setCreateTime(System.currentTimeMillis()); - if (!scenarioWithBLOBs.getVersionId().equals("update")) { + if (scenarioWithBLOBs.getVersionId() != null && !scenarioWithBLOBs.getVersionId().equals("update")) { scenarioWithBLOBs.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId())); // 导入时设置版本 scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId()); @@ -1232,7 +1232,7 @@ public class ApiAutomationService { scenarioWithBLOBs.setCreateTime(System.currentTimeMillis()); scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId()); scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); - if (!scenarioWithBLOBs.getVersionId().equals("update")) { + if (scenarioWithBLOBs.getVersionId() != null && !scenarioWithBLOBs.getVersionId().equals("update")) { scenarioWithBLOBs.setRefId(sameRequest.get(0).getRefId()); scenarioWithBLOBs.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num scenarioWithBLOBs.setOrder(sameRequest.get(0).getOrder()); 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 b306147957..77ef567dbe 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -830,11 +830,20 @@ public class ApiDefinitionService { } apiTestCaseWithBLOBs.setUpdateTime(System.currentTimeMillis()); if (StringUtils.isBlank(apiTestCaseWithBLOBs.getStatus())) { - apiTestCaseWithBLOBs.setStatus(APITestStatus.Underway.name()); + apiTestCaseWithBLOBs.setStatus(APITestStatus.Prepare.name()); + } + if (StringUtils.isBlank(apiTestCaseWithBLOBs.getCaseStatus())) { + apiTestCaseWithBLOBs.setCaseStatus(APITestStatus.Prepare.name()); + } + if (StringUtils.isBlank(apiTestCaseWithBLOBs.getCreateUserId())) { + apiTestCaseWithBLOBs.setCreateUserId(apiDefinition.getUserId()); } if (apiTestCaseWithBLOBs.getOrder() == null) { apiTestCaseWithBLOBs.setOrder(getImportNextCaseOrder(apiDefinition.getProjectId())); } + if (apiTestCaseWithBLOBs.getNum() == null) { + apiTestCaseWithBLOBs.setNum(testCaseService.getNextNum(apiDefinition.getId())); + } if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) { apiTestCaseMapper.updateByPrimaryKeyWithBLOBs(apiTestCaseWithBLOBs); } else { diff --git a/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java b/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java index 7508808a2b..690713b8e4 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java +++ b/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java @@ -1,5 +1,5 @@ package io.metersphere.commons.constants; public enum APITestStatus { - Saved, Starting, Running, Reporting, Completed, Debug, Error, Success,Underway,Waiting + Saved, Starting, Running, Reporting, Completed, Debug, Error, Success, Underway, Waiting, Prepare } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 936b36c8e2..e6ce62bb85 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1830,7 +1830,7 @@ public class TestCaseService { * * @return */ - private int getNextNum(String projectId) { + public int getNextNum(String projectId) { TestCase testCase = extTestCaseMapper.getMaxNumByProjectId(projectId); if (testCase == null || testCase.getNum() == null) { return 100001;