diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java
index 1ea5523f52..3bfecbfc1b 100644
--- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java
+++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java
@@ -118,8 +118,7 @@ public abstract class MsTestElement {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId());
- element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() {
- });
+ element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() {});
hashTree.add(element);
} catch (Exception ex) {
ex.printStackTrace();
diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
index 50862bf5a0..21b416fb4e 100644
--- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
+++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
@@ -243,11 +243,9 @@ public class ApiAutomationService {
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
LinkedList elements = mapper.readValue(element.getString("hashTree"),
- new TypeReference>() {
- });
+ new TypeReference>() {});
LinkedList variables = mapper.readValue(element.getString("variables"),
- new TypeReference>() {
- });
+ new TypeReference>() {});
scenario.setHashTree(elements);
scenario.setVariables(variables);
LinkedList scenarios = new LinkedList<>();
@@ -285,8 +283,6 @@ public class ApiAutomationService {
ParameterConfig config = new ParameterConfig();
config.setConfig(envConfig);
HashTree hashTree = request.getTestElement().generateHashTree(config);
- request.getTestElement().getJmx(hashTree);
-
// 调用执行方法
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name());
createAPIReportResult(request.getId(), ReportTriggerMode.MANUAL.name());
diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue
index d2fc8f5ead..8b489609e5 100644
--- a/frontend/src/business/components/api/automation/ApiAutomation.vue
+++ b/frontend/src/business/components/api/automation/ApiAutomation.vue
@@ -1,14 +1,13 @@
-
@@ -21,7 +20,7 @@
:name="item.name"
closable>
-
+
@@ -53,7 +52,6 @@
return {
isHide: true,
activeName: 'default',
- currentProject: null,
currentModule: null,
moduleOptions: {},
tabs: [],
@@ -102,9 +100,6 @@
initTree(data) {
this.moduleOptions = data;
},
- changeProject(data) {
- this.currentProject = data;
- },
refresh(data) {
this.$refs.apiScenarioList.search(data);
},
diff --git a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue
index 93cb4b3852..3b826f7de1 100644
--- a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue
+++ b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue
@@ -58,9 +58,8 @@
diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
index 230e296b21..6826a1b471 100644
--- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
+++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
@@ -187,7 +187,7 @@
-
+
@@ -245,7 +245,7 @@
-
+
@@ -263,7 +263,7 @@
@runRefresh="runRefresh" ref="runTest"/>
-
+
@@ -286,7 +286,7 @@
import MsApiComponent from "./ApiComponent";
import {ELEMENTS, ELEMENT_TYPE} from "./Setting";
import MsApiCustomize from "./ApiCustomize";
- import {getUUID} from "@/common/js/utils";
+ import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
import MsAddTag from "./AddTag";
import MsRun from "./DebugRun";
@@ -295,12 +295,10 @@
import MsApiReportDetail from "../report/ApiReportDetail";
import MsScenarioParameters from "./ScenarioParameters";
-
export default {
name: "EditApiScenario",
props: {
moduleOptions: Array,
- currentProject: {},
currentScenario: {},
},
components: {
@@ -350,9 +348,11 @@
path: "/api/automation/create",
debugData: {},
reportId: "",
+ projectId: "",
}
},
created() {
+ this.projectId = getCurrentProjectID();
this.operatingElements = ELEMENTS.get("ALL");
this.getMaintainerOptions();
this.refreshTags();
@@ -514,14 +514,14 @@
},
openTagConfig() {
- if (!this.currentProject) {
+ if (!this.projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
- this.$refs.tag.open(this.currentProject.id);
+ this.$refs.tag.open();
},
refreshTags() {
- let obj = {projectId: this.currentProject.id};
+ let obj = {projectId: this.projectId};
let tagIds = [];
this.$post('/api/tag/list', obj, response => {
this.tags = response.data;
@@ -562,8 +562,8 @@
this.reportId = getUUID().substring(0, 8);
},
getEnvironments() {
- if (this.currentProject) {
- this.$get('/api/environment/list/' + this.currentProject.id, response => {
+ if (this.projectId) {
+ this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
@@ -572,11 +572,11 @@
}
},
openEnvironmentConfig() {
- if (!this.currentProject) {
+ if (!this.projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
- this.$refs.environmentConfig.open(this.currentProject.id);
+ this.$refs.environmentConfig.open(this.projectId);
},
environmentConfigClose() {
this.getEnvironments();
@@ -696,7 +696,7 @@
}
},
setParameter() {
- this.currentScenario.projectId = this.currentProject.id;
+ this.currentScenario.projectId = this.projectId;
if (!this.currentScenario.id) {
this.currentScenario.id = getUUID();
}
diff --git a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue
index 6ea4043675..01c1ab5daa 100644
--- a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue
+++ b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue
@@ -1,12 +1,11 @@
-
{{$t('api_test.definition.request.req_param')}}
-
+
@@ -45,7 +45,6 @@
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: {
currentProtocol: String,
- currentProject: {},
scenario: Boolean,
},
data() {
diff --git a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue
index 9402c1930b..bdc212dc8d 100644
--- a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue
+++ b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue
@@ -12,7 +12,7 @@
{{$t('api_test.definition.request.req_param')}}
-
+
@@ -47,7 +47,6 @@
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: {
currentProtocol: String,
- currentProject: {},
scenario: Boolean,
},
data() {
diff --git a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue
index f014471d7a..3b7fc786ea 100644
--- a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue
+++ b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue
@@ -12,7 +12,7 @@
{{$t('api_test.definition.request.req_param')}}
-
+
@@ -46,7 +46,6 @@
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: {
currentProtocol: String,
- currentProject: {},
scenario: Boolean,
},
data() {
diff --git a/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue b/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue
index 8708e589e9..70951e5aa8 100644
--- a/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue
+++ b/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue
@@ -117,7 +117,6 @@
props: {
request: {},
basisData: {},
- currentProject: {},
moduleOptions: Array,
isReadOnly: {
type: Boolean,
diff --git a/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue b/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue
index df5163a423..9b380867b3 100644
--- a/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue
+++ b/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue
@@ -100,7 +100,6 @@
props: {
request: {},
basisData: {},
- currentProject: {},
moduleOptions: Array,
isReadOnly: {
type: Boolean,
@@ -148,10 +147,6 @@
})
},
validateApi() {
- if (this.currentProject === null) {
- this.$error(this.$t('api_test.select_project'), 2000);
- return;
- }
this.$refs['basicForm'].validate();
},
saveApi() {
@@ -185,6 +180,7 @@
/deep/ .el-form-item {
margin-bottom: 15px;
}
+
.ms-left-cell {
margin-top: 40px;
}
diff --git a/frontend/src/business/components/api/definition/components/request/tcp/BasisParameters.vue b/frontend/src/business/components/api/definition/components/request/tcp/BasisParameters.vue
index 04110a6ed3..b98b266794 100644
--- a/frontend/src/business/components/api/definition/components/request/tcp/BasisParameters.vue
+++ b/frontend/src/business/components/api/definition/components/request/tcp/BasisParameters.vue
@@ -132,6 +132,7 @@
import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig";
import {API_STATUS} from "../../../model/JsonData";
import TCPSampler from "../../jmeter/components/sampler/tcp-sampler";
+ import {getCurrentProjectID} from "@/common/js/utils";
export default {
name: "MsDatabaseConfig",
@@ -143,7 +144,6 @@
props: {
request: {},
basisData: {},
- currentProject: {},
moduleOptions: Array,
isReadOnly: {
type: Boolean,
@@ -156,6 +156,7 @@
classes: TCPSampler.CLASSES,
isReloadData: false,
options: API_STATUS,
+ currentProjectId: "",
rules: {
classname: [{required: true, message: "请选择TCPClient", trigger: 'change'}],
server: [{required: true, message: this.$t('api_test.request.tcp.server_cannot_be_empty'), trigger: 'blur'}],
@@ -164,6 +165,7 @@
}
},
created() {
+ this.currentProjectId = getCurrentProjectID();
this.getEnvironments();
},
methods: {
@@ -199,7 +201,7 @@
})
},
validateApi() {
- if (this.currentProject === null) {
+ if (this.currentProjectId === null) {
this.$error(this.$t('api_test.select_project'), 2000);
return;
}
@@ -213,7 +215,7 @@
},
validate() {
- if (this.currentProject === null) {
+ if (this.currentProjectId === null) {
this.$error(this.$t('api_test.select_project'), 2000);
return;
}
@@ -224,9 +226,9 @@
})
},
getEnvironments() {
- if (this.currentProject) {
+ if (this.currentProjectId) {
this.environments = [];
- this.$get('/api/environment/list/' + this.currentProject.id, response => {
+ this.$get('/api/environment/list/' + this.currentProjectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
@@ -236,11 +238,11 @@
}
},
openEnvironmentConfig() {
- if (!this.currentProject) {
+ if (!this.currentProjectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
- this.$refs.environmentConfig.open(this.currentProject.id);
+ this.$refs.environmentConfig.open(this.currentProjectId);
},
initDataSource() {
for (let i in this.environments) {
diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js
index 21c400e748..41ee406e5e 100644
--- a/frontend/src/common/js/utils.js
+++ b/frontend/src/common/js/utils.js
@@ -6,7 +6,8 @@ import {
ROLE_TEST_MANAGER,
ROLE_TEST_USER,
ROLE_TEST_VIEWER,
- TokenKey
+ TokenKey,
+ PROJECT_ID
} from "./constants";
import axios from "axios";
import {jsPDF} from "jspdf";
@@ -88,6 +89,10 @@ export function getCurrentUser() {
return JSON.parse(localStorage.getItem(TokenKey));
}
+export function getCurrentProjectID() {
+ return localStorage.getItem(PROJECT_ID);
+}
+
export function saveLocalStorage(response) {
// 登录信息保存 cookie
localStorage.setItem(TokenKey, JSON.stringify(response.data));