fix: 场景页面批量编辑用例
This commit is contained in:
parent
0d278cf20b
commit
5d9cf69916
|
@ -101,6 +101,12 @@ public class ApiAutomationController {
|
||||||
return apiAutomationService.run(request);
|
return apiAutomationService.run(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/batch/edit")
|
||||||
|
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||||
|
public void bathEdit(@RequestBody SaveApiScenarioRequest request) {
|
||||||
|
apiAutomationService.bathEdit(request);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/getReference")
|
@PostMapping("/getReference")
|
||||||
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
||||||
return apiAutomationService.getReference(request);
|
return apiAutomationService.getReference(request);
|
||||||
|
|
|
@ -19,6 +19,8 @@ public class SaveApiScenarioRequest {
|
||||||
|
|
||||||
private String apiScenarioModuleId;
|
private String apiScenarioModuleId;
|
||||||
|
|
||||||
|
private String environmentId;
|
||||||
|
|
||||||
private String modulePath;
|
private String modulePath;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -40,4 +42,15 @@ public class SaveApiScenarioRequest {
|
||||||
private MsTestElement scenarioDefinition;
|
private MsTestElement scenarioDefinition;
|
||||||
|
|
||||||
List<String> bodyUploadIds;
|
List<String> bodyUploadIds;
|
||||||
|
|
||||||
|
private List<String> scenarioIds;
|
||||||
|
|
||||||
|
private boolean isSelectAllDate;
|
||||||
|
|
||||||
|
private List<String> filters;
|
||||||
|
|
||||||
|
private List<String> moduleIds;
|
||||||
|
|
||||||
|
private List<String> unSelectIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,7 @@ import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.DateUtils;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
|
||||||
import io.metersphere.commons.utils.ServiceUtils;
|
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.job.sechedule.ApiScenarioTestJob;
|
import io.metersphere.job.sechedule.ApiScenarioTestJob;
|
||||||
import io.metersphere.service.ScheduleService;
|
import io.metersphere.service.ScheduleService;
|
||||||
|
@ -35,6 +32,7 @@ import io.metersphere.track.dto.TestPlanDTO;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||||
|
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
@ -45,6 +43,7 @@ import org.apache.jorphan.collections.ListedHashTree;
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentHelper;
|
import org.dom4j.DocumentHelper;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -81,6 +80,9 @@ public class ApiAutomationService {
|
||||||
SqlSessionFactory sqlSessionFactory;
|
SqlSessionFactory sqlSessionFactory;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||||
|
@Resource
|
||||||
|
@Lazy
|
||||||
|
private TestPlanScenarioCaseService testPlanScenarioCaseService;
|
||||||
|
|
||||||
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
||||||
request = this.initRequest(request,true,true);
|
request = this.initRequest(request,true,true);
|
||||||
|
@ -199,6 +201,7 @@ public class ApiAutomationService {
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
//及连删除外键表
|
//及连删除外键表
|
||||||
this.preDelete(id);
|
this.preDelete(id);
|
||||||
|
testPlanScenarioCaseService.deleteByScenarioId(id);
|
||||||
apiScenarioMapper.deleteByPrimaryKey(id);
|
apiScenarioMapper.deleteByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,6 +592,12 @@ public class ApiAutomationService {
|
||||||
return apiScenarioMapper.selectByExample(example);
|
return apiScenarioMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ApiScenarioWithBLOBs> selectByIdsWithBLOBs(List<String> ids) {
|
||||||
|
ApiScenarioExample example = new ApiScenarioExample();
|
||||||
|
example.createCriteria().andIdIn(ids);
|
||||||
|
return apiScenarioMapper.selectByExampleWithBLOBs(example);
|
||||||
|
}
|
||||||
|
|
||||||
public void createSchedule(Schedule request) {
|
public void createSchedule(Schedule request) {
|
||||||
Schedule schedule = scheduleService.buildApiTestSchedule(request);
|
Schedule schedule = scheduleService.buildApiTestSchedule(request);
|
||||||
schedule.setJob(ApiScenarioTestJob.class.getName());
|
schedule.setJob(ApiScenarioTestJob.class.getName());
|
||||||
|
@ -641,4 +650,35 @@ public class ApiAutomationService {
|
||||||
dto.setXml(jmx);
|
dto.setXml(jmx);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void bathEdit(SaveApiScenarioRequest request) {
|
||||||
|
if (request.isSelectAllDate()) {
|
||||||
|
request.setScenarioIds(this.getAllScenarioIdsByFontedSelect(
|
||||||
|
request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds()));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getEnvironmentId())) {
|
||||||
|
bathEditEnv(request);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ApiScenarioExample apiScenarioExample = new ApiScenarioExample();
|
||||||
|
apiScenarioExample.createCriteria().andIdIn(request.getScenarioIds());
|
||||||
|
ApiScenarioWithBLOBs apiScenarioWithBLOBs = new ApiScenarioWithBLOBs();
|
||||||
|
BeanUtils.copyBean(apiScenarioWithBLOBs, request);
|
||||||
|
apiScenarioWithBLOBs.setUpdateTime(System.currentTimeMillis());
|
||||||
|
apiScenarioMapper.updateByExampleSelective(
|
||||||
|
apiScenarioWithBLOBs,
|
||||||
|
apiScenarioExample);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bathEditEnv(SaveApiScenarioRequest request) {
|
||||||
|
if (StringUtils.isNotBlank(request.getEnvironmentId())) {
|
||||||
|
List<ApiScenarioWithBLOBs> apiScenarios = selectByIdsWithBLOBs(request.getScenarioIds());
|
||||||
|
apiScenarios.forEach(item -> {
|
||||||
|
JSONObject object = JSONObject.parseObject(item.getScenarioDefinition());
|
||||||
|
object.put("environmentId", request.getEnvironmentId());
|
||||||
|
item.setScenarioDefinition(JSONObject.toJSONString(object));
|
||||||
|
apiScenarioMapper.updateByPrimaryKeySelective(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,4 +120,16 @@ public class TestPlanScenarioCaseService {
|
||||||
request.setPlanId(planId);
|
request.setPlanId(planId);
|
||||||
deleteApiCaseBath(request);
|
deleteApiCaseBath(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void bathDeleteByScenarioIds(List<String> ids) {
|
||||||
|
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||||
|
example.createCriteria().andApiScenarioIdIn(ids);
|
||||||
|
testPlanApiScenarioMapper.deleteByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteByScenarioId(String id) {
|
||||||
|
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||||
|
example.createCriteria().andApiScenarioIdEqualTo(id);
|
||||||
|
testPlanApiScenarioMapper.deleteByExample(example);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,12 @@
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')">
|
||||||
|
<template v-slot:value>
|
||||||
|
<environment-select :current-data="{}" :project-id="projectId"/>
|
||||||
|
</template>
|
||||||
|
</batch-edit>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -120,10 +126,15 @@
|
||||||
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
|
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
|
||||||
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
|
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
|
||||||
import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
|
import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
|
||||||
|
import BatchEdit from "../../../track/case/components/BatchEdit";
|
||||||
|
import {WORKSPACE_ID} from "../../../../../common/js/constants";
|
||||||
|
import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiScenarioList",
|
name: "MsApiScenarioList",
|
||||||
components: {
|
components: {
|
||||||
|
EnvironmentSelect,
|
||||||
|
BatchEdit,
|
||||||
PlanStatusTableItem,
|
PlanStatusTableItem,
|
||||||
PriorityTableItem,
|
PriorityTableItem,
|
||||||
MsTableSelectAll,
|
MsTableSelectAll,
|
||||||
|
@ -176,13 +187,42 @@
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
|
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
|
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
|
||||||
|
},
|
||||||
|
{
|
||||||
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
|
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// {
|
||||||
|
// name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
|
||||||
|
// }
|
||||||
],
|
],
|
||||||
isSelectAllDate: false,
|
isSelectAllDate: false,
|
||||||
unSelection: [],
|
unSelection: [],
|
||||||
selectDataCounts: 0,
|
selectDataCounts: 0,
|
||||||
|
typeArr: [
|
||||||
|
{id: 'level', name: this.$t('test_track.case.priority')},
|
||||||
|
{id: 'status', name: this.$t('test_track.plan.plan_status')},
|
||||||
|
{id: 'principal', name: this.$t('api_test.definition.request.responsible'), optionMethod: this.getPrincipalOptions},
|
||||||
|
{id: 'environmentId', name: this.$t('api_test.definition.request.run_env'), optionMethod: this.getEnvsOptions},
|
||||||
|
],
|
||||||
|
valueArr: {
|
||||||
|
level: [
|
||||||
|
{name: 'P0', id: 'P0'},
|
||||||
|
{name: 'P1', id: 'P1'},
|
||||||
|
{name: 'P2', id: 'P2'},
|
||||||
|
{name: 'P3', id: 'P3'}
|
||||||
|
],
|
||||||
|
status: [
|
||||||
|
{name: this.$t('test_track.plan.plan_status_prepare'), id: 'Prepare'},
|
||||||
|
{name: this.$t('test_track.plan.plan_status_running'), id: 'Underway'},
|
||||||
|
{name: this.$t('test_track.plan.plan_status_completed'), id: 'Completed'}
|
||||||
|
],
|
||||||
|
principal: [],
|
||||||
|
environmentId: []
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -279,6 +319,57 @@
|
||||||
handleBatchAddCase() {
|
handleBatchAddCase() {
|
||||||
this.planVisible = true;
|
this.planVisible = true;
|
||||||
},
|
},
|
||||||
|
handleDeleteBatch() {
|
||||||
|
this.$alert(this.$t('test_track.case.delete_confirm') + "?", '', {
|
||||||
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
|
callback: (action) => {
|
||||||
|
if (action === 'confirm') {
|
||||||
|
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||||
|
this.$post('/test/case/batch/delete', {ids: ids}, () => {
|
||||||
|
this.selectRows.clear();
|
||||||
|
this.$emit("refresh");
|
||||||
|
this.$success(this.$t('commons.delete_success'));
|
||||||
|
// 发送广播,刷新 head 上的最新列表
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleBatchEdit() {
|
||||||
|
this.$refs.batchEdit.open(this.selectDataCounts);
|
||||||
|
},
|
||||||
|
handleBatchMove() {
|
||||||
|
this.$emit("batchMove", Array.from(this.selectRows).map(row => row.id));
|
||||||
|
},
|
||||||
|
batchEdit(form) {
|
||||||
|
let arr = this.selection;
|
||||||
|
let ids = this.selection;
|
||||||
|
let param = {};
|
||||||
|
param[form.type] = form.value;
|
||||||
|
this.buildBatchParam(param);
|
||||||
|
this.$post('/api/automation/batch/edit', param, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
this.search();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getPrincipalOptions(option) {
|
||||||
|
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||||
|
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||||
|
option.push(...response.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getEnvsOptions(option) {
|
||||||
|
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
|
option.push(...response.data);
|
||||||
|
option.forEach(environment => {
|
||||||
|
if (!(environment.config instanceof Object)) {
|
||||||
|
environment.config = JSON.parse(environment.config);
|
||||||
|
}
|
||||||
|
environment.name = environment.name + (environment.config.httpConfig.socket ?
|
||||||
|
(': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
addTestPlan(plans) {
|
addTestPlan(plans) {
|
||||||
let obj = {planIds: plans, scenarioIds: this.selection};
|
let obj = {planIds: plans, scenarioIds: this.selection};
|
||||||
|
|
||||||
|
@ -316,18 +407,19 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
buildBatchParam(param) {
|
||||||
|
param.scenarioIds = this.selection;
|
||||||
|
param.projectId = getCurrentProjectID();
|
||||||
|
param.selectAllDate = this.isSelectAllDate;
|
||||||
|
param.unSelectIds = this.unSelection;
|
||||||
|
param = Object.assign(param, this.condition);
|
||||||
|
},
|
||||||
handleBatchExecute() {
|
handleBatchExecute() {
|
||||||
this.infoDb = false;
|
this.infoDb = false;
|
||||||
let url = "/api/automation/run/batch";
|
let url = "/api/automation/run/batch";
|
||||||
let run = {};
|
let run = {};
|
||||||
let scenarioIds = this.selection;
|
|
||||||
run.id = getUUID();
|
run.id = getUUID();
|
||||||
run.scenarioIds = scenarioIds;
|
this.buildBatchParam(run);
|
||||||
run.projectId = getCurrentProjectID();
|
|
||||||
run.selectAllDate = this.isSelectAllDate;
|
|
||||||
run.unSelectIds = this.unSelection;
|
|
||||||
|
|
||||||
run = Object.assign(run, this.condition);
|
|
||||||
this.$post(url, run, response => {
|
this.$post(url, run, response => {
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
this.runVisible = false;
|
this.runVisible = false;
|
||||||
|
|
|
@ -9,13 +9,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
||||||
import ApiEnvironmentConfig from "../ApiEnvironmentConfig";
|
|
||||||
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
|
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
|
||||||
import MsJarConfigList from "./JarConfigList";
|
import MsJarConfigList from "./JarConfigList";
|
||||||
import MsJarConfigFrom from "./JarConfigFrom";
|
import MsJarConfigFrom from "./JarConfigFrom";
|
||||||
export default {
|
export default {
|
||||||
name: "MsJarConfig",
|
name: "MsJarConfig",
|
||||||
components: {MsJarConfigFrom, MsJarConfigList, ApiEnvironmentConfig, MsDialogFooter},
|
components: {MsJarConfigFrom, MsJarConfigList, MsDialogFooter},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
|
@ -76,9 +76,13 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
open() {
|
open(size) {
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
|
if (size) {
|
||||||
|
this.size = size;
|
||||||
|
} else {
|
||||||
this.size = this.$parent.selectRows.size;
|
this.size = this.$parent.selectRows.size;
|
||||||
|
}
|
||||||
listenGoBack(this.handleClose);
|
listenGoBack(this.handleClose);
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
|
@ -90,6 +94,15 @@
|
||||||
this.$set(this.form, "value", "");
|
this.$set(this.form, "value", "");
|
||||||
this.filterable = val === "maintainer" || val === "executor";
|
this.filterable = val === "maintainer" || val === "executor";
|
||||||
this.options = this.valueArr[val];
|
this.options = this.valueArr[val];
|
||||||
|
this.typeArr.forEach(item => {
|
||||||
|
if (item.id === val) {
|
||||||
|
if (item.optionMethod) {
|
||||||
|
this.options = [];
|
||||||
|
item.optionMethod(this.options);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue