feat: swagger定时自动同步

This commit is contained in:
wenyann 2021-01-18 18:05:25 +08:00
parent 41f928aa89
commit 5b2359ec3c
9 changed files with 228 additions and 196 deletions

View File

@ -163,7 +163,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
apiReportService.complete(testResult, report);
} else if (StringUtils.equals(this.runMode, ApiRunMode.DELIMIT.name())) {
// 调试操作不需要存储结果
if (!StringUtils.isBlank(debugReportId)) {
if (StringUtils.isBlank(debugReportId)) {
apiDefinitionService.addResult(testResult);
} else {
apiDefinitionService.addResult(testResult);

View File

@ -486,10 +486,7 @@ public class ApiTestCaseService {
}
public String getExecResult(String id){
ApiDefinitionExecResultExample apidefinitionexecresultexample = new ApiDefinitionExecResultExample();
ApiDefinitionExecResultExample.Criteria criteria = apidefinitionexecresultexample.createCriteria();
criteria.andResourceIdEqualTo(id);
String status=apiDefinitionExecResultMapper.selectByExample(apidefinitionexecresultexample).get(0).getStatus();
String status=apiDefinitionExecResultMapper.selectExecResult(id);
return status;
}
}

View File

@ -33,4 +33,6 @@ public interface ApiDefinitionExecResultMapper {
int updateByPrimaryKeyWithBLOBs(ApiDefinitionExecResult record);
int updateByPrimaryKey(ApiDefinitionExecResult record);
String selectExecResult(String resourceId);
}

View File

@ -210,6 +210,9 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="selectExecResult" resultType="java.lang.String">
select ader.status from api_definition_exec_result ader where ader.resource_id=#{resourceId}
</select>
<update id="updateByExampleSelective" parameterType="map">
update api_definition_exec_result
<set>

View File

@ -3,17 +3,17 @@
:visible.sync="visible" class="api-import" v-loading="result.loading" @close="close">
<div class="header-bar">
<div>{{$t('api_test.api_import.data_format')}}</div>
<div>{{ $t('api_test.api_import.data_format') }}</div>
<el-radio-group v-model="selectedPlatformValue">
<el-radio v-for="(item, index) in platforms" :key="index" :label="item.value">{{item.name}}</el-radio>
<el-radio v-for="(item, index) in platforms" :key="index" :label="item.value">{{ item.name }}</el-radio>
</el-radio-group>
<div class="operate-button">
<el-button class="save-button" type="primary" plain @click="save">
{{$t('commons.save')}}
{{ $t('commons.save') }}
</el-button>
<el-button class="cancel-button" type="warning" plain @click="visible = false">
{{$t('commons.cancel')}}
{{ $t('commons.cancel') }}
</el-button>
</div>
</div>
@ -34,7 +34,7 @@
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>
<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">
@ -47,15 +47,29 @@
: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>
<span>
{{ $t('api_test.api_import.next_synchronization_time') }}
<!-- <span :class="{'disable-character': !schedule.enable}"
v-if="!schedule.enable">{{ $t('schedule.not_set') }}</span>
<crontab-result v-if="schedule.enable" :enable-simple-mode="true" :ex="schedule.value" ref="crontabResult"/>-->
</span>
</el-form-item>
<schedule-import ref="scheduleEdit"></schedule-import>
</el-form>
<div class="format-tip">
<div>
<span>{{$t('api_test.api_import.tip')}}{{selectedPlatform.tip}}</span>
<span>{{ $t('api_test.api_import.tip') }}{{ selectedPlatform.tip }}</span>
</div>
<div>
<span>{{$t('api_test.api_import.export_tip')}}{{selectedPlatform.exportTip}}</span>
<span>{{ $t('api_test.api_import.export_tip') }}{{ selectedPlatform.exportTip }}</span>
</div>
</div>
@ -63,13 +77,13 @@
</template>
<script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
export default {
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";
export default {
name: "ApiImport",
components: {MsDialogFooter},
components: {ScheduleImport, MsDialogFooter},
props: {
saved: {
type: Boolean,
@ -80,6 +94,7 @@
return {
visible: false,
swaggerUrlEable: false,
swaggerSynchronization:false,
showEnvironmentSelect: true,
platforms: [
{
@ -138,6 +153,11 @@
}
},
methods: {
scheduleEdit(){
if(this.swaggerSynchronization){
/* this.$refs.scheduleEdit.open();*/
}
},
open(module) {
this.currentModule = module;
this.visible = true;
@ -208,72 +228,72 @@
this.visible = false;
}
}
}
}
</script>
<style scoped>
.api-import >>> .el-dialog {
.api-import >>> .el-dialog {
min-width: 700px;
}
}
.format-tip {
.format-tip {
background: #EDEDED;
}
}
.api-upload {
.api-upload {
text-align: center;
margin: auto 0;
}
}
.api-upload >>> .el-upload {
.api-upload >>> .el-upload {
width: 100%;
max-width: 350px;
}
}
.api-upload >>> .el-upload-dragger {
.api-upload >>> .el-upload-dragger {
width: 100%;
}
}
.el-radio-group {
.el-radio-group {
margin: 10px 0;
}
}
.header-bar, .format-tip, .el-form {
.header-bar, .format-tip, .el-form {
border: solid #E1E1E1 1px;
margin: 10px 0;
padding: 10px;
border-radius: 3px;
}
}
.header-bar {
.header-bar {
padding: 10px 30px;
}
}
.api-import >>> .el-dialog__body {
.api-import >>> .el-dialog__body {
padding: 15px 25px;
}
}
.operate-button {
.operate-button {
float: right;
}
}
.save-button {
.save-button {
margin-left: 10px;
}
}
.el-form {
.el-form {
padding: 30px 10px;
}
}
.dialog-footer {
.dialog-footer {
float: right;
}
}
.swagger-url-disable {
.swagger-url-disable {
margin-top: 10px;
margin-left: 80px;
}
}
</style>

View File

@ -826,6 +826,9 @@ export default {
swagger_export_tip: "Export jSON-formatted files via Swagger website",
suffixFormatErr: "The file format does not meet the requirements",
swagger_url_import: "Import using URL",
timing_synchronization:"Timing synchronization",
next_synchronization_time:"Next synchronization time",
},
home_page: {
unit_of_measurement: "",

View File

@ -827,6 +827,10 @@ export default {
swagger_export_tip: "通过 Swagger 页面导出",
suffixFormatErr: "文件格式不符合要求",
swagger_url_import: "使用URL导入",
timing_synchronization:"定时同步",
next_synchronization_time:"下次同步时间"
},
home_page: {
unit_of_measurement: "个",

View File

@ -827,6 +827,9 @@ export default {
swagger_export_tip: "通過 Swagger 頁面導出",
suffixFormatErr: "文件格式不符合要求",
swagger_url_import: "使用URL導入",
timing_synchronization:"定時同步",
next_synchronization_time:"下次同步時間",
},
home_page: {
unit_of_measurement: "個",