Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
be2699f1dc
|
@ -86,7 +86,7 @@ public class ApiAutomationController {
|
|||
}
|
||||
|
||||
@GetMapping("/getApiScenario/{id}")
|
||||
public ApiScenario getScenarioDefinition(@PathVariable String id) {
|
||||
public ApiScenarioDTO getScenarioDefinition(@PathVariable String id) {
|
||||
return apiAutomationService.getApiScenario(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,6 @@ public class ApiScenarioDTO extends ApiScenarioWithBLOBs {
|
|||
* 场景跨项目ID
|
||||
*/
|
||||
private List<String> projectIds;
|
||||
|
||||
private String caseId;
|
||||
}
|
||||
|
|
|
@ -94,18 +94,15 @@ public class ApiAutomationService {
|
|||
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
||||
request = this.initRequest(request, true, true);
|
||||
List<ApiScenarioDTO> list = extApiScenarioMapper.list(request);
|
||||
setApiScenarioProjectIds(list);
|
||||
return list;
|
||||
}
|
||||
public List<ApiScenarioDTO> listReview(ApiScenarioRequest request) {
|
||||
request = this.initRequest(request, true, true);
|
||||
List<ApiScenarioDTO> list = extApiScenarioMapper.listReview(request);
|
||||
setApiScenarioProjectIds(list);
|
||||
return list;
|
||||
}
|
||||
private void setApiScenarioProjectIds(List<ApiScenarioDTO> list) {
|
||||
private void setApiScenarioProjectIds(ApiScenarioDTO data) {
|
||||
// 如果场景步骤涉及多项目,则把涉及到的项目ID保存在projectIds属性
|
||||
list.forEach(data -> {
|
||||
List<String> idList = new ArrayList<>();
|
||||
String definition = data.getScenarioDefinition();
|
||||
if (StringUtils.isNotBlank(definition)) {
|
||||
|
@ -129,7 +126,6 @@ public class ApiAutomationService {
|
|||
|
||||
}
|
||||
data.setProjectIds(idList);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -333,8 +329,12 @@ public class ApiAutomationService {
|
|||
}
|
||||
}
|
||||
|
||||
public ApiScenarioWithBLOBs getApiScenario(String id) {
|
||||
return apiScenarioMapper.selectByPrimaryKey(id);
|
||||
public ApiScenarioDTO getApiScenario(String id) {
|
||||
ApiScenarioDTO apiScenarioDTO = new ApiScenarioDTO();
|
||||
ApiScenarioWithBLOBs scenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(id);
|
||||
BeanUtils.copyBean(apiScenarioDTO, scenarioWithBLOBs);
|
||||
setApiScenarioProjectIds(apiScenarioDTO);
|
||||
return apiScenarioDTO;
|
||||
}
|
||||
|
||||
public List<ApiScenarioWithBLOBs> getApiScenarios(List<String> ids) {
|
||||
|
|
|
@ -134,7 +134,6 @@
|
|||
</sql>
|
||||
<select id="list" resultMap="BaseResultMap">
|
||||
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
|
||||
api_scenario.scenario_definition,
|
||||
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
|
||||
api_scenario.status, api_scenario.principal, api_scenario.step_total, api_scenario.follow_people,
|
||||
api_scenario.last_result,api_scenario.pass_rate,api_scenario.report_id,
|
||||
|
@ -339,7 +338,6 @@
|
|||
</select>
|
||||
<select id="listReview" resultMap="BaseResultMap">
|
||||
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
|
||||
api_scenario.scenario_definition,
|
||||
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
|
||||
api_scenario.status, api_scenario.principal, api_scenario.step_total, api_scenario.follow_people,
|
||||
api_scenario.last_result,api_scenario.pass_rate,api_scenario.report_id,
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
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;
|
||||
import io.metersphere.api.dto.automation.TestPlanScenarioRequest;
|
||||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
import io.metersphere.api.service.ApiScenarioReportService;
|
||||
import io.metersphere.base.domain.TestCaseReviewScenario;
|
||||
import io.metersphere.base.domain.TestCaseReviewScenarioExample;
|
||||
import io.metersphere.base.domain.TestPlanApiScenario;
|
||||
import io.metersphere.base.domain.TestPlanApiScenarioExample;
|
||||
import io.metersphere.base.mapper.TestCaseReviewScenarioMapper;
|
||||
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestCaseReviewScenarioCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.track.dto.RelevanceScenarioRequest;
|
||||
|
@ -45,46 +39,15 @@ public class TestCaseReviewScenarioCaseService {
|
|||
request.setProjectId(null);
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
List<ApiScenarioDTO> apiTestCases = extTestCaseReviewScenarioCaseMapper.list(request);
|
||||
setApiScenarioProjectIds(apiTestCases);
|
||||
if (CollectionUtils.isEmpty(apiTestCases)) {
|
||||
return apiTestCases;
|
||||
}
|
||||
return apiTestCases;
|
||||
}
|
||||
|
||||
private void setApiScenarioProjectIds(List<ApiScenarioDTO> list) {
|
||||
// 如果场景步骤涉及多项目,则把涉及到的项目ID保存在projectIds属性
|
||||
list.forEach(data -> {
|
||||
List<String> idList = new ArrayList<>();
|
||||
String definition = data.getScenarioDefinition();
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(definition)) {
|
||||
RunDefinitionRequest d = JSON.parseObject(definition, RunDefinitionRequest.class);
|
||||
|
||||
if (d != null) {
|
||||
Map<String, String> map = d.getEnvironmentMap();
|
||||
if (map != null) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
data.setProjectIds(idList);
|
||||
});
|
||||
}
|
||||
|
||||
public List<ApiScenarioDTO> relevanceList(ApiScenarioRequest request) {
|
||||
request.setNotInTestPlan(true);
|
||||
List<ApiScenarioDTO> list = apiAutomationService.listReview(request);
|
||||
setApiScenarioProjectIds(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,46 +42,15 @@ public class TestPlanScenarioCaseService {
|
|||
request.setProjectId(null);
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
List<ApiScenarioDTO> apiTestCases = extTestPlanScenarioCaseMapper.list(request);
|
||||
setApiScenarioProjectIds(apiTestCases);
|
||||
if (CollectionUtils.isEmpty(apiTestCases)) {
|
||||
return apiTestCases;
|
||||
}
|
||||
return apiTestCases;
|
||||
}
|
||||
|
||||
private void setApiScenarioProjectIds(List<ApiScenarioDTO> list) {
|
||||
// 如果场景步骤涉及多项目,则把涉及到的项目ID保存在projectIds属性
|
||||
list.forEach(data -> {
|
||||
List<String> idList = new ArrayList<>();
|
||||
String definition = data.getScenarioDefinition();
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(definition)) {
|
||||
RunDefinitionRequest d = JSON.parseObject(definition, RunDefinitionRequest.class);
|
||||
|
||||
if (d != null) {
|
||||
Map<String, String> map = d.getEnvironmentMap();
|
||||
if (map != null) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
data.setProjectIds(idList);
|
||||
});
|
||||
}
|
||||
|
||||
public List<ApiScenarioDTO> relevanceList(ApiScenarioRequest request) {
|
||||
request.setNotInTestPlan(true);
|
||||
List<ApiScenarioDTO> list = apiAutomationService.list(request);
|
||||
setApiScenarioProjectIds(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -439,7 +439,7 @@
|
|||
},
|
||||
handleBatchEdit() {
|
||||
this.$refs.batchEdit.open(this.selectDataCounts);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows, "scenario");
|
||||
},
|
||||
handleBatchMove() {
|
||||
this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
|
||||
|
@ -457,11 +457,7 @@
|
|||
// 批量修改环境
|
||||
if (form.type === 'projectEnv') {
|
||||
let param = {};
|
||||
let map = new Map();
|
||||
this.selectRows.forEach(row => {
|
||||
map.set(row.id, row.projectIds);
|
||||
})
|
||||
param.mapping = strMapToObj(map);
|
||||
param.mapping = strMapToObj(form.map);
|
||||
param.envMap = strMapToObj(form.projectEnvMap);
|
||||
this.$post('/api/automation/batch/update/env', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
|
@ -519,11 +515,7 @@
|
|||
|
||||
this.planVisible = false;
|
||||
|
||||
let map = new Map();
|
||||
this.selectRows.forEach(row => {
|
||||
map.set(row.id, row.projectIds);
|
||||
})
|
||||
obj.mapping = strMapToObj(map);
|
||||
obj.mapping = strMapToObj(params[2]);
|
||||
obj.envMap = strMapToObj(params[1]);
|
||||
|
||||
this.$post("/api/automation/scenario/plan", obj, response => {
|
||||
|
|
|
@ -195,7 +195,8 @@ export default {
|
|||
],
|
||||
projectEnvMap: new Map(),
|
||||
projectList: [],
|
||||
projectIds: new Set()
|
||||
projectIds: new Set(),
|
||||
map: new Map(),
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -221,7 +222,7 @@ export default {
|
|||
if (!sign) {
|
||||
return false;
|
||||
}
|
||||
this.$emit('addTestPlan', this.selection, this.projectEnvMap);
|
||||
this.$emit('addTestPlan', this.selection, this.projectEnvMap, this.map);
|
||||
}
|
||||
},
|
||||
cancel(){
|
||||
|
@ -237,7 +238,11 @@ export default {
|
|||
setScenarioSelectRows(rows) {
|
||||
this.projectIds.clear();
|
||||
rows.forEach(row => {
|
||||
row.projectIds.forEach(id => this.projectIds.add(id));
|
||||
this.result = this.$get('/api/automation/getApiScenario/' + row.id, res => {
|
||||
let data = res.data;
|
||||
data.projectIds.forEach(d => this.projectIds.add(d));
|
||||
this.map.set(row.id, data.projectIds);
|
||||
})
|
||||
})
|
||||
},
|
||||
initTableData() {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
class="batch-edit-dialog"
|
||||
:destroy-on-close="true"
|
||||
@close="handleClose"
|
||||
v-loading="result.loading"
|
||||
>
|
||||
<el-form :model="form" label-position="right" label-width="150px" size="medium" ref="form" :rules="rules">
|
||||
<el-form-item :label="$t('test_track.case.batch_update', [size])" prop="type">
|
||||
|
@ -72,7 +73,10 @@
|
|||
projectList: [],
|
||||
projectIds: new Set(),
|
||||
selectRows: new Set(),
|
||||
projectEnvMap: new Map()
|
||||
projectEnvMap: new Map(),
|
||||
map: new Map(),
|
||||
isScenario: '',
|
||||
result: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -84,6 +88,7 @@
|
|||
if (!this.$refs.envPopover.checkEnv()) {
|
||||
return false;
|
||||
}
|
||||
this.form.map = this.map;
|
||||
}
|
||||
this.$emit("batchEdit", this.form);
|
||||
this.dialogVisible = false;
|
||||
|
@ -113,12 +118,9 @@
|
|||
this.projectIds.add(row.projectId)
|
||||
})
|
||||
},
|
||||
setScenarioSelectRows(rows) {
|
||||
setScenarioSelectRows(rows, sign) {
|
||||
this.selectRows = rows;
|
||||
this.projectIds.clear();
|
||||
this.selectRows.forEach(row => {
|
||||
row.projectIds.forEach(id => this.projectIds.add(id));
|
||||
})
|
||||
this.isScenario = sign;
|
||||
},
|
||||
handleClose() {
|
||||
this.form = {};
|
||||
|
@ -127,6 +129,17 @@
|
|||
},
|
||||
changeType(val) {
|
||||
this.$set(this.form, "value", "");
|
||||
if (val === 'projectEnv' && this.isScenario !== '') {
|
||||
this.projectIds.clear();
|
||||
this.selectRows.forEach(row => {
|
||||
let id = this.isScenario === 'scenario' ? row.id : row.caseId;
|
||||
this.result = this.$get('/api/automation/getApiScenario/' + id, res => {
|
||||
let data = res.data;
|
||||
data.projectIds.forEach(d => this.projectIds.add(d));
|
||||
this.map.set(row.id, data.projectIds);
|
||||
})
|
||||
})
|
||||
}
|
||||
this.filterable = val === "maintainer" || val === "executor";
|
||||
this.options = this.valueArr[val];
|
||||
this.typeArr.forEach(item => {
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
projectEnvMap: new Map(),
|
||||
projectList: [],
|
||||
projectIds: new Set(),
|
||||
map: new Map()
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -159,8 +160,10 @@
|
|||
initProjectIds() {
|
||||
this.projectIds.clear();
|
||||
this.selectRows.forEach(row => {
|
||||
row.projectIds.forEach(id => {
|
||||
this.projectIds.add(id);
|
||||
this.result = this.$get('/api/automation/getApiScenario/' + row.id, res => {
|
||||
let data = res.data;
|
||||
data.projectIds.forEach(d => this.projectIds.add(d));
|
||||
this.map.set(row.id, data.projectIds);
|
||||
})
|
||||
})
|
||||
},
|
||||
|
|
|
@ -104,12 +104,8 @@
|
|||
}
|
||||
let param = {};
|
||||
let url = '/api/automation/relevance';
|
||||
let rows = this.$refs.apiScenarioList.selectRows;
|
||||
const envMap = this.$refs.apiScenarioList.projectEnvMap;
|
||||
let map = new Map();
|
||||
rows.forEach(row => {
|
||||
map.set(row.id, row.projectIds);
|
||||
})
|
||||
let map = this.$refs.apiScenarioList.map;
|
||||
param.planId = this.planId;
|
||||
param.mapping = strMapToObj(map);
|
||||
param.envMap = strMapToObj(envMap);
|
||||
|
|
|
@ -358,15 +358,11 @@ export default {
|
|||
},
|
||||
handleBatchEdit() {
|
||||
this.$refs.batchEdit.open(this.selectRows.size);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows, "planScenario");
|
||||
},
|
||||
batchEdit(form) {
|
||||
let param = {};
|
||||
let map = new Map();
|
||||
this.selectRows.forEach(row => {
|
||||
map.set(row.id, row.projectIds);
|
||||
})
|
||||
param.mapping = strMapToObj(map);
|
||||
param.mapping = strMapToObj(form.map);
|
||||
param.envMap = strMapToObj(form.projectEnvMap);
|
||||
if (this.planId) {
|
||||
this.$post('/test/plan/scenario/case/batch/update/env', param, () => {
|
||||
|
|
Loading…
Reference in New Issue