fix(接口定义): 修复引用的场景不显示自定义id的缺陷

--bug=1019897 --user=王孝刚 [项目设置]应用管理接口测试tab开启场景ID自定义开关后新建的场景被引用后显示的ID错误
https://www.tapd.cn/55049933/s/1304381
This commit is contained in:
wxg0103 2022-11-24 14:44:29 +08:00 committed by wxg0103
parent 0373b10813
commit 77cbfadd06
3 changed files with 15 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import io.metersphere.commons.constants.PropertyConstant;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.JSONUtil;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.ProjectConfig;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService;
import org.apache.commons.collections.CollectionUtils;
@ -41,6 +42,8 @@ public class MsHashTreeService {
private ApiDefinitionMapper apiDefinitionMapper;
@Resource
private ExtApiScenarioMapper extApiScenarioMapper;
@Resource
private BaseProjectApplicationService baseProjectApplicationService;
@Resource
private ProjectMapper projectMapper;
@ -77,6 +80,8 @@ public class MsHashTreeService {
private static final String PRE = "PRE";
private static final String POST = "POST";
private static final String ASSERTIONS = ElementConstants.ASSERTIONS;
public static final String CUSTOMNUM = "customNum";
public static final String SHOWCUSTOMNUM = "showCustomNum";
public void setHashTree(JSONArray hashTree) {
// 将引用转成复制
@ -214,6 +219,10 @@ public class MsHashTreeService {
if (!element.has(VARIABLE_ENABLE)) {
element.put(VARIABLE_ENABLE, variableEnable);
}
//获取场景的当前项目是否开启了自定义id
ProjectConfig projectApplication = baseProjectApplicationService.getSpecificTypeValue(scenarioWithBLOBs.getProjectId(), "SCENARIO_CUSTOM_NUM");
element.put(SHOWCUSTOMNUM, projectApplication.getScenarioCustomNum());
element.put(CUSTOMNUM, scenarioWithBLOBs.getCustomNum());
this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable());
} else {
if (StringUtils.equalsIgnoreCase(element.optString(REFERENCED), REF)) {

View File

@ -134,6 +134,8 @@ export default {
hashTree: scenarioDefinition.hashTree,
projectId: item.projectId,
num: item.num,
customNum: item.customNum,
showCustomNum: scenarioDefinition.showCustomNum,
versionName: item.versionName,
versionEnable: item.versionEnable,
};

View File

@ -21,9 +21,12 @@
:envMap="envMap"
:title="$t('commons.scenario')">
<template v-slot:afterTitle>
<span v-if="isShowNum" @click="clickResource(scenario)">
<span v-if="isShowNum && !scenario.showCustomNum" @click="clickResource(scenario)">
{{ ' ID: ' + scenario.num + '' }}
</span>
<span v-else-if="isShowNum && scenario.showCustomNum" @click="clickResource(scenario)">
{{ ' ID: ' + scenario.customNum + '' }}
</span>
<span v-else>
<el-tooltip class="ms-num" effect="dark" :content="$t('api_test.automation.scenario.num_none')" placement="top">
<i class="el-icon-warning" />