fix(项目设置): 代码片段导入接口无响应

--bug=1017752 --user=李玉号 代码片段从接口定义导入case,点击确定无响应
https://www.tapd.cn/55049933/s/1258278
This commit is contained in:
shiziyuan9527 2022-10-11 15:59:02 +08:00 committed by lyh
parent 897af4dab7
commit 87877bbdfa
3 changed files with 32 additions and 12 deletions

View File

@ -121,6 +121,13 @@ export function getApiDocument(id, type) {
return get('/environment/relate/api/definition/document/' + id + '/' + type); return get('/environment/relate/api/definition/document/' + id + '/' + type);
} }
export function batchGetApiDefinition(obj) {
if (currentModuleName === 'api') {
return post('/api/definition/list/batch', obj);
}
return post('/environment/relate/api/definition/list/batch', obj);
}
export function jsonGenerator(params) { export function jsonGenerator(params) {
if (currentModuleName === 'api') { if (currentModuleName === 'api') {
return post('/api/definition/generator', params); return post('/api/definition/generator', params);
@ -176,4 +183,11 @@ export function getApiTestCasePages(goPage, pageSize, param) {
} }
return post(`/environment/relate/api/testcase/list/${goPage}/${pageSize}`, param); return post(`/environment/relate/api/testcase/list/${goPage}/${pageSize}`, param);
} }
export function getTestCaseBLOBs(params) {
if (currentModuleName === 'api') {
return post('/api/testcase/list-blobs', params);
}
return post('/environment/relate/api/testcase/list-blobs', params);
}
// //

View File

@ -54,6 +54,7 @@ import RelevanceApiList from "./ext/RelevanceApiList";
import MsApiModule from "./ext/module/ApiModule"; import MsApiModule from "./ext/module/ApiModule";
import TestCaseRelevanceBase from "./ext/TestCaseRelevanceBase"; import TestCaseRelevanceBase from "./ext/TestCaseRelevanceBase";
import {parseEnvironment} from "../../../model/EnvironmentModel"; import {parseEnvironment} from "../../../model/EnvironmentModel";
import {batchGetApiDefinition, getEnvironmentById, getTestCaseBLOBs} from "../../../api/environment";
export default { export default {
name: "ApiFuncRelevance", name: "ApiFuncRelevance",
@ -177,39 +178,34 @@ export default {
}, },
save() { save() {
let url = '';
let environmentId = undefined; let environmentId = undefined;
let selectIds = [];
if (this.isApiListEnable) { if (this.isApiListEnable) {
// //
let params = this.$refs.apiList.getConditions(); let params = this.$refs.apiList.getConditions();
// todo ajax batchGetApiDefinition(params).then(response => {
this.result = this.$post("/api/definition/list/batch", params, (response) => {
let apis = response.data; let apis = response.data;
url = '/api/definition/relevance';
environmentId = this.$refs.apiList.environmentId; environmentId = this.$refs.apiList.environmentId;
if (!environmentId) { if (!environmentId) {
this.$warning(this.$t('api_test.environment.select_environment')); this.$warning(this.$t('api_test.environment.select_environment'));
return; return;
} }
this.$get('/api/environment/get/' + environmentId, response => { getEnvironmentById(environmentId).then(res => {
let environment = response.data; let environment = res.data;
parseEnvironment(environment); parseEnvironment(environment);
this.$emit("save", apis, environment); this.$emit("save", apis, environment);
}); });
}); })
} else { } else {
let params = this.$refs.apiCaseList.getConditions(); let params = this.$refs.apiCaseList.getConditions();
this.result = this.$post("/api/testcase/get/caseBLOBs/request", params, (response) => { getTestCaseBLOBs(params).then(response => {
let apiCases = response.data; let apiCases = response.data;
url = '/api/testcase/relevance';
environmentId = this.$refs.apiCaseList.environmentId; environmentId = this.$refs.apiCaseList.environmentId;
if (!environmentId) { if (!environmentId) {
this.$warning(this.$t('api_test.environment.select_environment')); this.$warning(this.$t('api_test.environment.select_environment'));
return; return;
} }
this.$get('/api/environment/get/' + environmentId, response => { getEnvironmentById(environmentId).then(res => {
let environment = response.data; let environment = res.data;
parseEnvironment(environment); parseEnvironment(environment);
this.$emit("save", apiCases, environment); this.$emit("save", apiCases, environment);
}); });

View File

@ -23,6 +23,16 @@ public class EnvironmentRelateController {
return microService.getForData(MicroServiceName.API_TEST, "/api/definition/document/" + id + "/" + type); return microService.getForData(MicroServiceName.API_TEST, "/api/definition/document/" + id + "/" + type);
} }
@PostMapping("/api/definition/list/batch")
public Object listBatch(@RequestBody Object obj) {
return microService.postForData(MicroServiceName.API_TEST, "/api/definition/generator", obj);
}
@PostMapping("/api/testcase/list-blobs")
public Object getCaseBLOBs(@RequestBody Object obj) {
return microService.postForData(MicroServiceName.API_TEST, "/api/testcase/list-blobs", obj);
}
@PostMapping("/api/definition/generator") @PostMapping("/api/definition/generator")
public Object jsonGenerator(@RequestBody Object obj) { public Object jsonGenerator(@RequestBody Object obj) {
return microService.postForData(MicroServiceName.API_TEST, "/api/definition/generator", obj); return microService.postForData(MicroServiceName.API_TEST, "/api/definition/generator", obj);