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 d7740b1d7f..01727910c3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1211,7 +1211,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()); @@ -1248,7 +1248,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 2d28fa4de5..e2c2ff87fc 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -853,11 +853,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 011d5050b3..54433ee1d2 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,Rerunning + Saved, Starting, Running, Reporting, Completed, Debug, Error, Success, Underway, Waiting, Rerunning, 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 b4d9d2e766..90d17407b9 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1904,7 +1904,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;