parent
17d4c8af93
commit
823e92b8f8
|
@ -1231,12 +1231,10 @@ public class ApiAutomationService {
|
|||
private void _importCreate(List<ApiScenarioWithBLOBs> sameRequest, ApiScenarioMapper batchMapper, ExtApiScenarioMapper extApiScenarioMapper,
|
||||
ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper) {
|
||||
if (CollectionUtils.isEmpty(sameRequest)) {
|
||||
// 没有这个场景 新增
|
||||
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
|
||||
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
|
||||
if (scenarioWithBLOBs.getVersionId() != null && !scenarioWithBLOBs.getVersionId().equals("update")) {
|
||||
scenarioWithBLOBs.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
|
||||
// 导入时设置版本
|
||||
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
||||
if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("update")) {
|
||||
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
|
||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId());
|
||||
} else {
|
||||
|
@ -1244,24 +1242,17 @@ public class ApiAutomationService {
|
|||
}
|
||||
scenarioWithBLOBs.setLatest(true);
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(apiTestImportRequest.getUpdateVersionId())) {
|
||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
||||
scenarioWithBLOBs.setLatest(true); // 新增接口 latest = true
|
||||
scenarioWithBLOBs.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
|
||||
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
|
||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId());
|
||||
} else {
|
||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getDefaultVersion());
|
||||
}
|
||||
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||
}
|
||||
|
||||
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
|
||||
if (scenarioWithBLOBs.getOrder() == null) {
|
||||
scenarioWithBLOBs.setOrder(getImportNextOrder(scenarioWithBLOBs.getProjectId()));
|
||||
}
|
||||
if (scenarioWithBLOBs.getNum() == null) {
|
||||
scenarioWithBLOBs.setNum(getNextNum(scenarioWithBLOBs.getProjectId()));
|
||||
}
|
||||
if (scenarioWithBLOBs.getRefId() == null) {
|
||||
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
||||
}
|
||||
batchMapper.insert(scenarioWithBLOBs);
|
||||
apiScenarioReferenceIdService.saveApiAndScenarioRelation(scenarioWithBLOBs);
|
||||
extApiScenarioMapper.clearLatestVersion(scenarioWithBLOBs.getRefId());
|
||||
|
@ -1281,20 +1272,9 @@ public class ApiAutomationService {
|
|||
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
|
||||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
|
||||
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());
|
||||
}
|
||||
if (scenarioWithBLOBs.getOrder() == null) {
|
||||
scenarioWithBLOBs.setOrder(getImportNextOrder(scenarioWithBLOBs.getProjectId()));
|
||||
}
|
||||
if (scenarioWithBLOBs.getNum() == null) {
|
||||
scenarioWithBLOBs.setNum(getNextNum(scenarioWithBLOBs.getProjectId()));
|
||||
}
|
||||
if (scenarioWithBLOBs.getRefId() == null) {
|
||||
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
||||
}
|
||||
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());
|
||||
batchMapper.insert(scenarioWithBLOBs);
|
||||
} else {
|
||||
ApiScenarioWithBLOBs existScenario = scenarioOp.get();
|
||||
|
@ -1303,15 +1283,6 @@ public class ApiAutomationService {
|
|||
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
|
||||
scenarioWithBLOBs.setOrder(existScenario.getOrder());
|
||||
scenarioWithBLOBs.setNum(existScenario.getNum());
|
||||
if (scenarioWithBLOBs.getOrder() == null) {
|
||||
scenarioWithBLOBs.setOrder(getImportNextOrder(scenarioWithBLOBs.getProjectId()));
|
||||
}
|
||||
if (scenarioWithBLOBs.getNum() == null) {
|
||||
scenarioWithBLOBs.setNum(getNextNum(scenarioWithBLOBs.getProjectId()));
|
||||
}
|
||||
if (scenarioWithBLOBs.getRefId() == null) {
|
||||
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
|
||||
}
|
||||
batchMapper.updateByPrimaryKeyWithBLOBs(scenarioWithBLOBs);
|
||||
}
|
||||
checkReferenceCase(scenarioWithBLOBs, apiTestCaseMapper, apiDefinitionMapper);
|
||||
|
|
Loading…
Reference in New Issue