Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
764ee6507e
|
@ -144,6 +144,10 @@ public class ApiDefinitionController {
|
|||
public void createSchedule(@RequestBody Schedule request) {
|
||||
apiDefinitionService.createSchedule(request);
|
||||
}
|
||||
@PostMapping(value = "/schedule/update")
|
||||
public void updateSchedule(@RequestBody Schedule request){
|
||||
apiDefinitionService.updateSchedule(request);
|
||||
}
|
||||
|
||||
@PostMapping("/getReference")
|
||||
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
|
||||
|
|
|
@ -604,6 +604,10 @@ public class ApiDefinitionService {
|
|||
this.addOrUpdateSwaggerImportCronJob(request);
|
||||
|
||||
}
|
||||
public void updateSchedule(Schedule request){
|
||||
scheduleService.editSchedule(request);
|
||||
this.addOrUpdateSwaggerImportCronJob(request);
|
||||
}
|
||||
|
||||
private void addOrUpdateSwaggerImportCronJob(Schedule request) {
|
||||
scheduleService.addOrUpdateCronJob(request, SwaggerUrlImportJob.getJobKey(request.getResourceId()), SwaggerUrlImportJob.getTriggerKey(request.getResourceId()), SwaggerUrlImportJob.class);
|
||||
|
|
|
@ -290,11 +290,12 @@ public class ScheduleManager {
|
|||
addOrUpdateCronJob(jobKey, triggerKey, jobClass, cron, null);
|
||||
}
|
||||
|
||||
public JobDataMap getDefaultJobDataMap(String resourceId, String expression, String userId) {
|
||||
public JobDataMap getDefaultJobDataMap(String resourceId, String expression, String userId,String swaggerUrl) {
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("resourceId", resourceId);
|
||||
jobDataMap.put("expression", expression);
|
||||
jobDataMap.put("userId", userId);
|
||||
jobDataMap.put("swaggerUrl",swaggerUrl);
|
||||
return jobDataMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ public class SwaggerUrlImportJob extends MsScheduleJob {
|
|||
ApiTestImportRequest request = new ApiTestImportRequest();
|
||||
request.setProjectId(resourceId);
|
||||
request.setSwaggerUrl(swaggerUrl);
|
||||
request.setPlatform("Swagger2");
|
||||
request.setSaved(true);
|
||||
apiDefinitionService.apiTestImport(null, request);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public class ScheduleService {
|
|||
LogUtil.error("初始化任务:" + JSON.toJSONString(schedule));
|
||||
scheduleManager.addOrUpdateCronJob(new JobKey(schedule.getKey(), schedule.getGroup()),
|
||||
new TriggerKey(schedule.getKey(), schedule.getGroup()), Class.forName(schedule.getJob()), schedule.getValue(),
|
||||
scheduleManager.getDefaultJobDataMap(schedule.getResourceId(), schedule.getValue(), schedule.getUserId()));
|
||||
scheduleManager.getDefaultJobDataMap(schedule.getResourceId(), schedule.getValue(), schedule.getUserId(),schedule.getSwaggerUrl()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("初始化任务失败", e);
|
||||
|
@ -139,7 +139,8 @@ public class ScheduleService {
|
|||
String cronExpression = request.getValue();
|
||||
if (enable != null && enable && StringUtils.isNotBlank(cronExpression)) {
|
||||
try {
|
||||
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, clazz, cronExpression, scheduleManager.getDefaultJobDataMap(request.getResourceId(), cronExpression, SessionUtils.getUser().getId()));
|
||||
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, clazz, cronExpression,
|
||||
scheduleManager.getDefaultJobDataMap(request.getResourceId(), cronExpression, SessionUtils.getUser().getId(),request.getSwaggerUrl()));
|
||||
} catch (SchedulerException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException("定时任务开启异常");
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
@ -92,7 +91,7 @@
|
|||
<!-- 场景步骤-->
|
||||
<div v-loading="loading">
|
||||
<div @click="showAll">
|
||||
<p class="tip">{{$t('api_test.automation.scenario_step')}} </p>
|
||||
<p class="tip">{{ $t('api_test.automation.scenario_stepscenario_step') }} </p>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-col :span="21">
|
||||
|
@ -852,7 +851,6 @@
|
|||
this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenario.id, response => {
|
||||
if (response.data) {
|
||||
this.path = "/api/automation/update";
|
||||
this.currentScenario.description = response.data.description;
|
||||
if (response.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
|
|
|
@ -19,43 +19,60 @@
|
|||
</div>
|
||||
|
||||
<el-form :model="formData" :rules="rules" label-width="100px" v-loading="result.loading" ref="form">
|
||||
<el-row>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('commons.import_module')"
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)">
|
||||
<el-select size="small" v-model="formData.moduleId" class="project-select" clearable>
|
||||
<el-option v-for="item in moduleOptions" :key="item.id" :label="item.path" :value="item.id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.import_mode')"
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)">
|
||||
<el-select size="small" v-model="formData.modeId" class="project-select" clearable>
|
||||
<el-option v-for="item in modeOptions" :key="item.id" :label="item.name" :value="item.id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="10" style="margin-left: 20px">
|
||||
<el-upload
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)"
|
||||
class="api-upload"
|
||||
drag
|
||||
action=""
|
||||
:http-request="upload"
|
||||
:limit="1"
|
||||
:beforeUpload="uploadValidate"
|
||||
:on-remove="handleRemove"
|
||||
:file-list="fileList"
|
||||
:on-exceed="handleExceed"
|
||||
multiple>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
|
||||
<div class="el-upload__tip" slot="tip">{{ $t('api_test.api_import.file_size_limit') }}</div>
|
||||
</el-upload>
|
||||
</el-col>
|
||||
|
||||
<el-upload
|
||||
v-if="selectedPlatformValue != 'Swagger2' || (selectedPlatformValue == 'Swagger2' && !swaggerUrlEable)"
|
||||
class="api-upload"
|
||||
drag
|
||||
action=""
|
||||
:http-request="upload"
|
||||
:limit="1"
|
||||
:beforeUpload="uploadValidate"
|
||||
:on-remove="handleRemove"
|
||||
:file-list="fileList"
|
||||
:on-exceed="handleExceed"
|
||||
multiple>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
|
||||
<div class="el-upload__tip" slot="tip">{{ $t('api_test.api_import.file_size_limit') }}</div>
|
||||
</el-upload>
|
||||
<el-form-item :label="'Swagger URL'" prop="wgerUrl" v-if="isSwagger2 && swaggerUrlEable" class="swagger-url">
|
||||
<el-input size="small" v-model="formData.swaggerUrl" clearable show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isSwagger2" class="swagger-enable" :class="{'swagger-url-disable': !swaggerUrlEable}">
|
||||
<el-switch
|
||||
v-model="swaggerUrlEable"
|
||||
:active-text="$t('api_test.api_import.swagger_url_import')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="'Swagger URL'" prop="wgerUrl" v-if="isSwagger2 && swaggerUrlEable" class="swagger-url">
|
||||
<el-input size="small" v-model="formData.swaggerUrl" clearable show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isSwagger2 && swaggerUrlEable">
|
||||
<el-switch
|
||||
v-model="swaggerSynchronization"
|
||||
@click.native="scheduleEdit"
|
||||
:active-text="$t('api_test.api_import.timing_synchronization')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<schedule-import ref="scheduleEdit"></schedule-import>
|
||||
</el-row>
|
||||
|
||||
<el-form-item v-if="isSwagger2" class="swagger-enable" :class="{'swagger-url-disable': !swaggerUrlEable}">
|
||||
<el-switch
|
||||
v-model="swaggerUrlEable"
|
||||
:active-text="$t('api_test.api_import.swagger_url_import')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="isSwagger2 && swaggerUrlEable">
|
||||
<el-switch
|
||||
v-model="swaggerSynchronization"
|
||||
@click.native="scheduleEdit"
|
||||
:active-text="$t('api_test.api_import.timing_synchronization')">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<schedule-import ref="scheduleEdit"></schedule-import>
|
||||
|
||||
</el-form>
|
||||
|
||||
|
@ -76,6 +93,8 @@ import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
|||
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||
import {getCurrentProjectID} from "../../../../../../common/js/utils";
|
||||
import ScheduleImport from "@/business/components/api/definition/components/import/ImportScheduleEdit";
|
||||
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
|
||||
|
||||
export default {
|
||||
name: "ApiImport",
|
||||
components: {ScheduleImport, MsDialogFooter},
|
||||
|
@ -83,14 +102,24 @@ export default {
|
|||
saved: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
}
|
||||
},
|
||||
moduleOptions: {}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
swaggerUrlEable: false,
|
||||
swaggerSynchronization:false,
|
||||
swaggerSynchronization: false,
|
||||
showEnvironmentSelect: true,
|
||||
modeOptions: [{
|
||||
id: 'fullCoverage',
|
||||
name: '全量覆盖'
|
||||
},
|
||||
{
|
||||
id: 'incrementalMerge',
|
||||
name: '增量合并'
|
||||
}],
|
||||
protocol: "",
|
||||
platforms: [
|
||||
{
|
||||
name: 'Metersphere',
|
||||
|
@ -122,7 +151,9 @@ export default {
|
|||
useEnvironment: false,
|
||||
formData: {
|
||||
file: undefined,
|
||||
swaggerUrl: ''
|
||||
swaggerUrl: '',
|
||||
modeId: '',
|
||||
moduleId: ''
|
||||
},
|
||||
rules: {},
|
||||
currentModule: {},
|
||||
|
@ -148,15 +179,19 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
scheduleEdit(){
|
||||
if(this.swaggerSynchronization){
|
||||
this.$refs.scheduleEdit.open(this.buildParam());
|
||||
scheduleEdit() {
|
||||
if (this.swaggerSynchronization) {
|
||||
this.$refs.scheduleEdit.open(this.buildParam());
|
||||
} else {
|
||||
this.result = this.$post("/api/definition/schedule/update", this.schedule, response => {
|
||||
});
|
||||
}
|
||||
},
|
||||
open(module) {
|
||||
this.currentModule = module;
|
||||
this.visible = true;
|
||||
listenGoBack(this.close);
|
||||
|
||||
},
|
||||
upload(file) {
|
||||
this.formData.file = file.file;
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
}
|
||||
},
|
||||
planId: String,
|
||||
relevanceProjectId: String
|
||||
relevanceProjectId: String,
|
||||
},
|
||||
computed: {
|
||||
isPlanModel() {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
@saveAsEdit="saveAsEdit"
|
||||
@refresh="refresh"
|
||||
ref="basisApi"/>
|
||||
<api-import ref="apiImport" @refresh="$emit('refresh')"/>
|
||||
<api-import ref="apiImport" :moduleOptions="moduleOptions" @refresh="$emit('refresh')"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -43,6 +43,7 @@ import MsAddBasisApi from "../basis/AddBasisApi";
|
|||
import ApiImport from "../import/ApiImport";
|
||||
import ModuleTrashButton from "./ModuleTrashButton";
|
||||
import {getCurrentProjectID} from "../../../../../../common/js/utils";
|
||||
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
|
||||
|
||||
export default {
|
||||
name: "ApiModuleHeader",
|
||||
|
@ -50,6 +51,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
options: OPTIONS,
|
||||
moduleOptions: {}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -70,9 +72,10 @@ export default {
|
|||
default() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "debug":
|
||||
|
@ -88,6 +91,17 @@ export default {
|
|||
this.$warning(this.$t('commons.check_project_tip'));
|
||||
return;
|
||||
}
|
||||
this.protocol = "HTTP";
|
||||
this.result = this.$get("/api/module/list/" + getCurrentProjectID() + "/" + this.protocol, response => {
|
||||
if (response.data != undefined && response.data != null) {
|
||||
this.data = response.data;
|
||||
let moduleOptions = [];
|
||||
this.data.forEach(node => {
|
||||
buildNodePath(node, {path: ''}, moduleOptions);
|
||||
});
|
||||
this.moduleOptions = moduleOptions
|
||||
}
|
||||
});
|
||||
this.$refs.apiImport.open(this.currentModule);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -252,6 +252,9 @@ export default {
|
|||
activated() {
|
||||
this.initTableData();
|
||||
},
|
||||
created() {
|
||||
this.list()
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.dialogOrgAddVisible = true;
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
this.functionalCharData = [];
|
||||
if (this.executeResult.functionalResult) {
|
||||
this.executeResult.functionalResult.forEach(item => {
|
||||
let data = this.dataMap.get(item.status);
|
||||
let data = this.copyData(item.status);
|
||||
data.value = item.count;
|
||||
this.functionalCharData.push(data);
|
||||
});
|
||||
|
@ -129,7 +129,7 @@
|
|||
this.apiCharData = [];
|
||||
if (this.executeResult.apiResult) {
|
||||
this.executeResult.apiResult.forEach(item => {
|
||||
let data = this.dataMap.get(item.status);
|
||||
let data = this.copyData(item.status);
|
||||
data.value = item.count;
|
||||
this.apiCharData.push(data);
|
||||
});
|
||||
|
@ -139,7 +139,7 @@
|
|||
this.scenarioCharData = [];
|
||||
if (this.executeResult.apiResult) {
|
||||
this.executeResult.scenarioResult.forEach(item => {
|
||||
let data = this.dataMap.get(item.status);
|
||||
let data = this.copyData(item.status);
|
||||
data.value = item.count;
|
||||
this.scenarioCharData.push(data);
|
||||
});
|
||||
|
@ -149,12 +149,15 @@
|
|||
this.loadCharData = [];
|
||||
if (this.executeResult.loadResult) {
|
||||
this.executeResult.loadResult.forEach(item => {
|
||||
let data = this.dataMap.get(item.status);
|
||||
let data = this.copyData(item.status);
|
||||
data.value = item.count;
|
||||
this.loadCharData.push(data);
|
||||
});
|
||||
}
|
||||
},
|
||||
copyData(status) {
|
||||
return JSON.parse(JSON.stringify(this.dataMap.get(status)))
|
||||
},
|
||||
reload() {
|
||||
this.isShow = false;
|
||||
this.$nextTick(function () {
|
||||
|
|
|
@ -1 +1 @@
|
|||
export const PHONE_REGEX = '^1(3|4|5|7|8|9)\\d{9}$';
|
||||
export const PHONE_REGEX = '^1(3|4|5|6|7|8|9)\\d{9}$';
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export default {
|
||||
commons: {
|
||||
import_mode: 'Import mode',
|
||||
import_module: 'Import module',
|
||||
please_fill_in_the_template: 'Please fill in the template',
|
||||
cut_back_old_version: 'Cut back to old version',
|
||||
cut_back_new_version: 'Switch back to new version',
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export default {
|
||||
commons: {
|
||||
import_mode: '导入模式',
|
||||
import_module: '导入模块',
|
||||
please_fill_in_the_template: '请填写模版内容',
|
||||
cut_back_old_version: '切回旧版',
|
||||
cut_back_new_version: '切回新版',
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export default {
|
||||
commons: {
|
||||
import_mode: '導入模式',
|
||||
import_module: '導入模塊',
|
||||
please_fill_in_the_template: '請填寫模版內容',
|
||||
cut_back_old_version: '切回舊版',
|
||||
cut_back_new_version: '切回新版',
|
||||
|
|
Loading…
Reference in New Issue