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

修复测试场景批量修改环境的问题
This commit is contained in:
song-tianyang 2021-05-12 16:03:32 +08:00 committed by jianxing
parent c12aecfa6f
commit 87e35bbbc6
6 changed files with 60 additions and 8 deletions

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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>

View File

@ -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);

View File

@ -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,6 +135,16 @@
if (val === 'projectEnv' && this.isScenario !== '') {
this.projectIds.clear();
this.map.clear();
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 => {
@ -140,6 +154,7 @@
})
})
}
}
this.filterable = val === "maintainer" || val === "executor";
this.options = this.valueArr[val];
this.typeArr.forEach(item => {