Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
683d538b4b
|
@ -101,6 +101,12 @@ public class ApiAutomationController {
|
|||
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")
|
||||
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
||||
return apiAutomationService.getReference(request);
|
||||
|
|
|
@ -19,6 +19,8 @@ public class SaveApiScenarioRequest {
|
|||
|
||||
private String apiScenarioModuleId;
|
||||
|
||||
private String environmentId;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private String name;
|
||||
|
@ -40,4 +42,15 @@ public class SaveApiScenarioRequest {
|
|||
private MsTestElement scenarioDefinition;
|
||||
|
||||
List<String> bodyUploadIds;
|
||||
|
||||
private List<String> scenarioIds;
|
||||
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private List<String> filters;
|
||||
|
||||
private List<String> moduleIds;
|
||||
|
||||
private List<String> unSelectIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.api.dto.scenario;
|
|||
import io.metersphere.api.dto.scenario.request.BodyFile;
|
||||
import io.metersphere.commons.json.JSONSchemaGenerator;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
|
||||
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
|
||||
|
@ -81,12 +82,16 @@ public class Body {
|
|||
|
||||
private HTTPFileArg[] httpFileArgs(String requestId) {
|
||||
List<HTTPFileArg> list = new ArrayList<>();
|
||||
this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
|
||||
});
|
||||
this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(this.getKvs())) {
|
||||
this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getBinary())) {
|
||||
this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
|
||||
});
|
||||
}
|
||||
return list.toArray(new HTTPFileArg[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,7 @@ import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
|||
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.DateUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.job.sechedule.ApiScenarioTestJob;
|
||||
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.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
|
@ -45,6 +43,7 @@ import org.apache.jorphan.collections.ListedHashTree;
|
|||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -81,6 +80,9 @@ public class ApiAutomationService {
|
|||
SqlSessionFactory sqlSessionFactory;
|
||||
@Resource
|
||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||
@Resource
|
||||
@Lazy
|
||||
private TestPlanScenarioCaseService testPlanScenarioCaseService;
|
||||
|
||||
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
||||
request = this.initRequest(request,true,true);
|
||||
|
@ -199,6 +201,7 @@ public class ApiAutomationService {
|
|||
public void delete(String id) {
|
||||
//及连删除外键表
|
||||
this.preDelete(id);
|
||||
testPlanScenarioCaseService.deleteByScenarioId(id);
|
||||
apiScenarioMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
@ -600,6 +603,12 @@ public class ApiAutomationService {
|
|||
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) {
|
||||
Schedule schedule = scheduleService.buildApiTestSchedule(request);
|
||||
schedule.setJob(ApiScenarioTestJob.class.getName());
|
||||
|
@ -652,4 +661,35 @@ public class ApiAutomationService {
|
|||
dto.setXml(jmx);
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
|
|||
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
|
||||
import io.metersphere.api.dto.definition.request.timer.MsConstantTimer;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.Scenario;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.request.*;
|
||||
|
@ -108,12 +109,40 @@ public class HistoricalDataUpgradeService {
|
|||
URL urlObject = new URL(request1.getUrl());
|
||||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
||||
request1.setPath(envPath);
|
||||
request1.setUrl(null);
|
||||
} catch (Exception ex) {
|
||||
LogUtil.error(ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
request1.setUrl(null);
|
||||
}
|
||||
if (request1.getBody() != null && request1.getBody().isOldKV()) {
|
||||
request1.getBody().setType(Body.FORM_DATA);
|
||||
if (request1.getBody() != null) {
|
||||
request1.getBody().setBinary(new ArrayList<>());
|
||||
if (request1.getBody().isOldKV()) {
|
||||
request1.getBody().setType(Body.FORM_DATA);
|
||||
}
|
||||
if ("json".equals(request1.getBody().getFormat())) {
|
||||
request1.getBody().setType(Body.JSON);
|
||||
if (CollectionUtils.isEmpty(request1.getHeaders())) {
|
||||
List<KeyValue> headers = new LinkedList<>();
|
||||
headers.add(new KeyValue("Content-Type", "application/json"));
|
||||
request1.setHeaders(headers);
|
||||
} else {
|
||||
boolean isJsonType = false;
|
||||
for (KeyValue keyValue : request1.getHeaders()) {
|
||||
if ("Content-Type".equals(keyValue.getName())) {
|
||||
isJsonType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isJsonType) {
|
||||
request1.getHeaders().add(new KeyValue("Content-Type", "application/json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("xml".equals(request1.getBody().getFormat())) {
|
||||
request1.getBody().setType(Body.XML);
|
||||
}
|
||||
}
|
||||
BeanUtils.copyBean(element, request1);
|
||||
((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP);
|
||||
|
@ -292,7 +321,7 @@ public class HistoricalDataUpgradeService {
|
|||
copyDir(dir, BODY_FILE_DIR);
|
||||
}
|
||||
|
||||
private void createApiScenarioWithBLOBs(SaveHistoricalDataUpgrade saveHistoricalDataUpgrade, Scenario oldScenario, String scenarioDefinition, ApiScenarioMapper mapper) {
|
||||
private void createApiScenarioWithBLOBs(SaveHistoricalDataUpgrade saveHistoricalDataUpgrade, Scenario oldScenario, String scenarioDefinition, ApiScenarioMapper mapper, int num) {
|
||||
if (StringUtils.isEmpty(oldScenario.getName())) {
|
||||
oldScenario.setName("默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
||||
}
|
||||
|
@ -310,7 +339,6 @@ public class HistoricalDataUpgradeService {
|
|||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setStatus(ScenarioStatus.Underway.name());
|
||||
scenario.setUserId(SessionUtils.getUserId());
|
||||
scenario.setNum(getNextNum(saveHistoricalDataUpgrade.getProjectId()));
|
||||
mapper.updateByPrimaryKeySelective(scenario);
|
||||
} else {
|
||||
scenario = new ApiScenarioWithBLOBs();
|
||||
|
@ -328,7 +356,7 @@ public class HistoricalDataUpgradeService {
|
|||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setStatus(ScenarioStatus.Underway.name());
|
||||
scenario.setUserId(SessionUtils.getUserId());
|
||||
scenario.setNum(getNextNum(saveHistoricalDataUpgrade.getProjectId()));
|
||||
scenario.setNum(num);
|
||||
mapper.insert(scenario);
|
||||
}
|
||||
}
|
||||
|
@ -342,6 +370,7 @@ public class HistoricalDataUpgradeService {
|
|||
List<ApiTest> blobs = apiTestMapper.selectByExampleWithBLOBs(example);
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioMapper mapper = sqlSession.getMapper(ApiScenarioMapper.class);
|
||||
int num = getNextNum(saveHistoricalDataUpgrade.getProjectId());
|
||||
for (ApiTest test : blobs) {
|
||||
// 附件迁移
|
||||
createBodyFiles(test.getId());
|
||||
|
@ -352,7 +381,8 @@ public class HistoricalDataUpgradeService {
|
|||
for (Scenario scenario : scenarios) {
|
||||
MsScenario scenario1 = createScenario(scenario);
|
||||
String scenarioDefinition = JSON.toJSONString(scenario1);
|
||||
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenario, scenarioDefinition, mapper);
|
||||
num++;
|
||||
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenario, scenarioDefinition, mapper, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -365,14 +395,16 @@ public class HistoricalDataUpgradeService {
|
|||
environmentDTOMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(environments)) {
|
||||
environments.forEach(environment -> {
|
||||
EnvironmentConfig envConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
if (CollectionUtils.isNotEmpty(envConfig.getDatabaseConfigs())) {
|
||||
envConfig.getDatabaseConfigs().forEach(item -> {
|
||||
EnvironmentDTO dto = new EnvironmentDTO();
|
||||
dto.setDatabaseConfig(item);
|
||||
dto.setEnvironmentId(environment.getId());
|
||||
environmentDTOMap.put(item.getId(), dto);
|
||||
});
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig envConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
if (CollectionUtils.isNotEmpty(envConfig.getDatabaseConfigs())) {
|
||||
envConfig.getDatabaseConfigs().forEach(item -> {
|
||||
EnvironmentDTO dto = new EnvironmentDTO();
|
||||
dto.setDatabaseConfig(item);
|
||||
dto.setEnvironmentId(environment.getId());
|
||||
environmentDTOMap.put(item.getId(), dto);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -125,4 +125,16 @@ public class TestPlanScenarioCaseService {
|
|||
request.setPlanId(planId);
|
||||
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>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
|
@ -120,10 +126,15 @@
|
|||
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
|
||||
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
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 {
|
||||
name: "MsApiScenarioList",
|
||||
components: {
|
||||
EnvironmentSelect,
|
||||
BatchEdit,
|
||||
PlanStatusTableItem,
|
||||
PriorityTableItem,
|
||||
MsTableSelectAll,
|
||||
|
@ -176,13 +187,42 @@
|
|||
buttons: [
|
||||
{
|
||||
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('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
|
||||
// }
|
||||
],
|
||||
isSelectAllDate: false,
|
||||
unSelection: [],
|
||||
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() {
|
||||
|
@ -279,6 +319,57 @@
|
|||
handleBatchAddCase() {
|
||||
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) {
|
||||
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() {
|
||||
this.infoDb = false;
|
||||
let url = "/api/automation/run/batch";
|
||||
let run = {};
|
||||
let scenarioIds = this.selection;
|
||||
run.id = getUUID();
|
||||
run.scenarioIds = scenarioIds;
|
||||
run.projectId = getCurrentProjectID();
|
||||
run.selectAllDate = this.isSelectAllDate;
|
||||
run.unSelectIds = this.unSelection;
|
||||
|
||||
run = Object.assign(run, this.condition);
|
||||
this.buildBatchParam(run);
|
||||
this.$post(url, run, response => {
|
||||
let data = response.data;
|
||||
this.runVisible = false;
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
<!-- 添加/编辑测试窗口-->
|
||||
<div v-else-if="item.type=== 'ADD'" class="ms-api-div">
|
||||
<ms-api-config @runTest="runTest" @saveApi="saveApi" @createRootModel="createRootModel" ref="apiConfig"
|
||||
<ms-api-config :syncTabs="syncTabs" @runTest="runTest" @saveApi="saveApi" @createRootModel="createRootModel" ref="apiConfig"
|
||||
:current-api="item.api"
|
||||
:currentProtocol="currentProtocol"
|
||||
:moduleOptions="moduleOptions"/>
|
||||
|
@ -76,13 +76,13 @@
|
|||
|
||||
<!-- 测试-->
|
||||
<div v-else-if="item.type=== 'TEST'" class="ms-api-div">
|
||||
<ms-run-test-http-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-http-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='HTTP'"/>
|
||||
<ms-run-test-tcp-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-tcp-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='TCP'"/>
|
||||
<ms-run-test-sql-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-sql-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='SQL'"/>
|
||||
<ms-run-test-dubbo-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-dubbo-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='DUBBO'"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
@ -184,7 +184,8 @@
|
|||
type: "list",
|
||||
closable: false
|
||||
}],
|
||||
isApiListEnable: true
|
||||
isApiListEnable: true,
|
||||
syncTabs: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
<div class="card-container">
|
||||
<!-- HTTP 请求参数 -->
|
||||
<ms-edit-complete-http-api @runTest="runTest" @saveApi="saveApi" @createRootModelInTree="createRootModelInTree" :request="request" :response="response"
|
||||
:basisData="currentApi" :moduleOptions="moduleOptions" v-if="currentProtocol === 'HTTP'"/>
|
||||
:basisData="currentApi" :moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'HTTP'"/>
|
||||
<!-- TCP -->
|
||||
<ms-edit-complete-tcp-api :request="request" @runTest="runTest" @createRootModelInTree="createRootModelInTree" @saveApi="saveApi" :basisData="currentApi"
|
||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'TCP'"/>
|
||||
:moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'TCP'"/>
|
||||
<!--DUBBO-->
|
||||
<ms-edit-complete-dubbo-api :request="request" @runTest="runTest" @createRootModelInTree="createRootModelInTree" @saveApi="saveApi" :basisData="currentApi"
|
||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'DUBBO'"/>
|
||||
:moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'DUBBO'"/>
|
||||
<!--SQL-->
|
||||
<ms-edit-complete-sql-api :request="request" @runTest="runTest" @createRootModelInTree="createRootModelInTree" @saveApi="saveApi" :basisData="currentApi"
|
||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'SQL'"/>
|
||||
:moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'SQL'"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
|||
currentApi: {},
|
||||
moduleOptions: {},
|
||||
currentProtocol: String,
|
||||
syncTabs: Array,
|
||||
},
|
||||
created() {
|
||||
this.projectId = getCurrentProjectID();
|
||||
|
@ -75,7 +76,7 @@
|
|||
this.$emit('runTest', data);
|
||||
})
|
||||
},
|
||||
createRootModelInTree(){
|
||||
createRootModelInTree() {
|
||||
this.$emit("createRootModel");
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
|
|
|
@ -44,8 +44,30 @@
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
syncTabs: Array,
|
||||
},
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {validated: false}
|
||||
},
|
||||
|
|
|
@ -149,7 +149,29 @@
|
|||
options: API_STATUS,
|
||||
}
|
||||
},
|
||||
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}},
|
||||
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array},
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
this.httpForm.path = response.data.path;
|
||||
this.httpForm.method = response.data.method;
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
runTest() {
|
||||
this.$refs['httpForm'].validate((valid) => {
|
||||
|
|
|
@ -43,9 +43,29 @@ export default {
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
syncTabs:{},
|
||||
},
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {validated: false}
|
||||
},
|
||||
|
|
|
@ -42,14 +42,34 @@ export default {
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
syncTabs:Array,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
validated: false,
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
callback() {
|
||||
this.validated = true;
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
reportId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -173,6 +173,9 @@
|
|||
let bodyFiles = this.getBodyUploadFiles();
|
||||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
this.$emit('saveApi', this.api);
|
||||
});
|
||||
},
|
||||
|
@ -228,7 +231,8 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getEnvironments();
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
projectId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String, syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -205,6 +205,9 @@
|
|||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.$emit('saveApi', this.api);
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
});
|
||||
},
|
||||
selectTestCase(item) {
|
||||
|
@ -230,7 +233,8 @@
|
|||
},
|
||||
created() {
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getResult();
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
reportId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -172,6 +172,9 @@
|
|||
let bodyFiles = this.getBodyUploadFiles();
|
||||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
this.$emit('saveApi', this.api);
|
||||
});
|
||||
},
|
||||
|
@ -227,7 +230,8 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getEnvironments();
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
projectId: ""
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -173,6 +173,9 @@
|
|||
let bodyFiles = this.getBodyUploadFiles();
|
||||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
this.$emit('saveApi', this.api);
|
||||
});
|
||||
},
|
||||
|
@ -194,7 +197,8 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.projectId = getCurrentProjectID();
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
|
||||
<script>
|
||||
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
||||
import ApiEnvironmentConfig from "../ApiEnvironmentConfig";
|
||||
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
|
||||
import MsJarConfigList from "./JarConfigList";
|
||||
import MsJarConfigFrom from "./JarConfigFrom";
|
||||
export default {
|
||||
name: "MsJarConfig",
|
||||
components: {MsJarConfigFrom, MsJarConfigList, ApiEnvironmentConfig, MsDialogFooter},
|
||||
components: {MsJarConfigFrom, MsJarConfigList, MsDialogFooter},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div id="app" v-loading="loading">
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane :label="$t('organization.message.template')" name="apiTemplate">
|
||||
<el-button type="primary" size="mini" style="margin-left: 10px" @click="openOneClickOperation">导入</el-button>
|
||||
<el-button type="primary" size="mini" style="margin: 10px 10px 0px" @click="openOneClickOperation">导入</el-button>
|
||||
<div style="min-height: 200px">
|
||||
<json-schema-editor class="schema" :value="schema" lang="zh_CN" custom/>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
title="导入"
|
||||
:visible.sync="importVisible"
|
||||
width="50%"
|
||||
append-to-body
|
||||
show-close
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleClose">
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<json-schema-editor :value="{items:pickValue.items}" :deep="deep+1" disabled isItem :root="false" class="children" :lang="lang" :custom="custom"/>
|
||||
</template>
|
||||
<!-- 高级设置-->
|
||||
<el-dialog :close-on-click-modal="false" :title="$t('schema.adv_setting')" :visible.sync="modalVisible" :destroy-on-close="true"
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :title="$t('schema.adv_setting')" :visible.sync="modalVisible" :destroy-on-close="true"
|
||||
@close="handleClose">
|
||||
<p class="tip">基础设置 </p>
|
||||
<el-form :inline="true" v-model="advancedValue" class="ms-advanced-search-form">
|
||||
|
|
|
@ -76,9 +76,13 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
open() {
|
||||
open(size) {
|
||||
this.dialogVisible = true;
|
||||
this.size = this.$parent.selectRows.size;
|
||||
if (size) {
|
||||
this.size = size;
|
||||
} else {
|
||||
this.size = this.$parent.selectRows.size;
|
||||
}
|
||||
listenGoBack(this.handleClose);
|
||||
},
|
||||
handleClose() {
|
||||
|
@ -90,6 +94,15 @@
|
|||
this.$set(this.form, "value", "");
|
||||
this.filterable = val === "maintainer" || val === "executor";
|
||||
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