提交 aeee3749 编写于 作者: S song-tianyang 提交者: BugKing

refactor: 修复测试场景批量修改环境的问题

修复测试场景批量修改环境的问题
上级 a71780e3
......@@ -51,6 +51,14 @@ public class ApiAutomationController {
return apiAutomationService.listAll(request);
}
@PostMapping("/listWithIds/all")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public List<ApiScenarioWithBLOBs> listWithIds(@RequestBody ApiScenarioBatchRequest request) {
return apiAutomationService.listWithIds(request);
}
@PostMapping("/id/all")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public List<String> idAll(@RequestBody ApiScenarioBatchRequest request) {
......
......@@ -1767,4 +1767,11 @@ public class ApiAutomationService {
public void updateCustomNumByProjectId(String id) {
extApiScenarioMapper.updateCustomNumByProjectId(id);
}
public List<ApiScenarioWithBLOBs> listWithIds(ApiScenarioBatchRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
List<ApiScenarioWithBLOBs> list = extApiScenarioMapper.listWithIds(request.getIds());
return list;
}
}
......@@ -43,4 +43,6 @@ public interface ExtApiScenarioMapper {
List<String> selectIdsByQuery(@Param("request") ApiScenarioRequest request);
void updateCustomNumByProjectId(@Param("projectId") String projectId);
List<ApiScenarioWithBLOBs> listWithIds(@Param("ids") List<String> ids);
}
......@@ -257,6 +257,13 @@
</foreach>
</select>
<select id="listWithIds" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
select id from api_scenario where id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</select>
<select id="selectByIds" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
select * from api_scenario where id in (${ids}) ORDER BY FIND_IN_SET(id,${oderId})
</select>
......
......@@ -520,8 +520,21 @@
this.planVisible = true;
},
handleBatchEdit() {
this.$refs.batchEdit.open(this.selectDataCounts);
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows, "scenario");
if(this.condition.selectAll){
this.condition.ids = [];
let param = {};
this.buildBatchParam(param);
this.$post('/api/automation/listWithIds/all', param, response => {
let dataRows = response.data;
this.$refs.batchEdit.open(dataRows.size);
this.$refs.batchEdit.setAllDataRows(dataRows);
this.$refs.batchEdit.open(this.selectDataCounts);
});
}else {
this.$refs.batchEdit.setAllDataRows(new Set());
this.$refs.batchEdit.open(this.selectDataCounts);
}
},
handleBatchMove() {
this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
......
......@@ -72,6 +72,7 @@
projectList: [],
projectIds: new Set(),
selectRows: new Set(),
allDataRows:new Set(),
projectEnvMap: new Map(),
map: new Map(),
isScenario: '',
......@@ -121,6 +122,9 @@
this.selectRows = rows;
this.isScenario = sign;
},
setAllDataRows(rows){
this.allDataRows = rows;
},
handleClose() {
this.form = {};
this.options = [];
......@@ -131,14 +135,25 @@
if (val === 'projectEnv' && this.isScenario !== '') {
this.projectIds.clear();
this.map.clear();
this.selectRows.forEach(row => {
let id = this.isScenario === 'scenario' ? row.id : row.caseId;
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + id, res => {
let data = res.data;
data.projectIds.forEach(d => this.projectIds.add(d));
this.map.set(row.id, data.projectIds);
if(this.allDataRows != null && this.allDataRows.length > 0){
this.allDataRows.forEach(row => {
let id = this.isScenario === 'scenario' ? row.id : row.caseId;
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + id, res => {
let data = res.data;
data.projectIds.forEach(d => this.projectIds.add(d));
this.map.set(row.id, data.projectIds);
})
})
}else{
this.selectRows.forEach(row => {
let id = this.isScenario === 'scenario' ? row.id : row.caseId;
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + 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];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册