fix(接口定义): 修复修改自定义字段值不生效的缺陷

--bug=1017799 --user=王孝刚 【接口测试】接口定义-接口使用自定义模版-编辑接口的自定义字段保存后不生效
https://www.tapd.cn/55049933/s/1258698
This commit is contained in:
wxg0103 2022-10-11 18:01:25 +08:00 committed by wxg0103
parent b6a8c2aa6f
commit 191e037a17
3 changed files with 47 additions and 10 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.service.definition;
import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.CustomFieldResourceDTO;
import io.metersphere.service.CustomFieldResourceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,4 +27,32 @@ public class ApiCustomFieldService extends CustomFieldResourceService {
public Map<String, List<CustomFieldDao>> getMapByResourceIds(List<String> resourceIds) {
return super.getMapByResourceIds(TABLE_NAME, resourceIds);
}
public void addFields(String resourceId, List<CustomFieldResourceDTO> addFields) {
super.addFields(TABLE_NAME, resourceId, addFields);
}
public void editFields(String resourceId, List<CustomFieldResourceDTO> editFields) {
super.editFields(TABLE_NAME, resourceId, editFields);
}
public int updateByPrimaryKeySelective(CustomFieldResourceDTO field) {
return super.updateByPrimaryKeySelective(TABLE_NAME, field);
}
public int insert(CustomFieldResourceDTO field) {
return super.insert(TABLE_NAME, field);
}
public List<CustomFieldResourceDTO> getByResourceId(String resourceId) {
return super.getByResourceId(TABLE_NAME, resourceId);
}
public void batchUpdateByResourceIds(List<String> resourceIds, CustomFieldResourceDTO customField) {
super.batchUpdateByResourceIds(TABLE_NAME, resourceIds, customField);
}
public void batchInsertIfNotExists(List<String> ids, CustomFieldResourceDTO customField) {
super.batchInsertIfNotExists(TABLE_NAME, ids, customField);
}
}

View File

@ -763,6 +763,9 @@ public class ApiDefinitionService {
// 存储附件关系
extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name());
//保存自定义字段
customFieldApiService.editFields(test.getId(), request.getEditFields());
customFieldApiService.addFields(test.getId(), request.getAddFields());
return result;
}
@ -889,7 +892,12 @@ public class ApiDefinitionService {
}
// 存储附件关系
extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name());
//保存自定义字段
List<CustomFieldResourceDTO> addFields = request.getAddFields();
if (CollectionUtils.isNotEmpty(addFields)) {
addFields.addAll(request.getEditFields());
customFieldApiService.addFields(request.getId(), addFields);
}
return getById(test.getId());
}

View File

@ -21,7 +21,7 @@
v-if="!loading"/>
<div>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="$t('api_report.total')" name="total">
<el-tab-pane label="All" name="total">
<ms-scenario-results
:treeData="fullTreeNodes"
:report="report"
@ -32,9 +32,7 @@
</el-tab-pane>
<el-tab-pane name="fail">
<template slot="label">
<span class="fail">
{{ $t('api_report.fail') }}
</span>
Error
</template>
<ms-scenario-results
:console="content.console"
@ -46,16 +44,18 @@
</el-tab-pane>
<el-tab-pane name="errorReport" v-if="content.errorCode > 0">
<template slot="label">
<span class="fail" style="color: #F6972A">{{ $t('error_report_library.option.name') }}</span>
<span class="fail" style="color: #F6972A">
FakeError
</span>
</template>
<ms-scenario-results v-on:requestResult="requestResult" :console="content.console"
:treeData="fullTreeNodes" ref="errorReportTree"/>
</el-tab-pane>
<el-tab-pane name="unExecute" v-if="content.unExecute > 0">
<template slot="label">
<span class="fail" style="color: #9C9B9A">{{
$t('api_test.home_page.detail_card.unexecute')
}}</span>
<span class="fail" style="color: #9C9B9A">
Pending
</span>
</template>
<ms-scenario-results v-on:requestResult="requestResult"
:report="report"
@ -65,7 +65,7 @@
</el-tab-pane>
<el-tab-pane name="console">
<template slot="label">
<span class="console">{{ $t('api_test.definition.request.console') }}</span>
<span class="console">Console</span>
</template>
<pre>{{ content.console }}</pre>
</el-tab-pane>