refactor(接口测试): 优化保存接口弹窗设置
--user=郭雨琦 --bug=1015217 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015217 --bug=1015215 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015215
This commit is contained in:
parent
ecbdb4734c
commit
401e317238
|
@ -13,10 +13,7 @@ import io.metersphere.api.dto.scenario.Body;
|
||||||
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
|
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
|
||||||
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
|
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
|
||||||
import io.metersphere.api.exec.queue.ExecThreadPoolExecutor;
|
import io.metersphere.api.exec.queue.ExecThreadPoolExecutor;
|
||||||
import io.metersphere.api.service.ApiDefinitionService;
|
import io.metersphere.api.service.*;
|
||||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
|
||||||
import io.metersphere.api.service.EsbApiParamService;
|
|
||||||
import io.metersphere.api.service.EsbImportService;
|
|
||||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
import io.metersphere.base.domain.Schedule;
|
import io.metersphere.base.domain.Schedule;
|
||||||
import io.metersphere.commons.constants.NoticeConstants;
|
import io.metersphere.commons.constants.NoticeConstants;
|
||||||
|
@ -51,6 +48,8 @@ public class ApiDefinitionController {
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionService apiDefinitionService;
|
private ApiDefinitionService apiDefinitionService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private ApiTestCaseService apiTestCaseService;
|
||||||
|
@Resource
|
||||||
private CheckPermissionService checkPermissionService;
|
private CheckPermissionService checkPermissionService;
|
||||||
@Resource
|
@Resource
|
||||||
private EsbApiParamService esbApiParamService;
|
private EsbApiParamService esbApiParamService;
|
||||||
|
@ -64,6 +63,12 @@ public class ApiDefinitionController {
|
||||||
@PostMapping("/list/{goPage}/{pageSize}")
|
@PostMapping("/list/{goPage}/{pageSize}")
|
||||||
@RequiresPermissions("PROJECT_API_DEFINITION:READ")
|
@RequiresPermissions("PROJECT_API_DEFINITION:READ")
|
||||||
public Pager<List<ApiDefinitionResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
|
public Pager<List<ApiDefinitionResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
|
||||||
|
if (request.getToBeUpdated() != null && request.getToBeUpdated()) {
|
||||||
|
Long toBeUpdatedTime = apiTestCaseService.getToBeUpdatedTime(request.getProjectId());
|
||||||
|
if (toBeUpdatedTime != null) {
|
||||||
|
request.setToBeUpdateTime(toBeUpdatedTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
return PageUtils.setPageInfo(page, apiDefinitionService.list(request));
|
return PageUtils.setPageInfo(page, apiDefinitionService.list(request));
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,12 +170,6 @@ public class ApiDefinitionService {
|
||||||
|
|
||||||
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
|
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
|
||||||
request = this.initRequest(request, true, true);
|
request = this.initRequest(request, true, true);
|
||||||
if (request.getToBeUpdated() != null && request.getToBeUpdated()) {
|
|
||||||
Long toBeUpdatedTime = apiTestCaseService.getToBeUpdatedTime(request.getProjectId());
|
|
||||||
if (toBeUpdatedTime != null) {
|
|
||||||
request.setToBeUpdateTime(toBeUpdatedTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<ApiDefinitionResult> resList = extApiDefinitionMapper.list(request);
|
List<ApiDefinitionResult> resList = extApiDefinitionMapper.list(request);
|
||||||
buildUserInfo(resList);
|
buildUserInfo(resList);
|
||||||
if (StringUtils.isNotBlank(request.getProjectId())) {
|
if (StringUtils.isNotBlank(request.getProjectId())) {
|
||||||
|
|
|
@ -192,7 +192,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<span v-if="syncCases">{{ $t('workstation.sync') + $t('commons.setting') }}</span><br/>
|
<span v-if="syncCases">{{ $t('workstation.sync') + $t('commons.setting') }}</span><br/>
|
||||||
<el-row style="margin-bottom: 10px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
|
<el-row style="margin-bottom: 10px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
|
||||||
<sync-settings v-if="syncCases" ref="synSetting"></sync-settings>
|
<sync-setting v-if="syncCases" ref="synSetting"></sync-setting>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row style="margin-bottom: 10px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
|
<el-row style="margin-bottom: 10px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
|
||||||
<div class="timeClass">
|
<div class="timeClass">
|
||||||
|
@ -235,8 +235,8 @@ import {createComponent} from ".././jmeter/components";
|
||||||
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||||
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||||
import {getProjectMemberOption} from "@/network/user";
|
import {getProjectMemberOption} from "@/network/user";
|
||||||
import SyncSettings from "@/business/components/xpack/workstation/component/SyncSettings";
|
|
||||||
import {deepClone} from "@/common/js/tableUtils";
|
import {deepClone} from "@/common/js/tableUtils";
|
||||||
|
import SyncSetting from "@/business/components/api/definition/util/SyncSetting";
|
||||||
|
|
||||||
const {Body} = require("@/business/components/api/definition/model/ApiTestModel");
|
const {Body} = require("@/business/components/api/definition/model/ApiTestModel");
|
||||||
const Sampler = require("@/business/components/api/definition/components/jmeter/components/sampler/sampler");
|
const Sampler = require("@/business/components/api/definition/components/jmeter/components/sampler/sampler");
|
||||||
|
@ -252,7 +252,7 @@ export default {
|
||||||
ApiOtherInfo,
|
ApiOtherInfo,
|
||||||
MsFormDivider,
|
MsFormDivider,
|
||||||
MsJsr233Processor, MsResponseText, MsApiRequestForm, MsInputTag, MsSelectTree, MsChangeHistory,
|
MsJsr233Processor, MsResponseText, MsApiRequestForm, MsInputTag, MsSelectTree, MsChangeHistory,
|
||||||
HttpApiVersionDiff, SyncSettings,
|
HttpApiVersionDiff, SyncSetting,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
let validateURL = (rule, value, callback) => {
|
let validateURL = (rule, value, callback) => {
|
||||||
|
@ -284,7 +284,7 @@ export default {
|
||||||
},
|
},
|
||||||
httpForm: {environmentId: "", path: "", tags: []},
|
httpForm: {environmentId: "", path: "", tags: []},
|
||||||
beforeHttpForm: {environmentId: "", path: "", tags: []},
|
beforeHttpForm: {environmentId: "", path: "", tags: []},
|
||||||
beforeRequest: {},
|
beforeRequest: {arguments: []},
|
||||||
beforeResponse: {},
|
beforeResponse: {},
|
||||||
newData: {environmentId: "", path: "", tags: []},
|
newData: {environmentId: "", path: "", tags: []},
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
|
@ -311,7 +311,8 @@ export default {
|
||||||
syncCases: true,
|
syncCases: true,
|
||||||
specialReceivers: false,
|
specialReceivers: false,
|
||||||
caseCreator: false,
|
caseCreator: false,
|
||||||
scenarioCreator: false
|
scenarioCreator: false,
|
||||||
|
apiSyncCaseRequest: {},
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -521,40 +522,52 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasLicense() && this.httpForm.caseTotal > 0) {
|
if (hasLicense() && this.httpForm.caseTotal > 0) {
|
||||||
if (this.httpForm.name !== this.beforeHttpForm.name) {
|
|
||||||
this.batchSyncApiVisible = true;
|
if (this.apiSyncCaseRequest && this.apiSyncCaseRequest.method) {
|
||||||
}
|
|
||||||
if (this.httpForm.method !== this.beforeHttpForm.method) {
|
if (this.httpForm.method !== this.beforeHttpForm.method) {
|
||||||
this.batchSyncApiVisible = true;
|
this.batchSyncApiVisible = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (this.apiSyncCaseRequest && this.apiSyncCaseRequest.path) {
|
||||||
if (this.httpForm.path !== this.beforeHttpForm.path) {
|
if (this.httpForm.path !== this.beforeHttpForm.path) {
|
||||||
this.batchSyncApiVisible = true;
|
this.batchSyncApiVisible = true;
|
||||||
}
|
}
|
||||||
if (this.httpForm.userId !== this.beforeHttpForm.userId) {
|
}
|
||||||
|
if (this.apiSyncCaseRequest && this.apiSyncCaseRequest.headers) {
|
||||||
|
if (this.request.headers && this.beforeRequest.headers) {
|
||||||
|
let submitRequestHeaders = JSON.stringify(this.request.headers);
|
||||||
|
let beforeRequestHeaders = JSON.stringify(this.beforeRequest.headers);
|
||||||
|
if (submitRequestHeaders !== beforeRequestHeaders) {
|
||||||
this.batchSyncApiVisible = true;
|
this.batchSyncApiVisible = true;
|
||||||
}
|
}
|
||||||
if (this.httpForm.moduleId !== this.beforeHttpForm.moduleId) {
|
}
|
||||||
|
}
|
||||||
|
if (this.apiSyncCaseRequest && this.apiSyncCaseRequest.query) {
|
||||||
|
if (this.request.arguments && this.beforeRequest.arguments) {
|
||||||
|
let submitRequestQuery = JSON.stringify(this.request.arguments);
|
||||||
|
let beforeRequestQuery = JSON.stringify(this.beforeRequest.arguments);
|
||||||
|
if (submitRequestQuery !== beforeRequestQuery) {
|
||||||
this.batchSyncApiVisible = true;
|
this.batchSyncApiVisible = true;
|
||||||
}
|
}
|
||||||
if (this.httpForm.status !== this.beforeHttpForm.status) {
|
}
|
||||||
|
}
|
||||||
|
if (this.apiSyncCaseRequest && this.apiSyncCaseRequest.rest) {
|
||||||
|
if (this.request.rest && this.beforeRequest.rest) {
|
||||||
|
let submitRequestRest = JSON.stringify(this.request.rest);
|
||||||
|
let beforeRequestRest = JSON.stringify(this.beforeRequest.rest);
|
||||||
|
if (submitRequestRest !== beforeRequestRest) {
|
||||||
this.batchSyncApiVisible = true;
|
this.batchSyncApiVisible = true;
|
||||||
}
|
}
|
||||||
if (!this.beforeHttpForm.tags) {
|
|
||||||
this.beforeHttpForm.tags = [];
|
|
||||||
this.beforeHttpForm.tags = JSON.stringify(this.beforeHttpForm.tags)
|
|
||||||
}
|
}
|
||||||
if (this.httpForm.tags !== this.beforeHttpForm.tags) {
|
}
|
||||||
|
if (this.apiSyncCaseRequest && this.apiSyncCaseRequest.body) {
|
||||||
|
if (this.request.body && this.beforeRequest.body) {
|
||||||
|
let submitRequestBody = JSON.stringify(this.request.body);
|
||||||
|
let beforeRequestBody = JSON.stringify(this.beforeRequest.body);
|
||||||
|
if (submitRequestBody !== beforeRequestBody) {
|
||||||
this.batchSyncApiVisible = true;
|
this.batchSyncApiVisible = true;
|
||||||
}
|
}
|
||||||
let submitRequest = JSON.stringify(this.request);
|
|
||||||
let beforeRequestHeaders = JSON.stringify(this.beforeRequest);
|
|
||||||
if (submitRequest !== beforeRequestHeaders) {
|
|
||||||
this.batchSyncApiVisible = true;
|
|
||||||
}
|
}
|
||||||
let submitResponse = JSON.stringify(this.response);
|
|
||||||
let beforeResponse = JSON.stringify(this.response);
|
|
||||||
if (submitResponse !== beforeResponse) {
|
|
||||||
this.batchSyncApiVisible = true;
|
|
||||||
}
|
}
|
||||||
if (this.batchSyncApiVisible !== true) {
|
if (this.batchSyncApiVisible !== true) {
|
||||||
this.$emit('saveApi', this.httpForm);
|
this.$emit('saveApi', this.httpForm);
|
||||||
|
@ -851,10 +864,18 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getApplication() {
|
||||||
|
this.$get('/project_application/get/config/' + this.projectId + "/TRIGGER_UPDATE", res => {
|
||||||
|
if (res.data && res.data.triggerUpdate) {
|
||||||
|
this.apiSyncCaseRequest = JSON.parse(res.data.triggerUpdate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.getMaintainerOptions();
|
this.getMaintainerOptions();
|
||||||
|
this.getApplication();
|
||||||
if (!this.basisData.environmentId) {
|
if (!this.basisData.environmentId) {
|
||||||
this.basisData.environmentId = "";
|
this.basisData.environmentId = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@
|
||||||
|
|
||||||
<el-dialog :visible.sync="batchSyncCaseVisible" :title="$t('commons.batch')+$t('workstation.sync')">
|
<el-dialog :visible.sync="batchSyncCaseVisible" :title="$t('commons.batch')+$t('workstation.sync')">
|
||||||
<span>{{ $t('workstation.sync') + $t('commons.setting') }}</span><br/>
|
<span>{{ $t('workstation.sync') + $t('commons.setting') }}</span><br/>
|
||||||
<sync-settings ref="synSetting"></sync-settings>
|
<sync-setting ref="synSetting"></sync-setting>
|
||||||
<span style="color: red">{{ $t('workstation.batch_sync_api_tips') }}</span>
|
<span style="color: red">{{ $t('workstation.batch_sync_api_tips') }}</span>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button @click="batchSyncCaseVisible = false">取 消</el-button>
|
<el-button @click="batchSyncCaseVisible = false">取 消</el-button>
|
||||||
|
@ -308,7 +308,7 @@ import {editApiTestCaseOrder} from "@/network/api";
|
||||||
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||||
import i18n from "@/i18n/i18n";
|
import i18n from "@/i18n/i18n";
|
||||||
import MsSearch from "@/business/components/common/components/search/MsSearch";
|
import MsSearch from "@/business/components/common/components/search/MsSearch";
|
||||||
import SyncSettings from "@/business/components/xpack/workstation/component/SyncSettings";
|
import SyncSetting from "@/business/components/api/definition/util/SyncSetting";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiCaseSimpleList",
|
name: "ApiCaseSimpleList",
|
||||||
|
@ -336,7 +336,7 @@ export default {
|
||||||
MsRequestResultTail,
|
MsRequestResultTail,
|
||||||
MsApiCaseRunModeWithEnv,
|
MsApiCaseRunModeWithEnv,
|
||||||
MsSearch,
|
MsSearch,
|
||||||
SyncSettings,
|
SyncSetting,
|
||||||
PlanStatusTableItem: () => import("../../../../track/common/tableItems/plan/PlanStatusTableItem"),
|
PlanStatusTableItem: () => import("../../../../track/common/tableItems/plan/PlanStatusTableItem"),
|
||||||
MsTaskCenter: () => import("@/business/components/task/TaskCenter"),
|
MsTaskCenter: () => import("@/business/components/task/TaskCenter"),
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="4">{{ $t('api_test.mock.base_info') + ":" }}</el-col>
|
||||||
|
<el-col :span="20" style="color: #783887">
|
||||||
|
<el-checkbox v-model="fromData.protocol" disabled>{{
|
||||||
|
$t('api_report.request') + $t('api_test.request.protocol')
|
||||||
|
}}
|
||||||
|
</el-checkbox>
|
||||||
|
<el-checkbox v-model="fromData.method" disabled>
|
||||||
|
{{ $t('api_test.definition.document.request_method') + '\xa0\xa0\xa0\xa0\xa0' }}
|
||||||
|
</el-checkbox>
|
||||||
|
<el-checkbox v-model="fromData.path" disabled>{{ "URL" }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="4">{{ $t('api_test.mock.req_param') + ":" }}</el-col>
|
||||||
|
<el-col :span="20" style="color: #783887">
|
||||||
|
<el-checkbox v-model="fromData.headers">{{ "Header" + '\xa0\xa0' }}</el-checkbox>
|
||||||
|
<el-checkbox v-model="fromData.query">{{ $t('api_test.definition.request.query_param') }}</el-checkbox>
|
||||||
|
<el-checkbox v-model="fromData.rest">{{ $t('api_test.definition.request.rest_param') }}</el-checkbox>
|
||||||
|
<el-checkbox v-model="fromData.body">{{ $t('api_test.request.body') }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="4">{{ $t('api_test.definition.request.other_config') + ":" }}</el-col>
|
||||||
|
<el-col :span="20" style="color: #783887">
|
||||||
|
<el-checkbox v-model="fromData.delNotSame">{{ $t('workstation.delNotSame') }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "SyncSetting",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
fromData: {
|
||||||
|
protocol: true,
|
||||||
|
method: true,
|
||||||
|
path: true,
|
||||||
|
headers: true,
|
||||||
|
query: true,
|
||||||
|
rest: true,
|
||||||
|
body: true,
|
||||||
|
delNotSame: true,
|
||||||
|
runError: true,
|
||||||
|
unRun: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.el-row {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue