fix: 修复测试计划执行性能测试时、批量修改环境时只能操作当前页面数据的问题
修复测试计划执行性能测试时、批量修改环境时只能操作当前页面数据的问题
This commit is contained in:
parent
1b8812d1cd
commit
d325e065c3
|
@ -55,9 +55,9 @@
|
|||
where 1
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and
|
||||
and a.projectId = #{request.projectId}
|
||||
</if>
|
||||
t.id in
|
||||
and t.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
|
|
|
@ -10,6 +10,9 @@ public interface ExtTestPlanLoadCaseMapper {
|
|||
|
||||
List<String> selectIdsNotInPlan(@Param("request") LoadCaseRequest request);
|
||||
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request);
|
||||
|
||||
List<TestPlanLoadCaseDTO> selectByIdIn(@Param("request") LoadCaseRequest request);
|
||||
|
||||
void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status);
|
||||
List<String> getStatusByTestPlanId(@Param("planId") String planId);
|
||||
|
||||
|
|
|
@ -68,6 +68,35 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByIdIn" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
|
||||
select tplc.id,
|
||||
u.name as userName,
|
||||
tplc.create_time,
|
||||
tplc.update_time,
|
||||
tplc.test_plan_id,
|
||||
tplc.load_case_id,
|
||||
lt.status,
|
||||
lt.num,
|
||||
tplc.status as caseStatus,
|
||||
lt.name as caseName,
|
||||
tplc.load_report_id,
|
||||
p.name as projectName
|
||||
from test_plan_load_case tplc
|
||||
inner join load_test lt on tplc.load_case_id = lt.id
|
||||
inner join user u on lt.user_id = u.id
|
||||
inner join project p on lt.project_id = p.id
|
||||
WHERE tplc.id in
|
||||
<foreach collection="request.ids" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
tplc.${order.name} ${order.type}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectTestPlanLoadCaseId" resultType="java.lang.String">
|
||||
select tplc.id
|
||||
from test_plan_load_case tplc
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
where 1
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and
|
||||
and c.project_id = #{request.projectId}
|
||||
</if>
|
||||
t.id in
|
||||
and t.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
|
|
|
@ -8,7 +8,6 @@ import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
|
|||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
|
||||
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
|
@ -31,6 +30,12 @@ public class TestPlanApiCaseController {
|
|||
return PageUtils.setPageInfo(page, testPlanApiCaseService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/selectAllTableRows")
|
||||
public List<TestPlanApiCaseDTO> selectAllTableRows(@RequestBody TestPlanApiCaseBatchRequest request) {
|
||||
return testPlanApiCaseService.selectAllTableRows(request);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/relevance/list/{goPage}/{pageSize}")
|
||||
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
|
||||
return testPlanApiCaseService.relevanceList(goPage, pageSize, request);
|
||||
|
|
|
@ -42,6 +42,11 @@ public class TestPlanLoadCaseController {
|
|||
return PageUtils.setPageInfo(page, testPlanLoadCaseService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/selectAllTableRows")
|
||||
public List<TestPlanLoadCaseDTO> selectAllTableRows(@RequestBody LoadCaseReportBatchRequest request) {
|
||||
return testPlanLoadCaseService.selectAllTableRows(request);
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
public void delete(@PathVariable String id) {
|
||||
testPlanLoadCaseService.delete(id);
|
||||
|
|
|
@ -31,6 +31,11 @@ public class TestPlanScenarioCaseController {
|
|||
return PageUtils.setPageInfo(page, testPlanScenarioCaseService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/selectAllTableRows")
|
||||
public List<ApiScenarioDTO> selectAllTableRows(@RequestBody TestPlanScenarioCaseBatchRequest request) {
|
||||
return testPlanScenarioCaseService.selectAllTableRows(request);
|
||||
}
|
||||
|
||||
@PostMapping("/relevance/list/{goPage}/{pageSize}")
|
||||
public Pager<List<ApiScenarioDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||
@Getter
|
||||
@Setter
|
||||
public class LoadCaseRequest extends TestPlanLoadCase {
|
||||
private List<String> ids;
|
||||
private String projectId;
|
||||
private List<String> caseIds;
|
||||
private String name;
|
||||
|
|
|
@ -105,6 +105,9 @@ public class TestPlanApiCaseService {
|
|||
List<String> deleteIds = request.getIds();
|
||||
if(request.getCondition()!=null && request.getCondition().isSelectAll()){
|
||||
deleteIds = this.selectIds(request.getCondition());
|
||||
if (request.getCondition() != null && request.getCondition().getUnSelectIds() != null) {
|
||||
deleteIds.removeAll(request.getCondition().getUnSelectIds());
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(deleteIds)) {
|
||||
|
@ -168,4 +171,21 @@ public class TestPlanApiCaseService {
|
|||
return testPlanApiCaseMapper.selectByExample(example).get(0).getStatus();
|
||||
|
||||
}
|
||||
|
||||
public List<TestPlanApiCaseDTO> selectAllTableRows(TestPlanApiCaseBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.getCondition() != null && request.getCondition().isSelectAll()) {
|
||||
ids = this.selectIds(request.getCondition());
|
||||
if (request.getCondition() != null && request.getCondition().getUnSelectIds() != null) {
|
||||
ids.removeAll(request.getCondition().getUnSelectIds());
|
||||
}
|
||||
}
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ApiTestCaseRequest selectReq = new ApiTestCaseRequest();
|
||||
selectReq.setIds(ids);
|
||||
List<TestPlanApiCaseDTO> returnList = extTestPlanApiCaseMapper.list(selectReq);
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,4 +224,33 @@ public class TestPlanLoadCaseService {
|
|||
public List<String> getStatus(String planId) {
|
||||
return extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId);
|
||||
}
|
||||
|
||||
public List<TestPlanLoadCaseDTO> selectAllTableRows(LoadCaseReportBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.getCondition() != null && request.getCondition().isSelectAll()) {
|
||||
ids = this.selectTestPlanLoadCaseIds(request.getCondition());
|
||||
if (request.getCondition().getUnSelectIds() != null) {
|
||||
ids.removeAll(request.getCondition().getUnSelectIds());
|
||||
}
|
||||
}
|
||||
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<OrderRequest> orders = request.getCondition().getOrders();
|
||||
if (orders == null || orders.size() < 1) {
|
||||
OrderRequest orderRequest = new OrderRequest();
|
||||
orderRequest.setName("create_time");
|
||||
orderRequest.setType("desc");
|
||||
orders = new ArrayList<>();
|
||||
orders.add(orderRequest);
|
||||
}
|
||||
|
||||
LoadCaseRequest tableReq = new LoadCaseRequest();
|
||||
tableReq.setIds(ids);
|
||||
tableReq.setOrders(orders);
|
||||
List<TestPlanLoadCaseDTO> list = extTestPlanLoadCaseMapper.selectByIdIn(tableReq);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,9 @@ public class TestPlanScenarioCaseService {
|
|||
List<String> ids = request.getIds();
|
||||
if(request.getCondition()!=null && request.getCondition().isSelectAll()){
|
||||
ids = this.selectIds(request.getCondition());
|
||||
if (request.getCondition() != null && request.getCondition().getUnSelectIds() != null) {
|
||||
ids.removeAll(request.getCondition().getUnSelectIds());
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
|
@ -180,4 +183,20 @@ public class TestPlanScenarioCaseService {
|
|||
|
||||
|
||||
}
|
||||
|
||||
public List<ApiScenarioDTO> selectAllTableRows(TestPlanScenarioCaseBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.getCondition() != null && request.getCondition().isSelectAll()) {
|
||||
ids = this.selectIds(request.getCondition());
|
||||
if (request.getCondition() != null && request.getCondition().getUnSelectIds() != null) {
|
||||
ids.removeAll(request.getCondition().getUnSelectIds());
|
||||
}
|
||||
}
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
TestPlanScenarioRequest tableRequest = new TestPlanScenarioRequest();
|
||||
tableRequest.setIds(ids);
|
||||
return extTestPlanScenarioCaseMapper.list(tableRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -501,58 +501,67 @@ export default {
|
|||
return new Promise((resolve) => {
|
||||
let index = 1;
|
||||
this.runData = [];
|
||||
// 按照列表顺序排序
|
||||
this.orderBySelectRows(this.selectRows);
|
||||
this.selectRows.forEach(row => {
|
||||
this.$get('/api/testcase/get/' + row.caseId, (response) => {
|
||||
let apiCase = response.data;
|
||||
let request = JSON.parse(apiCase.request);
|
||||
request.name = row.id;
|
||||
request.id = row.id;
|
||||
request.useEnvironment = row.environmentId;
|
||||
this.runData.unshift(request);
|
||||
if (this.selectRows.length === index) {
|
||||
resolve();
|
||||
}
|
||||
index++;
|
||||
if (this.condition != null && this.condition.selectAll) {
|
||||
let selectAllRowParams = buildBatchParam(this);
|
||||
selectAllRowParams.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/plan/api/case/selectAllTableRows', selectAllRowParams, response => {
|
||||
let dataRows = response.data;
|
||||
// 按照列表顺序排序
|
||||
this.orderBySelectRows(dataRows);
|
||||
dataRows.forEach(row => {
|
||||
this.$get('/api/testcase/get/' + row.caseId, (response) => {
|
||||
let apiCase = response.data;
|
||||
let request = JSON.parse(apiCase.request);
|
||||
request.name = row.id;
|
||||
request.id = row.id;
|
||||
request.useEnvironment = row.environmentId;
|
||||
this.runData.unshift(request);
|
||||
if (dataRows.length === index) {
|
||||
resolve();
|
||||
}
|
||||
index++;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// 按照列表顺序排序
|
||||
this.orderBySelectRows(this.selectRows);
|
||||
this.selectRows.forEach(row => {
|
||||
this.$get('/api/testcase/get/' + row.caseId, (response) => {
|
||||
let apiCase = response.data;
|
||||
let request = JSON.parse(apiCase.request);
|
||||
request.name = row.id;
|
||||
request.id = row.id;
|
||||
request.useEnvironment = row.environmentId;
|
||||
this.runData.unshift(request);
|
||||
if (this.selectRows.length === index) {
|
||||
resolve();
|
||||
}
|
||||
index++;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
batchEdit(form) {
|
||||
let param = {};
|
||||
// 批量修改环境
|
||||
if (form.type === 'projectEnv') {
|
||||
if(this.condition != null && this.condition.selectAll){
|
||||
this.$alert(this.$t('commons.option_cannot_spread_pages'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let map = new Map();
|
||||
param.projectEnvMap = strMapToObj(form.projectEnvMap);
|
||||
this.selectRows.forEach(row => {
|
||||
map[row.id] = row.projectId;
|
||||
})
|
||||
param.selectRows = map;
|
||||
this.$post('/test/plan/api/case/batch/update/env', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initTable();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}else {
|
||||
let selectAllRowParams = buildBatchParam(this);
|
||||
selectAllRowParams.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/plan/api/case/selectAllTableRows', selectAllRowParams, response => {
|
||||
let dataRows = response.data;
|
||||
let map = new Map();
|
||||
param.projectEnvMap = strMapToObj(form.projectEnvMap);
|
||||
this.selectRows.forEach(row => {
|
||||
dataRows.forEach(row => {
|
||||
map[row.id] = row.projectId;
|
||||
})
|
||||
});
|
||||
param.selectRows = map;
|
||||
this.$post('/test/plan/api/case/batch/update/env', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initTable();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 批量修改其它
|
||||
}
|
||||
|
@ -568,26 +577,11 @@ export default {
|
|||
this.selectRows = array;
|
||||
},
|
||||
handleBatchExecute() {
|
||||
if(this.condition != null && this.condition.selectAll) {
|
||||
this.$alert(this.$t('commons.option_cannot_spread_pages'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.getData().then(() => {
|
||||
if (this.runData && this.runData.length > 0) {
|
||||
this.$refs.runMode.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}else {
|
||||
this.getData().then(() => {
|
||||
if (this.runData && this.runData.length > 0) {
|
||||
this.$refs.runMode.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.getData().then(() => {
|
||||
if (this.runData && this.runData.length > 0) {
|
||||
this.$refs.runMode.open();
|
||||
}
|
||||
});
|
||||
},
|
||||
handleRunBatch(config) {
|
||||
let testPlan = new TestPlan();
|
||||
|
|
|
@ -423,42 +423,30 @@ export default {
|
|||
});
|
||||
},
|
||||
handleBatchEdit() {
|
||||
this.$refs.batchEdit.open(this.selectRows.size);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows, "planScenario");
|
||||
if (this.condition != null && this.condition.selectAll) {
|
||||
let selectAllRowParams = buildBatchParam(this);
|
||||
selectAllRowParams.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/plan/scenario/case/selectAllTableRows', selectAllRowParams, response => {
|
||||
let dataRows = response.data;
|
||||
this.$refs.batchEdit.open(dataRows.size);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(dataRows, "planScenario");
|
||||
});
|
||||
} else {
|
||||
this.$refs.batchEdit.open(this.selectRows.size);
|
||||
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows, "planScenario");
|
||||
}
|
||||
},
|
||||
batchEdit(form) {
|
||||
let param = {};
|
||||
param.mapping = strMapToObj(form.map);
|
||||
param.envMap = strMapToObj(form.projectEnvMap);
|
||||
|
||||
if(this.condition != null && this.condition.selectAll){
|
||||
this.$alert(this.$t('commons.option_cannot_spread_pages'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
if (this.planId) {
|
||||
this.$post('/test/plan/scenario/case/batch/update/env', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.planId) {
|
||||
this.$post('/test/plan/scenario/case/batch/update/env', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
});
|
||||
}else {
|
||||
if (this.planId) {
|
||||
this.$post('/test/plan/scenario/case/batch/update/env', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.search();
|
||||
})
|
||||
}
|
||||
}
|
||||
// if (this.reviewId) {
|
||||
// this.$post('/test/case/review/scenario/case/batch/update/env', param, () => {
|
||||
// this.$success(this.$t('commons.save_success'));
|
||||
// this.search();
|
||||
// })
|
||||
// }
|
||||
},
|
||||
isSelectDataAll(data) {
|
||||
this.condition.selectAll = data;
|
||||
|
|
|
@ -251,23 +251,22 @@ export default {
|
|||
runBatch(config){
|
||||
this.orderBySelectRows(this.selectRows);
|
||||
if(this.condition != null && this.condition.selectAll){
|
||||
this.$alert(this.$t('commons.option_cannot_spread_pages'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let runArr = [];
|
||||
this.selectRows.forEach(loadCase => {
|
||||
runArr.push( {
|
||||
id: loadCase.loadCaseId,
|
||||
testPlanLoadId: loadCase.id,
|
||||
triggerMode: 'CASE'
|
||||
})
|
||||
});
|
||||
let obj = {config:config,requests:runArr,userId:getCurrentUser().id};
|
||||
this._runBatch(obj);
|
||||
this.refreshStatus();
|
||||
}
|
||||
}
|
||||
let selectAllRowParams = buildBatchParam(this);
|
||||
selectAllRowParams.ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/plan/load/case/selectAllTableRows', selectAllRowParams, response => {
|
||||
let dataRows = response.data;
|
||||
let runArr = [];
|
||||
dataRows.forEach(loadCase => {
|
||||
runArr.push({
|
||||
id: loadCase.loadCaseId,
|
||||
testPlanLoadId: loadCase.id,
|
||||
triggerMode: 'CASE'
|
||||
});
|
||||
});
|
||||
let obj = {config: config, requests: runArr, userId: getCurrentUser().id};
|
||||
this._runBatch(obj);
|
||||
this.initTable();
|
||||
this.refreshStatus();
|
||||
});
|
||||
}else {
|
||||
let runArr = [];
|
||||
|
|
Loading…
Reference in New Issue