fix(接口测试): 接口自动化导入文件后查看用例存在显示id重复问题以及覆盖接口自动化用例导入问题

--user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001016870
This commit is contained in:
guoyuqi 2022-09-20 17:47:39 +08:00 committed by 刘瑞斌
parent 7bdefc783a
commit 9be815da39
2 changed files with 7 additions and 6 deletions

View File

@ -1300,6 +1300,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);
batchMapper.insert(scenarioWithBLOBs);
} else {
ApiScenarioWithBLOBs existScenario = scenarioOp.get();
@ -1308,9 +1309,9 @@ public class ApiAutomationService {
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
scenarioWithBLOBs.setOrder(existScenario.getOrder());
scenarioWithBLOBs.setNum(existScenario.getNum());
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
batchMapper.updateByPrimaryKeyWithBLOBs(scenarioWithBLOBs);
}
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
apiScenarioReferenceIdService.saveApiAndScenarioRelation(scenarioWithBLOBs);
extApiScenarioMapper.clearLatestVersion(scenarioWithBLOBs.getRefId());
extApiScenarioMapper.addLatestVersion(scenarioWithBLOBs.getRefId());
@ -1381,7 +1382,6 @@ public class ApiAutomationService {
} else {
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getDefaultVersion());
}
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
if (scenarioWithBLOBs.getOrder() == null) {
scenarioWithBLOBs.setOrder(getImportNextOrder(request.getProjectId()));
}
@ -1391,6 +1391,7 @@ public class ApiAutomationService {
if (scenarioWithBLOBs.getRefId() == null) {
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
}
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
batchMapper.insert(scenarioWithBLOBs);
// 存储依赖关系
ApiAutomationRelationshipEdgeService relationshipEdgeService = CommonBeanFactory.getBean(ApiAutomationRelationshipEdgeService.class);

View File

@ -827,16 +827,16 @@
select * from api_test_case
<where>
(api_test_case.status is null or api_test_case.status != 'Trash')
<if test="request.name !='' || request.name != null">
<if test="request.name !='' and request.name != null">
and name =#{request.name}
</if>
<if test="request.apiDefinitionId !='' || request.apiDefinitionId != null">
<if test="request.apiDefinitionId !='' and request.apiDefinitionId != null">
and api_definition_id =#{request.apiDefinitionId}
</if>
<if test="request.id !='' || request.id != null">
<if test="request.id !='' and request.id != null">
and id !=#{request.id}
</if>
<if test="request.versionId !='' || request.versionId != null">
<if test="request.versionId !='' and request.versionId != null">
and version_id =#{request.versionId}
</if>