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.CustomFieldDao;
import io.metersphere.dto.CustomFieldResourceDTO;
import io.metersphere.service.CustomFieldResourceService; import io.metersphere.service.CustomFieldResourceService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -26,4 +27,32 @@ public class ApiCustomFieldService extends CustomFieldResourceService {
public Map<String, List<CustomFieldDao>> getMapByResourceIds(List<String> resourceIds) { public Map<String, List<CustomFieldDao>> getMapByResourceIds(List<String> resourceIds) {
return super.getMapByResourceIds(TABLE_NAME, 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()); extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name());
//保存自定义字段
customFieldApiService.editFields(test.getId(), request.getEditFields());
customFieldApiService.addFields(test.getId(), request.getAddFields());
return result; return result;
} }
@ -889,7 +892,12 @@ public class ApiDefinitionService {
} }
// 存储附件关系 // 存储附件关系
extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name()); 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()); return getById(test.getId());
} }

View File

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