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 f33e7f945a..4fa97a6308 100644
--- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
+++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
@@ -1330,6 +1330,7 @@ public class ApiAutomationService {
scenarioWithBLOBs.setRefId(sameRequest.get(0).getRefId() == null ? sameRequest.get(0).getId() : sameRequest.get(0).getRefId());
scenarioWithBLOBs.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num
scenarioWithBLOBs.setOrder(sameRequest.get(0).getOrder());
+ checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
sendImportScenarioCreateNotice(scenarioWithBLOBs);
batchMapper.insert(scenarioWithBLOBs);
} else {
@@ -1339,10 +1340,10 @@ public class ApiAutomationService {
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
scenarioWithBLOBs.setOrder(existScenario.getOrder());
scenarioWithBLOBs.setNum(existScenario.getNum());
+ checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
sendImportScenarioUpdateNotice(scenarioWithBLOBs);
batchMapper.updateByPrimaryKeyWithBLOBs(scenarioWithBLOBs);
}
- checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
apiScenarioReferenceIdService.saveApiAndScenarioRelation(scenarioWithBLOBs);
extApiScenarioMapper.clearLatestVersion(scenarioWithBLOBs.getRefId());
extApiScenarioMapper.addLatestVersion(scenarioWithBLOBs.getRefId());
@@ -1414,7 +1415,6 @@ public class ApiAutomationService {
} else {
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getDefaultVersion());
}
- checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
if (scenarioWithBLOBs.getOrder() == null) {
scenarioWithBLOBs.setOrder(getImportNextOrder(request.getProjectId()));
}
@@ -1424,6 +1424,7 @@ public class ApiAutomationService {
if (scenarioWithBLOBs.getRefId() == null) {
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
}
+ checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
sendImportScenarioCreateNotice(scenarioWithBLOBs);
batchMapper.insert(scenarioWithBLOBs);
// 存储依赖关系
diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
index d21522477c..a82761e88a 100644
--- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
+++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
@@ -880,19 +880,18 @@
select * from api_test_case
(api_test_case.status is null or api_test_case.status != 'Trash')
-
+
and name =#{request.name}
-
+
and api_definition_id =#{request.apiDefinitionId}
-
+
and id !=#{request.id}
-
+
and version_id =#{request.versionId}
-