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 ebf56b3b64..4df6c31435 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -844,6 +844,12 @@ public class ApiDefinitionService { for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : caseList) { apiTestCaseWithBLOBs.setApiDefinitionId(apiDefinition.getId()); apiTestCaseWithBLOBs.setVersionId(apiDefinition.getVersionId()); + if (apiTestCaseWithBLOBs.getCreateTime() == null) { + apiTestCaseWithBLOBs.setCreateTime(System.currentTimeMillis()); + } + if (apiTestCaseWithBLOBs.getUpdateTime() == null) { + apiTestCaseWithBLOBs.setUpdateTime(System.currentTimeMillis()); + } if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) { apiTestCaseMapper.updateByPrimaryKeyWithBLOBs(apiTestCaseWithBLOBs); } else { 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 b9dd7a99d5..2acb915796 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -897,7 +897,9 @@ public class ApiModuleService extends NodeTreeService { apiDefinitionWithBLOBs.setLatest(v.getLatest()); apiDefinitionWithBLOBs.setCreateTime(v.getCreateTime()); //组合case - buildCaseList(oldCaseMap, caseNameMap, v); + if (caseNameMap != null) { + buildCaseList(oldCaseMap, caseNameMap, v); + } toUpdateList.add(apiDefinitionWithBLOBs); } }); @@ -934,7 +936,9 @@ public class ApiModuleService extends NodeTreeService { apiDefinitionWithBLOBs.setId(v.getId()); setApiParam(apiDefinitionWithBLOBs, updateVersionId, v); //组合case - buildCaseList(oldCaseMap, caseNameMap, v); + if (caseNameMap != null) { + buildCaseList(oldCaseMap, caseNameMap, v); + } toUpdateList.add(apiDefinitionWithBLOBs); } }); @@ -1076,7 +1080,9 @@ public class ApiModuleService extends NodeTreeService { //循环系统内重复接口 for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) { //组合case - buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs); + if (caseNameMap != null) { + buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs); + } ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs(); BeanUtils.copyBean(api, apiDefinitionWithBLOBs); @@ -1111,7 +1117,7 @@ public class ApiModuleService extends NodeTreeService { ApiTestCaseWithBLOBs apiTestCaseWithBLOBs1 = oldCaseNameMap.get(name); if (apiTestCaseWithBLOBs1 != null) { caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); - caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : caseWithBLOBs1.getVersion() + 1); + caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : apiTestCaseWithBLOBs1.getVersion() + 1); oldCaseNameMap.remove(name); } else { caseWithBLOBs1.setVersion(0); @@ -1124,7 +1130,11 @@ public class ApiModuleService extends NodeTreeService { private Map getDistinctCaseNameMap(Map> definitionIdCaseMAp, ApiDefinitionWithBLOBs apiDefinitionWithBLOBs) { List caseWithBLOBs = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId()); - return caseWithBLOBs.stream().collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase)); + if (caseWithBLOBs != null) { + return caseWithBLOBs.stream().collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase)); + } else { + return null; + } } private void startCover(List toUpdateList, List optionData, @@ -1139,7 +1149,9 @@ public class ApiModuleService extends NodeTreeService { Map caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs); for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) { //组合case - buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs); + if (caseNameMap != null) { + buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs); + } ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs(); BeanUtils.copyBean(api, apiDefinitionWithBLOBs);