fix(接口测试): 修复接口定义关联数没有初始化的问题

--bug=1018095 --user=宋天阳 【接口测试】接口定义-某个接口添加前后置依赖保存后,再次编辑不显示依赖关联统计数
https://www.tapd.cn/55049933/s/1264165
This commit is contained in:
song-tianyang 2022-10-17 16:20:50 +08:00 committed by 建国
parent 631e3b3b6f
commit 4e1924760f
2 changed files with 22 additions and 13 deletions

View File

@ -16,11 +16,6 @@ import io.metersphere.api.exec.api.ApiExecuteService;
import io.metersphere.api.exec.generator.JSONSchemaGenerator; import io.metersphere.api.exec.generator.JSONSchemaGenerator;
import io.metersphere.api.exec.queue.ExecThreadPoolExecutor; import io.metersphere.api.exec.queue.ExecThreadPoolExecutor;
import io.metersphere.api.parse.api.ApiDefinitionImport; import io.metersphere.api.parse.api.ApiDefinitionImport;
import io.metersphere.dto.BaseCase;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService;
import io.metersphere.service.definition.EsbApiParamService;
import io.metersphere.service.definition.EsbImportService;
import io.metersphere.base.domain.ApiDefinition; import io.metersphere.base.domain.ApiDefinition;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.base.domain.Schedule; import io.metersphere.base.domain.Schedule;
@ -28,15 +23,19 @@ import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule; import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants; import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.JSONToDocumentUtil;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.BaseCase;
import io.metersphere.dto.MsExecResponseDTO; import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.RelationshipEdgeDTO; import io.metersphere.dto.RelationshipEdgeDTO;
import io.metersphere.environment.service.BaseEnvironmentService; import io.metersphere.environment.service.BaseEnvironmentService;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice; import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.request.ResetOrderRequest; import io.metersphere.request.ResetOrderRequest;
import io.metersphere.commons.utils.JSONToDocumentUtil; import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.EsbApiParamService;
import io.metersphere.service.definition.EsbImportService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -326,7 +325,7 @@ public class ApiDefinitionController {
return apiDefinitionService.getRelationshipApi(id, relationshipType); return apiDefinitionService.getRelationshipApi(id, relationshipType);
} }
@GetMapping("/relationship/count/{id}/") @GetMapping("/relationship/count/{id}")
public int getRelationshipApi(@PathVariable("id") String id) { public int getRelationshipApi(@PathVariable("id") String id) {
return apiDefinitionService.getRelationshipCount(id); return apiDefinitionService.getRelationshipCount(id);
} }

View File

@ -6,13 +6,15 @@
<el-collapse-transition> <el-collapse-transition>
<el-tabs v-model="activeName" style="margin: 20px"> <el-tabs v-model="activeName" style="margin: 20px">
<el-tab-pane :label="$t('commons.remark')" name="remark" class="pane"> <el-tab-pane :label="$t('commons.remark')" name="remark" class="pane">
<form-rich-text-item class="remark-item" :disabled="readOnly && !hasPermissions" :data="api" prop="remark" label-width="0"/> <form-rich-text-item class="remark-item" :disabled="readOnly && !hasPermissions" :data="api" prop="remark"
label-width="0"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('commons.relationship.name')" name="dependencies" class="pane"> <el-tab-pane :label="$t('commons.relationship.name')" name="dependencies" class="pane">
<template v-slot:label> <template v-slot:label>
<tab-pane-count :title="$t('commons.relationship.name')" :count="relationshipCount"/> <tab-pane-count :title="$t('commons.relationship.name')" :count="relationshipCount"/>
</template> </template>
<dependencies-list @setCount="setCount" :read-only="readOnly" :resource-id="api.id" resource-type="API" ref="dependencies"/> <dependencies-list @setCount="setCount" :read-only="readOnly" :resource-id="api.id" resource-type="API"
ref="dependencies"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-collapse-transition> </el-collapse-transition>
@ -29,10 +31,11 @@ import FormRichTextItem from "@/business/commons/FormRichTextItem";
import {hasPermissions} from "metersphere-frontend/src/utils/permission"; import {hasPermissions} from "metersphere-frontend/src/utils/permission";
import TabPaneCount from "@/business/commons/TabPaneCount"; import TabPaneCount from "@/business/commons/TabPaneCount";
import {getRelationshipCountApi} from "@/api/definition"; import {getRelationshipCountApi} from "@/api/definition";
export default { export default {
name: "ApiOtherInfo", name: "ApiOtherInfo",
components: {TabPaneCount, FormRichTextItem, DependenciesList, ApiInfoContainer, MsFormDivider}, components: {TabPaneCount, FormRichTextItem, DependenciesList, ApiInfoContainer, MsFormDivider},
props: ['api','readOnly'], props: ['api', 'readOnly'],
data() { data() {
return { return {
activeName: 'remark', activeName: 'remark',
@ -46,20 +49,27 @@ export default {
}, },
watch: { watch: {
activeName() { activeName() {
if (this.activeName === 'dependencies') { if (this.activeName === 'dependencies') {
this.$refs.dependencies.open(); this.$refs.dependencies.open();
} }
}, },
}, },
mounted() { mounted() {
getRelationshipCountApi(this.api.id, (data) => { this.$nextTick(() => {
this.relationshipCount = data; this.initRelationshipCount();
}); });
}, },
methods: { methods: {
setCount(count) { setCount(count) {
this.relationshipCount = count; this.relationshipCount = count;
}, },
initRelationshipCount() {
getRelationshipCountApi(this.api.id).then(rsp => {
let data = rsp.data;
this.relationshipCount = data;
});
}
} }
} }
</script> </script>