feat(接口定义): 增加批量修改用例信息功能
This commit is contained in:
parent
554af29606
commit
1e6b252d12
|
@ -1,13 +1,10 @@
|
|||
package io.metersphere.api.dto.definition;
|
||||
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -32,6 +29,10 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
|
|||
|
||||
private String name;
|
||||
|
||||
private String method;
|
||||
|
||||
private String path;
|
||||
|
||||
private List<String> moduleIds;
|
||||
|
||||
private List<String> unSelectIds;
|
||||
|
@ -39,13 +40,4 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
|
|||
private String protocol;
|
||||
|
||||
private String status;
|
||||
|
||||
public void cleanSelectParam() {
|
||||
filters = new HashMap<>();
|
||||
name = null;
|
||||
moduleIds = new ArrayList<>();
|
||||
protocol = null;
|
||||
status = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
|
@ -11,6 +12,8 @@ import io.metersphere.api.dto.definition.request.MsTestElement;
|
|||
import io.metersphere.api.dto.definition.request.MsTestPlan;
|
||||
import io.metersphere.api.dto.definition.request.MsThreadGroup;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
|
@ -373,13 +376,33 @@ public class ApiTestCaseService {
|
|||
if (request.isSelectAllDate()) {
|
||||
ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus());
|
||||
}
|
||||
request.cleanSelectParam();
|
||||
ApiTestCaseExample apiDefinitionExample = new ApiTestCaseExample();
|
||||
apiDefinitionExample.createCriteria().andIdIn(ids);
|
||||
ApiTestCaseWithBLOBs apiDefinitionWithBLOBs = new ApiTestCaseWithBLOBs();
|
||||
BeanUtils.copyBean(apiDefinitionWithBLOBs, request);
|
||||
apiDefinitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestCaseMapper.updateByExampleSelective(apiDefinitionWithBLOBs, apiDefinitionExample);
|
||||
if (StringUtils.isNotEmpty(request.getPriority())) {
|
||||
ApiTestCaseWithBLOBs apiDefinitionWithBLOBs = new ApiTestCaseWithBLOBs();
|
||||
apiDefinitionWithBLOBs.setPriority(request.getPriority());
|
||||
apiDefinitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestCaseMapper.updateByExampleSelective(apiDefinitionWithBLOBs, apiDefinitionExample);
|
||||
}
|
||||
if ((StringUtils.isNotEmpty(request.getMethod()) || StringUtils.isNotEmpty(request.getPath())) && request.getProtocol().equals(RequestType.HTTP)) {
|
||||
List<ApiTestCaseWithBLOBs> bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample);
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
||||
bloBs.forEach(apiTestCase -> {
|
||||
MsHTTPSamplerProxy req = JSON.parseObject(apiTestCase.getRequest(), MsHTTPSamplerProxy.class);
|
||||
if (StringUtils.isNotEmpty(request.getMethod())) {
|
||||
req.setMethod(request.getMethod());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(request.getPath())) {
|
||||
req.setPath(request.getPath());
|
||||
}
|
||||
String requestStr = JSON.toJSONString(req);
|
||||
apiTestCase.setRequest(requestStr);
|
||||
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<String> getAllApiCaseIdsByFontedSelect(Map<String, List<String>> filters, List<String> moduleIds, String name, String projectId, String protocol, List<String> unSelectIds, String status) {
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
<el-option v-for="(type, index) in typeArr" :key="index" :value="type.id" :label="type.name"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('test_track.case.updated_attr_value')" prop="value">
|
||||
<el-form-item v-if="form.type ==='path'" :label="$t('test_track.case.updated_attr_value')" prop="value">
|
||||
<el-input size="small" v-model="form.value"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-else :label="$t('test_track.case.updated_attr_value')" prop="value">
|
||||
<el-select v-model="form.value" style="width: 80%" :filterable="filterable">
|
||||
<el-option v-for="(option, index) in options" :key="index" :value="option.id" :label="option.label">
|
||||
<div v-if="option.email">
|
||||
|
|
|
@ -101,14 +101,12 @@
|
|||
import MsBottomContainer from "../BottomContainer";
|
||||
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
|
||||
import MsBatchEdit from "../basis/BatchEdit";
|
||||
import {API_METHOD_COLOUR, CASE_PRIORITY} from "../../model/JsonData";
|
||||
import {API_METHOD_COLOUR, CASE_PRIORITY, REQ_METHOD} from "../../model/JsonData";
|
||||
import {getCurrentProjectID} from "@/common/js/utils";
|
||||
import ApiListContainer from "./ApiListContainer";
|
||||
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
import ApiCaseList from "../case/ApiCaseList";
|
||||
import {_filter, _sort} from "../../../../../../common/js/utils";
|
||||
import TestPlanCaseListHeader from "../../../../track/plan/view/comonents/api/TestPlanCaseListHeader";
|
||||
import MsEnvironmentSelect from "../case/MsEnvironmentSelect";
|
||||
import {_handleSelect, _handleSelectAll} from "../../../../../../common/js/tableUtils";
|
||||
|
||||
export default {
|
||||
|
@ -141,6 +139,8 @@
|
|||
],
|
||||
typeArr: [
|
||||
{id: 'priority', name: this.$t('test_track.case.priority')},
|
||||
{id: 'method', name: this.$t('api_test.definition.api_type')},
|
||||
{id: 'path', name: this.$t('api_test.request.path')},
|
||||
],
|
||||
priorityFilters: [
|
||||
{text: 'P0', value: 'P0'},
|
||||
|
@ -150,6 +150,7 @@
|
|||
],
|
||||
valueArr: {
|
||||
priority: CASE_PRIORITY,
|
||||
method: REQ_METHOD,
|
||||
},
|
||||
methodColorMap: new Map(API_METHOD_COLOUR),
|
||||
tableData: [],
|
||||
|
@ -159,8 +160,8 @@
|
|||
screenHeight: document.documentElement.clientHeight - 330,//屏幕高度
|
||||
environmentId: undefined,
|
||||
selectAll: false,
|
||||
unSelection:[],
|
||||
selectDataCounts:0,
|
||||
unSelection: [],
|
||||
selectDataCounts: 0,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -233,7 +234,7 @@
|
|||
this.condition.status = "Trash";
|
||||
this.condition.moduleIds = [];
|
||||
}
|
||||
this.selectAll = false;
|
||||
this.selectAll = false;
|
||||
this.unSelection = [];
|
||||
this.selectDataCounts = 0;
|
||||
this.condition.projectId = getCurrentProjectID();
|
||||
|
@ -245,7 +246,7 @@
|
|||
this.result = this.$post('/api/testcase/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);
|
||||
this.unSelection = response.data.listObject.map(s => s.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -312,24 +313,24 @@
|
|||
},
|
||||
handleDeleteBatch() {
|
||||
// if (this.trashEnable) {
|
||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let obj = {};
|
||||
obj.projectId = getCurrentProjectID();
|
||||
obj.selectAllDate = this.isSelectAllDate;
|
||||
obj.unSelectIds = this.unSelection;
|
||||
obj.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
obj = Object.assign(obj, this.condition);
|
||||
this.$post('/api/testcase/deleteBatchByParam/', obj , () => {
|
||||
this.selectRows.clear();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
});
|
||||
}
|
||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let obj = {};
|
||||
obj.projectId = getCurrentProjectID();
|
||||
obj.selectAllDate = this.isSelectAllDate;
|
||||
obj.unSelectIds = this.unSelection;
|
||||
obj.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
obj = Object.assign(obj, this.condition);
|
||||
this.$post('/api/testcase/deleteBatchByParam/', obj, () => {
|
||||
this.selectRows.clear();
|
||||
this.initTable();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// } else {
|
||||
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + "?", '', {
|
||||
// confirmButtonText: this.$t('commons.confirm'),
|
||||
|
@ -355,7 +356,6 @@
|
|||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
param.ids = ids;
|
||||
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.selectAllDate = this.isSelectAllDate;
|
||||
param.unSelectIds = this.unSelection;
|
||||
|
@ -367,11 +367,11 @@
|
|||
},
|
||||
handleDelete(apiCase) {
|
||||
// if (this.trashEnable) {
|
||||
this.$get('/api/testcase/delete/' + apiCase.id, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.initTable();
|
||||
});
|
||||
return;
|
||||
this.$get('/api/testcase/delete/' + apiCase.id, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.initTable();
|
||||
});
|
||||
return;
|
||||
// }
|
||||
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ?", '', {
|
||||
// confirmButtonText: this.$t('commons.confirm'),
|
||||
|
@ -389,16 +389,16 @@
|
|||
setEnvironment(data) {
|
||||
this.environmentId = data.id;
|
||||
},
|
||||
selectRowsCount(selection){
|
||||
selectRowsCount(selection) {
|
||||
let selectedIDs = this.getIds(selection);
|
||||
let allIDs = this.tableData.map(s=>s.id);
|
||||
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;
|
||||
if (this.isSelectAllDate) {
|
||||
this.selectDataCounts = this.total - this.unSelection.length;
|
||||
} else {
|
||||
this.selectDataCounts = selection.size;
|
||||
}
|
||||
},
|
||||
isSelectDataAll(dataType) {
|
||||
|
@ -409,9 +409,9 @@
|
|||
this.$refs.caseTable.toggleAllSelection(true);
|
||||
}
|
||||
},
|
||||
getIds(rowSets){
|
||||
getIds(rowSets) {
|
||||
let rowArray = Array.from(rowSets)
|
||||
let ids = rowArray.map(s=>s.id);
|
||||
let ids = rowArray.map(s => s.id);
|
||||
return ids;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue