Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
3e985afc4b
|
@ -117,6 +117,12 @@ public class ApiAutomationController {
|
||||||
apiAutomationService.bathEdit(request);
|
apiAutomationService.bathEdit(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/batch/update/env")
|
||||||
|
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||||
|
public void batchUpdateEnv(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
|
apiAutomationService.batchUpdateEnv(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);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -15,4 +16,14 @@ public class ApiScenarioBatchRequest extends ApiScenarioWithBLOBs {
|
||||||
private String environmentId;
|
private String environmentId;
|
||||||
|
|
||||||
private ApiScenarioRequest condition;
|
private ApiScenarioRequest condition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境和项目对应关系
|
||||||
|
*/
|
||||||
|
private Map<String, String> envMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场景用例跨项目的关系
|
||||||
|
*/
|
||||||
|
private Map<String, List<String>> mapping;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,9 +90,28 @@ public class ApiAutomationService {
|
||||||
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
||||||
request = this.initRequest(request, true, true);
|
request = this.initRequest(request, true, true);
|
||||||
List<ApiScenarioDTO> list = extApiScenarioMapper.list(request);
|
List<ApiScenarioDTO> list = extApiScenarioMapper.list(request);
|
||||||
|
setApiScenarioProjectIds(list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setApiScenarioProjectIds(List<ApiScenarioDTO> list) {
|
||||||
|
// 如果场景步骤涉及多项目,则把涉及到的项目ID保存在projectIds属性
|
||||||
|
list.forEach(data -> {
|
||||||
|
String definition = data.getScenarioDefinition();
|
||||||
|
RunDefinitionRequest d = JSON.parseObject(definition, RunDefinitionRequest.class);
|
||||||
|
Map<String, String> map = d.getEnvironmentMap();
|
||||||
|
List<String> idList = new ArrayList<>();
|
||||||
|
if (map != null) {
|
||||||
|
Set<String> set = d.getEnvironmentMap().keySet();
|
||||||
|
idList = new ArrayList<>(set);
|
||||||
|
} else {
|
||||||
|
// 兼容历史数据,无EnvironmentMap直接赋值场景所属项目
|
||||||
|
idList.add(data.getProjectId());
|
||||||
|
}
|
||||||
|
data.setProjectIds(idList);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化部分参数
|
* 初始化部分参数
|
||||||
*
|
*
|
||||||
|
@ -908,4 +927,28 @@ public class ApiAutomationService {
|
||||||
return resList;
|
return resList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void batchUpdateEnv(ApiScenarioBatchRequest request) {
|
||||||
|
Map<String, String> envMap = request.getEnvMap();
|
||||||
|
Map<String, List<String>> mapping = request.getMapping();
|
||||||
|
Set<String> set = mapping.keySet();
|
||||||
|
if (set.isEmpty()) { return; }
|
||||||
|
set.forEach(id -> {
|
||||||
|
Map<String, String> newEnvMap = new HashMap<>(16);
|
||||||
|
if (envMap != null && !envMap.isEmpty()) {
|
||||||
|
List<String> list = mapping.get(id);
|
||||||
|
list.forEach(l -> {
|
||||||
|
newEnvMap.put(l, envMap.get(l));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!newEnvMap.isEmpty()) {
|
||||||
|
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id);
|
||||||
|
String definition = scenario.getScenarioDefinition();
|
||||||
|
JSONObject object = JSON.parseObject(definition);
|
||||||
|
object.put("environmentMap", newEnvMap);
|
||||||
|
String newDefinition = JSON.toJSONString(object);
|
||||||
|
scenario.setScenarioDefinition(newDefinition);
|
||||||
|
apiScenarioMapper.updateByPrimaryKeySelective(scenario);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,8 @@ public class TestPlanScenarioCaseService {
|
||||||
Set<String> set = d.getEnvironmentMap().keySet();
|
Set<String> set = d.getEnvironmentMap().keySet();
|
||||||
idList = new ArrayList<>(set);
|
idList = new ArrayList<>(set);
|
||||||
} else {
|
} else {
|
||||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(d.getEnvironmentId())) {
|
// 兼容历史数据,无EnvironmentMap直接赋值场景所属项目
|
||||||
idList.add(d.getEnvironmentId());
|
idList.add(data.getProjectId());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
data.setProjectIds(idList);
|
data.setProjectIds(idList);
|
||||||
});
|
});
|
||||||
|
|
|
@ -151,9 +151,6 @@
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')">
|
<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>
|
</batch-edit>
|
||||||
|
|
||||||
<batch-move @refresh="search" @moveSave="moveSave" ref="testBatchMove"/>
|
<batch-move @refresh="search" @moveSave="moveSave" ref="testBatchMove"/>
|
||||||
|
@ -166,7 +163,7 @@
|
||||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||||
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
|
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
|
||||||
import MsTag from "../../../common/components/MsTag";
|
import MsTag from "../../../common/components/MsTag";
|
||||||
import {downloadFile, getCurrentProjectID, getCurrentUser, getUUID} from "@/common/js/utils";
|
import {downloadFile, getCurrentProjectID, getCurrentUser, getUUID, strMapToObj} from "@/common/js/utils";
|
||||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||||
import MsTableMoreBtn from "./TableMoreBtn";
|
import MsTableMoreBtn from "./TableMoreBtn";
|
||||||
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
|
||||||
|
@ -288,7 +285,8 @@
|
||||||
{id: 'level', name: this.$t('test_track.case.priority')},
|
{id: 'level', name: this.$t('test_track.case.priority')},
|
||||||
{id: 'status', name: this.$t('test_track.plan.plan_status')},
|
{id: 'status', name: this.$t('test_track.plan.plan_status')},
|
||||||
{id: 'principal', name: this.$t('api_test.definition.request.responsible'), optionMethod: this.getPrincipalOptions},
|
{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},
|
// {id: 'environmentId', name: this.$t('api_test.definition.request.run_env'), optionMethod: this.getEnvsOptions},
|
||||||
|
{id: 'projectEnv', name: this.$t('api_test.definition.request.run_env')},
|
||||||
],
|
],
|
||||||
statusFilters: [
|
statusFilters: [
|
||||||
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
|
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
|
||||||
|
@ -319,7 +317,8 @@
|
||||||
{name: this.$t('test_track.plan.plan_status_completed'), id: 'Completed'}
|
{name: this.$t('test_track.plan.plan_status_completed'), id: 'Completed'}
|
||||||
],
|
],
|
||||||
principal: [],
|
principal: [],
|
||||||
environmentId: []
|
environmentId: [],
|
||||||
|
projectEnv: []
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -432,6 +431,7 @@
|
||||||
},
|
},
|
||||||
handleBatchEdit() {
|
handleBatchEdit() {
|
||||||
this.$refs.batchEdit.open(this.selectDataCounts);
|
this.$refs.batchEdit.open(this.selectDataCounts);
|
||||||
|
this.$refs.batchEdit.setScenarioSelectRows(this.selectRows);
|
||||||
},
|
},
|
||||||
handleBatchMove() {
|
handleBatchMove() {
|
||||||
this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
|
this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
|
||||||
|
@ -446,13 +446,31 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
batchEdit(form) {
|
batchEdit(form) {
|
||||||
let param = {};
|
// 批量修改环境
|
||||||
param[form.type] = form.value;
|
if (form.type === 'projectEnv') {
|
||||||
this.buildBatchParam(param);
|
let param = {};
|
||||||
this.$post('/api/automation/batch/edit', param, () => {
|
let map = new Map();
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.selectRows.forEach(row => {
|
||||||
this.search();
|
map.set(row.id, row.projectIds);
|
||||||
});
|
})
|
||||||
|
param.mapping = strMapToObj(map);
|
||||||
|
param.envMap = strMapToObj(form.projectEnvMap);
|
||||||
|
this.$post('/api/automation/batch/update/env', param, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
this.search();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 批量修改其它
|
||||||
|
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) {
|
getPrincipalOptions(option) {
|
||||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-input :placeholder="$t('api_test.definition.document.search_by_api_name')" @blur="initApiDocSimpleList()" style="float: right;width: 180px;margin-right: 5px" size="small"
|
<el-input :placeholder="$t('api_test.definition.document.search_by_api_name')" @blur="initApiDocSimpleList()" style="float: right;width: 180px;margin-right: 5px" size="small"
|
||||||
@keyup.enter.native="initApiDocSimpleList()" v-model="apiSearch.name"/>
|
@keyup.enter.native="initApiDocSimpleList()" v-model="apiSearch.name"/>
|
||||||
<api-document-batch-share v-xpack @shareApiDocument="shareApiDocument" :project-id="projectId" :share-url="batchShareUrl" style="float: right;margin: 6px;font-size: 17px"/>
|
<api-document-batch-share v-xpack v-if="showXpackCompnent" @shareApiDocument="shareApiDocument" :project-id="projectId" :share-url="batchShareUrl" style="float: right;margin: 6px;font-size: 17px"/>
|
||||||
|
<!-- <api-document-batch-share v-xpack v-if="showXpackCompnent"/>-->
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-divider></el-divider>
|
<el-divider></el-divider>
|
||||||
<div ref="apiDocInfoDiv" @scroll="handleScroll" >
|
<div ref="apiDocInfoDiv" @scroll="handleScroll" >
|
||||||
|
@ -300,6 +301,7 @@ export default {
|
||||||
shareUrl:"",
|
shareUrl:"",
|
||||||
batchShareUrl:"",
|
batchShareUrl:"",
|
||||||
apiStepIndex: 0,
|
apiStepIndex: 0,
|
||||||
|
showXpackCompnent:false,
|
||||||
apiInfoArray: [],
|
apiInfoArray: [],
|
||||||
modes: ['text', 'json', 'xml', 'html'],
|
modes: ['text', 'json', 'xml', 'html'],
|
||||||
formParamTypes: ['form-data', 'x-www-from-urlencoded', 'BINARY'],
|
formParamTypes: ['form-data', 'x-www-from-urlencoded', 'BINARY'],
|
||||||
|
@ -349,6 +351,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
if(requireComponent!=null && JSON.stringify(apiDocumentBatchShare) != '{}'){
|
||||||
|
this.showXpackCompnent = true;
|
||||||
|
}
|
||||||
this.initApiDocSimpleList();
|
this.initApiDocSimpleList();
|
||||||
this.clientHeight = `${document.documentElement.clientHeight}`;//获取浏览器可视区域高度
|
this.clientHeight = `${document.documentElement.clientHeight}`;//获取浏览器可视区域高度
|
||||||
let that = this;
|
let that = this;
|
||||||
|
@ -601,7 +606,6 @@ export default {
|
||||||
}
|
}
|
||||||
if(apiInfo == null || !apiInfo.selectedFlag){
|
if(apiInfo == null || !apiInfo.selectedFlag){
|
||||||
let apiId = apiInfo.id;
|
let apiId = apiInfo.id;
|
||||||
console.log(apiInfo.isSearching+":"+apiId);
|
|
||||||
if(!apiInfo.isSearching){
|
if(!apiInfo.isSearching){
|
||||||
apiInfo.isSearching = true;
|
apiInfo.isSearching = true;
|
||||||
this.selectApiInfo(beforeIndex,apiId);
|
this.selectApiInfo(beforeIndex,apiId);
|
||||||
|
@ -616,7 +620,6 @@ export default {
|
||||||
}
|
}
|
||||||
if(apiInfo == null || !apiInfo.selectedFlag){
|
if(apiInfo == null || !apiInfo.selectedFlag){
|
||||||
let apiId = apiInfo.id;
|
let apiId = apiInfo.id;
|
||||||
console.log(apiInfo.isSearching+":"+apiId);
|
|
||||||
if(!apiInfo.isSearching) {
|
if(!apiInfo.isSearching) {
|
||||||
apiInfo.isSearching = true;
|
apiInfo.isSearching = true;
|
||||||
this.selectApiInfo(afterIndex,apiId);
|
this.selectApiInfo(afterIndex,apiId);
|
||||||
|
|
|
@ -97,6 +97,7 @@
|
||||||
},
|
},
|
||||||
open(size) {
|
open(size) {
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
|
this.projectEnvMap.clear();
|
||||||
if (size) {
|
if (size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue