diff --git a/framework/sdk-parent/frontend/src/api/environment.js b/framework/sdk-parent/frontend/src/api/environment.js index 4a63dd0e48..c71f239a77 100644 --- a/framework/sdk-parent/frontend/src/api/environment.js +++ b/framework/sdk-parent/frontend/src/api/environment.js @@ -121,6 +121,13 @@ export function getApiDocument(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) { if (currentModuleName === 'api') { 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); } + +export function getTestCaseBLOBs(params) { + if (currentModuleName === 'api') { + return post('/api/testcase/list-blobs', params); + } + return post('/environment/relate/api/testcase/list-blobs', params); +} // diff --git a/framework/sdk-parent/frontend/src/components/environment/snippet/ApiFuncRelevance.vue b/framework/sdk-parent/frontend/src/components/environment/snippet/ApiFuncRelevance.vue index 9cffb6ddec..ff1a7dd682 100644 --- a/framework/sdk-parent/frontend/src/components/environment/snippet/ApiFuncRelevance.vue +++ b/framework/sdk-parent/frontend/src/components/environment/snippet/ApiFuncRelevance.vue @@ -54,6 +54,7 @@ import RelevanceApiList from "./ext/RelevanceApiList"; import MsApiModule from "./ext/module/ApiModule"; import TestCaseRelevanceBase from "./ext/TestCaseRelevanceBase"; import {parseEnvironment} from "../../../model/EnvironmentModel"; +import {batchGetApiDefinition, getEnvironmentById, getTestCaseBLOBs} from "../../../api/environment"; export default { name: "ApiFuncRelevance", @@ -177,39 +178,34 @@ export default { }, save() { - let url = ''; let environmentId = undefined; - let selectIds = []; if (this.isApiListEnable) { //查找所有数据 let params = this.$refs.apiList.getConditions(); - // todo ajax - this.result = this.$post("/api/definition/list/batch", params, (response) => { + batchGetApiDefinition(params).then(response => { let apis = response.data; - url = '/api/definition/relevance'; environmentId = this.$refs.apiList.environmentId; if (!environmentId) { this.$warning(this.$t('api_test.environment.select_environment')); return; } - this.$get('/api/environment/get/' + environmentId, response => { - let environment = response.data; + getEnvironmentById(environmentId).then(res => { + let environment = res.data; parseEnvironment(environment); this.$emit("save", apis, environment); }); - }); + }) } else { 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; - url = '/api/testcase/relevance'; environmentId = this.$refs.apiCaseList.environmentId; if (!environmentId) { this.$warning(this.$t('api_test.environment.select_environment')); return; } - this.$get('/api/environment/get/' + environmentId, response => { - let environment = response.data; + getEnvironmentById(environmentId).then(res => { + let environment = res.data; parseEnvironment(environment); this.$emit("save", apiCases, environment); }); diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/controller/EnvironmentRelateController.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/controller/EnvironmentRelateController.java index 6aa7c07aef..af87996e93 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/controller/EnvironmentRelateController.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/environment/controller/EnvironmentRelateController.java @@ -23,6 +23,16 @@ public class EnvironmentRelateController { 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") public Object jsonGenerator(@RequestBody Object obj) { return microService.postForData(MicroServiceName.API_TEST, "/api/definition/generator", obj);