parent
f11e0af0bf
commit
f2908ac330
|
@ -72,12 +72,23 @@ public class ApiDefinitionController {
|
|||
apiDefinitionService.deleteBatch(ids);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteBatchByParams")
|
||||
public void deleteBatchByParams(@RequestBody ApiDefinitionBatchProcessingRequest request) {
|
||||
apiDefinitionService.deleteByParams(request);
|
||||
}
|
||||
|
||||
@PostMapping("/removeToGc")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
||||
public void removeToGc(@RequestBody List<String> ids) {
|
||||
apiDefinitionService.removeToGc(ids);
|
||||
}
|
||||
|
||||
@PostMapping("/removeToGcByParams")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER}, logical = Logical.OR)
|
||||
public void removeToGcByParams(@RequestBody ApiDefinitionBatchProcessingRequest request) {
|
||||
apiDefinitionService.removeToGcByParams(request);
|
||||
}
|
||||
|
||||
@PostMapping("/reduction")
|
||||
public void reduction(@RequestBody List<SaveApiDefinitionRequest> requests) {
|
||||
apiDefinitionService.reduction(requests);
|
||||
|
@ -130,6 +141,12 @@ public class ApiDefinitionController {
|
|||
apiDefinitionService.editApiBath(request);
|
||||
}
|
||||
|
||||
@PostMapping("/batch/editByParams")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public void editByParams(@RequestBody ApiBatchRequest request) {
|
||||
apiDefinitionService.editApiByParam(request);
|
||||
}
|
||||
|
||||
@PostMapping("/relevance")
|
||||
public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) {
|
||||
apiDefinitionService.testPlanRelevance(request);
|
||||
|
|
|
@ -13,4 +13,23 @@ public class ApiBatchRequest extends ApiDefinitionWithBLOBs {
|
|||
private List<String> ids;
|
||||
private List<OrderRequest> orders;
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* isSelectAllDate:选择的数据是否是全部数据(全部数据是不受分页影响的数据)
|
||||
* filters: 数据状态
|
||||
* name:如果是全部数据,那么表格如果历经查询,查询参数是什么
|
||||
* moduleIds: 哪些模块的数据
|
||||
* unSelectIds:是否在页面上有未勾选的数据,有的话他们的ID是哪些。
|
||||
* filters/name/moduleIds/unSeelctIds 只在isSelectAllDate为true时需要。为了让程序能明确批量的范围。
|
||||
*/
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private List<String> filters;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> moduleIds;
|
||||
|
||||
private List<String> unSelectIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口定义模块-批量处理请求类
|
||||
* @author song.tianyang
|
||||
* @Date 2020/12/29 4:13 下午
|
||||
* @Description
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiDefinitionBatchProcessingRequest {
|
||||
/**
|
||||
* isSelectAllDate:选择的数据是否是全部数据(全部数据是不受分页影响的数据)
|
||||
* filters: 数据状态
|
||||
* name:如果是全部数据,那么表格如果历经查询,查询参数是什么
|
||||
* moduleIds: 哪些模块的数据
|
||||
* unSelectIds:是否在页面上有未勾选的数据,有的话他们的ID是哪些。
|
||||
* filters/name/moduleIds/unSeelctIds 只在isSelectAllDate为true时需要。为了让程序能明确批量的范围。
|
||||
*/
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private List<String> filters;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> moduleIds;
|
||||
|
||||
private List<String> unSelectIds;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private List<String> dataIds;
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.ReferenceDTO;
|
||||
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
||||
|
@ -420,6 +421,23 @@ public class ApiDefinitionService {
|
|||
apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, definitionExample);
|
||||
}
|
||||
|
||||
public void editApiByParam(ApiBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if(request.isSelectAllDate()){
|
||||
ids = this.getAllApiIdsByFontedSelect(request.getFilters(),request.getName(),request.getModuleIds(),request.getProjectId(),request.getUnSelectIds());
|
||||
}
|
||||
//name在这里只是查询参数
|
||||
request.setName(null);
|
||||
|
||||
ApiDefinitionExample definitionExample = new ApiDefinitionExample();
|
||||
definitionExample.createCriteria().andIdIn(ids);
|
||||
|
||||
ApiDefinitionWithBLOBs definitionWithBLOBs = new ApiDefinitionWithBLOBs();
|
||||
BeanUtils.copyBean(definitionWithBLOBs, request);
|
||||
definitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||
apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, definitionExample);
|
||||
}
|
||||
|
||||
public void testPlanRelevance(ApiCaseRelevanceRequest request) {
|
||||
apiTestCaseService.relevanceByApi(request);
|
||||
}
|
||||
|
@ -466,4 +484,37 @@ public class ApiDefinitionService {
|
|||
example.createCriteria().andIdIn(ids);
|
||||
return apiDefinitionMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void deleteByParams(ApiDefinitionBatchProcessingRequest request) {
|
||||
List<String> apiIds = request.getDataIds();
|
||||
if(request.isSelectAllDate()){
|
||||
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(),request.getName(),request.getModuleIds(),request.getProjectId(),request.getUnSelectIds());
|
||||
}
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria().andIdIn(apiIds);
|
||||
apiDefinitionMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
private List<String> getAllApiIdsByFontedSelect(List<String> filter,String name,List<String> moduleIds,String projectId,List<String>unSelectIds) {
|
||||
ApiDefinitionRequest request = new ApiDefinitionRequest();
|
||||
request.setFilters(filter);
|
||||
request.setName(name);
|
||||
request.setModuleIds(moduleIds);
|
||||
request.setProjectId(projectId);
|
||||
List<ApiDefinitionResult> resList = extApiDefinitionMapper.list(request);
|
||||
List<String> ids = new ArrayList<>(0);
|
||||
if (!resList.isEmpty()) {
|
||||
List<String> allIds = resList.stream().map(ApiDefinitionResult::getId).collect(Collectors.toList());
|
||||
ids = allIds.stream().filter(id -> !unSelectIds.contains(id)).collect(Collectors.toList());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void removeToGcByParams(ApiDefinitionBatchProcessingRequest request) {
|
||||
List<String> apiIds = request.getDataIds();
|
||||
if(request.isSelectAllDate()){
|
||||
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(),request.getName(),request.getModuleIds(),request.getProjectId(),request.getUnSelectIds());
|
||||
}
|
||||
extApiDefinitionMapper.removeToGc(apiIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,28 @@
|
|||
|
||||
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" @keyup.enter.native="search" v-model="condition.name"/>
|
||||
|
||||
<el-table v-loading="result.loading"
|
||||
<el-table v-loading="result.loading" ref="apiDefinitionTable"
|
||||
border
|
||||
:data="tableData" row-key="id" class="test-content adjust-table"
|
||||
@select-all="handleSelectAll"
|
||||
@select="handleSelect" :height="screenHeight">
|
||||
<el-table-column type="selection"/>
|
||||
<el-table-column width="40" :resizable="false" align="center">
|
||||
<el-dropdown slot="header" style="width: 14px">
|
||||
<span class="el-dropdown-link" style="width: 14px">
|
||||
<i class="el-icon-arrow-down el-icon--right" style="margin-left: 0px"></i>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item @click.native.stop="isSelectDataAll(true)">
|
||||
{{$t('api_test.batch_menus.select_all_data',[total])}}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native.stop="isSelectDataAll(false)">
|
||||
{{$t('api_test.batch_menus.select_show_data',[tableData.length])}}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<template v-slot:default="scope">
|
||||
<show-more-btn :is-show="scope.row.showMore && !isReadOnly && !isRelevance" :buttons="buttons" :size="selectRows.size"/>
|
||||
<show-more-btn :is-show="scope.row.showMore && !isReadOnly && !isRelevance" :buttons="buttons" :size="selectDataCounts"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
@ -161,7 +174,10 @@
|
|||
pageSize: 10,
|
||||
total: 0,
|
||||
screenHeight: document.documentElement.clientHeight - 330,//屏幕高度,
|
||||
environmentId: undefined
|
||||
environmentId: undefined,
|
||||
selectAll: false,
|
||||
unSelection:[],
|
||||
selectDataCounts:0,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -213,6 +229,11 @@
|
|||
},
|
||||
initTable() {
|
||||
this.selectRows = new Set();
|
||||
|
||||
this.selectAll = false;
|
||||
this.unSelection = [];
|
||||
this.selectDataCounts = 0;
|
||||
|
||||
this.condition.filters = ["Prepare", "Underway", "Completed"];
|
||||
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
|
@ -229,6 +250,7 @@
|
|||
this.result = this.$post("/api/definition/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
|
||||
this.total = response.data.itemCount;
|
||||
this.tableData = response.data.listObject;
|
||||
this.unSelection = response.data.listObject.map(s=>s.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -256,6 +278,7 @@
|
|||
this.$set(row, "showMore", true);
|
||||
})
|
||||
}
|
||||
this.selectRowsCount(this.selectRows)
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
|
@ -275,6 +298,7 @@
|
|||
this.$set(row, "showMore", false);
|
||||
})
|
||||
}
|
||||
this.selectRowsCount(this.selectRows)
|
||||
},
|
||||
search() {
|
||||
this.initTable();
|
||||
|
@ -301,8 +325,14 @@
|
|||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let deleteParam = {};
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/api/definition/deleteBatch/', ids, () => {
|
||||
deleteParam.dataIds = ids;
|
||||
deleteParam.projectId = getCurrentProjectID();
|
||||
deleteParam.selectAllDate = this.isSelectAllDate;
|
||||
deleteParam.unSelectIds = this.unSelection;
|
||||
deleteParam = Object.assign(deleteParam, this.condition);
|
||||
this.$post('/api/definition/deleteBatchByParams/', deleteParam, () => {
|
||||
this.selectRows.clear();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
|
@ -316,7 +346,13 @@
|
|||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/api/definition/removeToGc/', ids, () => {
|
||||
let deleteParam = {};
|
||||
deleteParam.dataIds = ids;
|
||||
deleteParam.projectId = getCurrentProjectID();
|
||||
deleteParam.selectAllDate = this.isSelectAllDate;
|
||||
deleteParam.unSelectIds = this.unSelection;
|
||||
deleteParam = Object.assign(deleteParam, this.condition);
|
||||
this.$post('/api/definition/removeToGcByParams/', deleteParam, () => {
|
||||
this.selectRows.clear();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
|
@ -336,7 +372,13 @@
|
|||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
param.ids = ids;
|
||||
this.$post('/api/definition/batch/edit', param, () => {
|
||||
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.selectAllDate = this.isSelectAllDate;
|
||||
param.unSelectIds = this.unSelection;
|
||||
param = Object.assign(param, this.condition);
|
||||
|
||||
this.$post('/api/definition/batch/editByParams', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initTable();
|
||||
});
|
||||
|
@ -394,6 +436,31 @@
|
|||
},
|
||||
setEnvironment(data) {
|
||||
this.environmentId = data.id;
|
||||
},
|
||||
selectRowsCount(selection){
|
||||
let selectedIDs = this.getIds(selection);
|
||||
let allIDs = this.tableData.map(s=>s.id);
|
||||
this.unSelection = allIDs.filter(function (val) {
|
||||
return selectedIDs.indexOf(val) === -1
|
||||
});
|
||||
if(this.isSelectAllDate){
|
||||
this.selectDataCounts =this.total - this.unSelection.length;
|
||||
}else {
|
||||
this.selectDataCounts =selection.size;
|
||||
}
|
||||
},
|
||||
isSelectDataAll(dataType) {
|
||||
this.isSelectAllDate = dataType;
|
||||
this.selectRowsCount(this.selectRows)
|
||||
//如果已经全选,不需要再操作了
|
||||
if (this.selectRows.size != this.tableData.length) {
|
||||
this.$refs.apiDefinitionTable.toggleAllSelection(true);
|
||||
}
|
||||
},
|
||||
getIds(rowSets){
|
||||
let rowArray = Array.from(rowSets)
|
||||
let ids = rowArray.map(s=>s.id);
|
||||
return ids;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue