This commit is contained in:
fit2-zhao 2021-03-08 17:00:39 +08:00
commit 44422224ca
3 changed files with 22 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.api.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -102,8 +103,13 @@ public class ApiAutomationService {
Map<String, String> map = d.getEnvironmentMap();
List<String> idList = new ArrayList<>();
if (map != null) {
Set<String> set = d.getEnvironmentMap().keySet();
idList = new ArrayList<>(set);
if (map.isEmpty()) {
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
idList.addAll(new HashSet<>(ids));
} else {
Set<String> set = d.getEnvironmentMap().keySet();
idList = new ArrayList<>(set);
}
} else {
// 兼容历史数据无EnvironmentMap直接赋值场景所属项目
idList.add(data.getProjectId());

View File

@ -1,6 +1,7 @@
package io.metersphere.track.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONPath;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.automation.RunScenarioRequest;
@ -56,8 +57,13 @@ public class TestPlanScenarioCaseService {
Map<String, String> map = d.getEnvironmentMap();
List<String> idList = new ArrayList<>();
if (map != null) {
Set<String> set = d.getEnvironmentMap().keySet();
idList = new ArrayList<>(set);
if (map.isEmpty()) {
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
idList.addAll(new HashSet<>(ids));
} else {
Set<String> set = d.getEnvironmentMap().keySet();
idList = new ArrayList<>(set);
}
} else {
// 兼容历史数据无EnvironmentMap直接赋值场景所属项目
idList.add(data.getProjectId());

View File

@ -1001,10 +1001,12 @@
},
initProjectIds() {
//
this.projectIds.clear();
this.scenarioDefinition.forEach(data=>{
let arr = jsonPath.query(data, "$..projectId");
arr.forEach(a => this.projectIds.add(a));
this.$nextTick(() => {
this.projectIds.clear();
this.scenarioDefinition.forEach(data=>{
let arr = jsonPath.query(data, "$..projectId");
arr.forEach(a => this.projectIds.add(a));
})
})
}
}