fix(接口自动化): 修复场景复制缺陷
This commit is contained in:
parent
3d1b39e592
commit
8ac28a233f
|
@ -34,8 +34,8 @@ public class ApiAutomationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/create")
|
@PostMapping(value = "/create")
|
||||||
public void create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||||
apiAutomationService.create(request, bodyFiles);
|
return apiAutomationService.create(request, bodyFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/update")
|
@PostMapping(value = "/update")
|
||||||
|
|
|
@ -100,11 +100,12 @@ public class ApiAutomationService {
|
||||||
apiScenarioMapper.deleteByExample(example);
|
apiScenarioMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
public ApiScenario create(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
||||||
|
request.setId(UUID.randomUUID().toString());
|
||||||
checkNameExist(request);
|
checkNameExist(request);
|
||||||
|
|
||||||
final ApiScenario scenario = new ApiScenario();
|
final ApiScenario scenario = new ApiScenario();
|
||||||
scenario.setId(UUID.randomUUID().toString());
|
scenario.setId(request.getId());
|
||||||
scenario.setName(request.getName());
|
scenario.setName(request.getName());
|
||||||
scenario.setProjectId(request.getProjectId());
|
scenario.setProjectId(request.getProjectId());
|
||||||
scenario.setTagId(request.getTagId());
|
scenario.setTagId(request.getTagId());
|
||||||
|
@ -132,6 +133,7 @@ public class ApiAutomationService {
|
||||||
|
|
||||||
List<String> bodyUploadIds = request.getBodyUploadIds();
|
List<String> bodyUploadIds = request.getBodyUploadIds();
|
||||||
apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles);
|
apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||||
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
public void update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
||||||
|
@ -248,7 +250,7 @@ public class ApiAutomationService {
|
||||||
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
|
||||||
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
||||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||||
if (element!= null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||||
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
||||||
new TypeReference<LinkedList<MsTestElement>>() {
|
new TypeReference<LinkedList<MsTestElement>>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 61397c16728a63493507679f7e0940d9099f337f
|
Subproject commit 1fe20ba15a7ca3fe9f77ddf866021e7c7dfe5969
|
|
@ -240,7 +240,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
copy(row) {
|
copy(row) {
|
||||||
row.id = getUUID();
|
row.copy = true;
|
||||||
this.$emit('edit', row);
|
this.$emit('edit', row);
|
||||||
},
|
},
|
||||||
showReport(row) {
|
showReport(row) {
|
||||||
|
|
|
@ -694,9 +694,12 @@
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.setParameter();
|
this.setParameter();
|
||||||
let bodyFiles = this.getBodyUploadFiles(this.currentScenario);
|
let bodyFiles = this.getBodyUploadFiles(this.currentScenario);
|
||||||
this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, () => {
|
this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
this.path = "/api/automation/update";
|
this.path = "/api/automation/update";
|
||||||
|
if (response.data) {
|
||||||
|
this.currentScenario.id = response.data.id;
|
||||||
|
}
|
||||||
this.currentScenario.tagId = JSON.parse(this.currentScenario.tagId);
|
this.currentScenario.tagId = JSON.parse(this.currentScenario.tagId);
|
||||||
this.$emit('refresh');
|
this.$emit('refresh');
|
||||||
})
|
})
|
||||||
|
@ -719,6 +722,9 @@
|
||||||
this.scenarioDefinition = obj.hashTree;
|
this.scenarioDefinition = obj.hashTree;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.currentScenario.copy) {
|
||||||
|
this.path = "/api/automation/create";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue