From 411ac0d079a5c0735a639661901803ca91bad6c7 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 21 Oct 2021 21:02:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=85=B3=E7=B3=BB=E5=9B=BE?= =?UTF-8?q?=E8=8B=A5=E5=B9=B2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/Application.java | 1 - .../controller/ApiDefinitionController.java | 5 ++ .../api/service/ApiDefinitionService.java | 25 +++++++- .../mapper/ext/ExtApiDefinitionMapper.java | 2 + .../mapper/ext/ExtApiDefinitionMapper.xml | 8 +++ .../base/mapper/ext/ExtTestCaseMapper.java | 2 + .../base/mapper/ext/ExtTestCaseMapper.xml | 9 +++ .../service/CustomFieldService.java | 12 ++++ .../service/RelationshipEdgeService.java | 64 ++++++++++++------- .../track/controller/TestCaseController.java | 5 ++ .../track/issue/AbstractIssuePlatform.java | 15 +---- .../metersphere/track/issue/JiraPlatform.java | 5 +- .../metersphere/track/issue/TapdPlatform.java | 1 - .../track/service/TestCaseService.java | 26 +++++++- backend/src/main/java/io/metersphere/xpack | 2 +- .../components/complete/ApiOtherInfo.vue | 24 +++++-- .../complete/ApiRelationshipList.vue | 17 ++++- .../components/graph/DependenciesList.vue | 43 ++++++++++--- .../components/graph/RelationshipList.vue | 5 ++ .../track/case/components/TestCaseEdit.vue | 2 + .../case/components/TestCaseEditOtherInfo.vue | 17 ++++- .../components/TestCaseRelationshipList.vue | 19 ++++++ .../report/detail/component/TabPaneCount.vue | 14 +++- frontend/src/business/components/xpack | 2 +- frontend/src/i18n/en-US.js | 7 +- frontend/src/i18n/zh-CN.js | 8 ++- frontend/src/i18n/zh-TW.js | 8 ++- frontend/src/network/api.js | 4 ++ frontend/src/network/testCase.js | 4 ++ frontend/src/store/index.js | 3 +- frontend/src/store/mutations.js | 3 + 31 files changed, 291 insertions(+), 71 deletions(-) diff --git a/backend/src/main/java/io/metersphere/Application.java b/backend/src/main/java/io/metersphere/Application.java index 202977b8ff..60c4737f32 100644 --- a/backend/src/main/java/io/metersphere/Application.java +++ b/backend/src/main/java/io/metersphere/Application.java @@ -23,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; JmeterProperties.class }) @EnableScheduling -//@PropertySource(value = {"file:c:\\opt\\metersphere\\conf\\metersphere.properties"}, encoding = "UTF-8", ignoreResourceNotFound = true) @PropertySource(value = {"file:/opt/metersphere/conf/metersphere.properties"}, encoding = "UTF-8", ignoreResourceNotFound = true) public class Application { public static void main(String[] args) { diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index b3505459b0..f9c31b51c8 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -315,6 +315,11 @@ public class ApiDefinitionController { return apiDefinitionService.getRelationshipApi(id, relationshipType); } + @GetMapping("/relationship/count/{id}/") + public int getRelationshipApi(@PathVariable("id") String id) { + return apiDefinitionService.getRelationshipCount(id); + } + @PostMapping("/relationship/relate/{goPage}/{pageSize}") public Pager< List> getRelationshipRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index f1c8af9210..965f165359 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1607,16 +1607,21 @@ public class ApiDefinitionService { return extApiDefinitionMapper.countQuotedApiByProjectId(projectId); } + public int getRelationshipCount(String id) { + return relationshipEdgeService.getRelationshipCount(id, extApiDefinitionMapper::countByIds); + } + public List getRelationshipApi(String id, String relationshipType) { List relationshipEdges = relationshipEdgeService.getRelationshipEdgeByType(id, relationshipType); List ids = relationshipEdgeService.getRelationIdsByType(relationshipType, relationshipEdges); if (CollectionUtils.isNotEmpty(ids)) { ApiDefinitionExample example = new ApiDefinitionExample(); - example.createCriteria().andIdIn(ids); + example.createCriteria().andIdIn(ids).andStatusNotEqualTo("Trash"); List apiDefinitions = apiDefinitionMapper.selectByExample(example); Map apiMap = apiDefinitions.stream().collect(Collectors.toMap(ApiDefinition::getId, i -> i)); List results = new ArrayList<>(); + buildUserInfo(apiDefinitions); for (RelationshipEdge relationshipEdge : relationshipEdges) { RelationshipEdgeDTO relationshipEdgeDTO = new RelationshipEdgeDTO(); BeanUtils.copyBean(relationshipEdgeDTO, relationshipEdge); @@ -1627,8 +1632,9 @@ public class ApiDefinitionService { apiDefinition = apiMap.get(relationshipEdge.getSourceId()); } relationshipEdgeDTO.setTargetName(apiDefinition.getName()); - relationshipEdgeDTO.setCreator(apiDefinition.getCreateUser()); + relationshipEdgeDTO.setCreator(apiDefinition.getUserId()); relationshipEdgeDTO.setTargetNum(apiDefinition.getNum()); + relationshipEdgeDTO.setStatus(apiDefinition.getStatus()); results.add(relationshipEdgeDTO); } return results; @@ -1636,6 +1642,21 @@ public class ApiDefinitionService { return new ArrayList<>(); } + public void buildUserInfo(List apis) { + List userIds = new ArrayList(); + userIds.addAll(apis.stream().map(ApiDefinition::getCreateUser).collect(Collectors.toList())); + userIds.addAll(apis.stream().map(ApiDefinition::getDeleteUserId).collect(Collectors.toList())); + userIds.addAll(apis.stream().map(ApiDefinition::getUserId).collect(Collectors.toList())); + if (!org.apache.commons.collections.CollectionUtils.isEmpty(userIds)) { + Map userMap = ServiceUtils.getUserNameMap(userIds); + apis.forEach(caseResult -> { + caseResult.setCreateUser(userMap.get(caseResult.getCreateUser())); + caseResult.setDeleteUserId(userMap.get(caseResult.getDeleteUserId())); + caseResult.setUserId(userMap.get(caseResult.getUserId())); + }); + } + } + public List getRelationshipRelateList(ApiDefinitionRequest request) { request = this.initRequest(request, true, true); List relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index bf0c043691..1500c4f3cf 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -76,4 +76,6 @@ public interface ExtApiDefinitionMapper { long countQuotedApiByProjectId(String projectId); List getForGraph(@Param("ids") Set ids); + + int countByIds(@Param("ids") List ids); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 12ac75ac59..07934d9b91 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -720,5 +720,13 @@ where t3.api_definition_id = #{apiDefinitionId} and t3.`status`!='Trash' + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index 358d57ab0f..2a108fa2ba 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -123,4 +123,6 @@ public interface ExtTestCaseMapper { List getTestCase(@Param("request") QueryTestCaseRequest request); List getTestCaseForGraph(@Param("ids") Set ids); + + int countByIds(@Param("ids") List ids); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 9cbfe8533b..9613bc0556 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -574,6 +574,15 @@ and (test_case.status != 'Trash' or test_case.status is NULL); + update test_case set original_status=status, diff --git a/backend/src/main/java/io/metersphere/service/CustomFieldService.java b/backend/src/main/java/io/metersphere/service/CustomFieldService.java index 3e344dcd72..d0b38f468a 100644 --- a/backend/src/main/java/io/metersphere/service/CustomFieldService.java +++ b/backend/src/main/java/io/metersphere/service/CustomFieldService.java @@ -1,6 +1,8 @@ package io.metersphere.service; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.CustomField; @@ -13,6 +15,7 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; import io.metersphere.controller.request.QueryCustomFieldRequest; import io.metersphere.dto.CustomFieldDao; +import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.i18n.Translator; import io.metersphere.log.utils.ReflexObjectUtil; import io.metersphere.log.vo.DetailColumn; @@ -205,4 +208,13 @@ public class CustomFieldService { } return null; } + + public static List getCustomFields(String customFieldsStr) { + if (StringUtils.isNotBlank(customFieldsStr)) { + if (JSONObject.parse(customFieldsStr) instanceof JSONArray) { + return JSONArray.parseArray(customFieldsStr, CustomFieldItemDTO.class); + } + } + return new ArrayList<>(); + } } diff --git a/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java b/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java index 291e47fbfd..f76c94cc30 100644 --- a/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java +++ b/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java @@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -97,6 +98,17 @@ public class RelationshipEdgeService { return relationshipEdgeMapper.selectByExample(example); } + public List getBySourceIdOrTargetId(String id) { + RelationshipEdgeExample example = new RelationshipEdgeExample(); + example.createCriteria() + .andSourceIdEqualTo(id); + example.or( + example.createCriteria() + .andTargetIdEqualTo(id) + ); + return relationshipEdgeMapper.selectByExample(example); + } + /** * 保存新的边 * 校验是否存在环 @@ -128,11 +140,16 @@ public class RelationshipEdgeService { }); } - // 判断是否有环, 两个方向都搜索一遍 - if (directedCycle(request.getId(), relationshipEdges, new HashSet<>(), true) || - directedCycle(request.getId(), relationshipEdges, new HashSet<>(), false)) { - MSException.throwException("关联后存在循环依赖,请检查依赖关系"); - }; + HashSet nodeIds = new HashSet<>(); + nodeIds.addAll(relationshipEdges.stream().map(RelationshipEdge::getSourceId).collect(Collectors.toSet())); + nodeIds.addAll(relationshipEdges.stream().map(RelationshipEdge::getTargetId).collect(Collectors.toSet())); + // 判断是否有环 + HashSet visitedSet = new HashSet<>(); + nodeIds.forEach(nodeId -> { + if (!visitedSet.contains(nodeId) && directedCycle(nodeId, relationshipEdges, new HashSet<>(), visitedSet)) { + MSException.throwException("关联后存在循环依赖,请检查依赖关系"); + }; + }); relationshipEdges.forEach(item -> { if (addEdgesIds.contains(item.getSourceId() + item.getTargetId())) { @@ -186,11 +203,11 @@ public class RelationshipEdgeService { * 给定一点,深度搜索该连通图中是否存在环 * @param id * @param edges - * @param markSet - * @param isForwardDirection + * @param markSet 标记该路径上经过的节点 + * @param visitedSet 标记访问过的节点 * @return */ - public boolean directedCycle(String id, List edges, Set markSet, Boolean isForwardDirection) { + public boolean directedCycle(String id, List edges, Set markSet, Set visitedSet) { if (markSet.contains(id)) { // 如果已经访问过该节点,则说明存在环 @@ -198,23 +215,19 @@ public class RelationshipEdgeService { } markSet.add(id); + visitedSet.add(id); + ArrayList nextLevelNodes = new ArrayList(); for (RelationshipEdge relationshipEdge : edges) { - if (isForwardDirection) {// 正向则搜索 sourceId 是当前节点的边 - if (id.equals(relationshipEdge.getSourceId())) { - nextLevelNodes.add(relationshipEdge.getTargetId()); - } - } else { - if (id.equals(relationshipEdge.getTargetId())) { - nextLevelNodes.add(relationshipEdge.getSourceId()); - } + if (id.equals(relationshipEdge.getSourceId())) { + nextLevelNodes.add(relationshipEdge.getTargetId()); } } for (String nextNode : nextLevelNodes) { - if (directedCycle(nextNode, edges, markSet, isForwardDirection)) { + if (directedCycle(nextNode, edges, markSet, visitedSet)) { return true; - }; + } } // 关键,递归完这一条路径要把这个标记去掉,否则会误判为有环 @@ -225,17 +238,24 @@ public class RelationshipEdgeService { } /** - * 给定一个节点获取跟他关联的所有节点的id + * 给定一个节点获取直接关联的节点的id * @param nodeId * @return */ public List getRelationshipIds(String nodeId) { - List sourceRelationshipEdges = getBySourceId(nodeId); - List targetRelationshipEdges = getByTargetId(nodeId); + List sourceRelationshipEdges = getBySourceIdOrTargetId(nodeId); List ids = sourceRelationshipEdges.stream().map(RelationshipEdge::getTargetId).collect(Collectors.toList()); - ids.addAll(targetRelationshipEdges.stream().map(RelationshipEdge::getSourceId).collect(Collectors.toList())); + ids.addAll(sourceRelationshipEdges.stream().map(RelationshipEdge::getSourceId).collect(Collectors.toList())); ids.add(nodeId); return ids; } + public int getRelationshipCount(String id, Function, Integer> countByIdsFunc) { + List ids = getRelationshipIds(id); + ids = ids.stream().filter(i -> !i.equals(id)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ids)) { + return countByIdsFunc.apply(ids); + } + return 0; + } } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index 7097efb69a..0ce1b97481 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -105,6 +105,11 @@ public class TestCaseController { return testCaseService.getRelationshipCase(id, relationshipType); } + @GetMapping("/relationship/case/count/{id}") + public int getRelationshipCase(@PathVariable("id") String id) { + return testCaseService.getRelationshipCount(id); + } + @GetMapping("recent/{count}") public List recentTestPlans(@PathVariable int count) { String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java index 9eced3396a..b70db57935 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -1,6 +1,5 @@ package io.metersphere.track.issue; -import com.alibaba.fastjson.JSONArray; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.ProjectMapper; @@ -11,10 +10,7 @@ import io.metersphere.commons.utils.*; import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.UserDTO; -import io.metersphere.service.IntegrationService; -import io.metersphere.service.ProjectService; -import io.metersphere.service.ResourceService; -import io.metersphere.service.UserService; +import io.metersphere.service.*; import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest; import io.metersphere.track.service.TestCaseIssueService; @@ -218,13 +214,6 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { } } - protected List getCustomFields(String customFieldsStr) { - if (StringUtils.isNotBlank(customFieldsStr)) { - return JSONArray.parseArray(customFieldsStr, CustomFieldItemDTO.class); - } - return new ArrayList<>(); - } - /** * 将html格式的缺陷描述转成ms平台的格式 * @@ -347,7 +336,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { } protected void addCustomFields(IssuesUpdateRequest issuesRequest, MultiValueMap paramMap) { - List customFields = getCustomFields(issuesRequest.getCustomFields()); + List customFields = CustomFieldService.getCustomFields(issuesRequest.getCustomFields()); customFields.forEach(item -> { if (StringUtils.isNotBlank(item.getCustomData())) { paramMap.add(item.getCustomData(), item.getValue()); diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index f204b19ae6..37fb421def 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -11,6 +11,7 @@ import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.UserDTO; +import io.metersphere.service.CustomFieldService; import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.issue.client.JiraClientV2; import io.metersphere.track.issue.domain.Jira.JiraAddIssueResponse; @@ -109,7 +110,7 @@ public class JiraPlatform extends AbstractIssuePlatform { } public String parseIssueCustomField(String customFieldsStr, JiraIssue jiraIssue) { - List customFields = getCustomFields(customFieldsStr); + List customFields = CustomFieldService.getCustomFields(customFieldsStr); JSONObject fields = jiraIssue.getFields(); customFields.forEach(item -> { @@ -286,7 +287,7 @@ public class JiraPlatform extends AbstractIssuePlatform { JSONObject addJiraIssueParam = new JSONObject(); addJiraIssueParam.put("fields", fields); - List customFields = getCustomFields(issuesRequest.getCustomFields()); + List customFields = CustomFieldService.getCustomFields(issuesRequest.getCustomFields()); jiraClientV2.setConfig(config); customFields.forEach(item -> { diff --git a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java index 469b0f5164..60f94f70bd 100644 --- a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java @@ -15,7 +15,6 @@ import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.ResultHolder; -import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.UserDTO; import io.metersphere.service.SystemParameterService; import io.metersphere.track.dto.DemandDTO; diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 248bd362b7..d1006da5a8 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -10,6 +10,7 @@ import io.metersphere.api.dto.automation.ApiScenarioDTO; import io.metersphere.api.dto.automation.ApiScenarioRequest; import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseRequest; +import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.api.service.ApiTestCaseService; import io.metersphere.base.domain.*; @@ -1973,8 +1974,9 @@ public class TestCaseService { if (CollectionUtils.isNotEmpty(ids)) { TestCaseExample example = new TestCaseExample(); - example.createCriteria().andIdIn(ids); - List testCaseList = testCaseMapper.selectByExample(example); + example.createCriteria().andIdIn(ids).andStatusNotEqualTo("Trash"); + List testCaseList = testCaseMapper.selectByExampleWithBLOBs(example); + buildUserInfo(testCaseList); Map caseMap = testCaseList.stream().collect(Collectors.toMap(TestCase::getId, i -> i)); List results = new ArrayList<>(); for (RelationshipEdge relationshipEdge : relationshipEdges) { @@ -1990,10 +1992,30 @@ public class TestCaseService { relationshipEdgeDTO.setCreator(testCase.getCreateUser()); relationshipEdgeDTO.setTargetNum(testCase.getNum()); relationshipEdgeDTO.setTargetCustomNum(testCase.getCustomNum()); + relationshipEdgeDTO.setStatus(testCase.getStatus()); results.add(relationshipEdgeDTO); } return results; } return new ArrayList<>(); } + + public void buildUserInfo(List testCases) { + List userIds = new ArrayList(); + userIds.addAll(testCases.stream().map(TestCase::getCreateUser).collect(Collectors.toList())); + userIds.addAll(testCases.stream().map(TestCase::getDeleteUserId).collect(Collectors.toList())); + userIds.addAll(testCases.stream().map(TestCase::getMaintainer).collect(Collectors.toList())); + if (!org.apache.commons.collections.CollectionUtils.isEmpty(userIds)) { + Map userMap = ServiceUtils.getUserNameMap(userIds); + testCases.forEach(caseResult -> { + caseResult.setCreateUser(userMap.get(caseResult.getCreateUser())); + caseResult.setDeleteUserId(userMap.get(caseResult.getDeleteUserId())); + caseResult.setMaintainer(userMap.get(caseResult.getMaintainer())); + }); + } + } + + public int getRelationshipCount(String id) { + return relationshipEdgeService.getRelationshipCount(id, extTestCaseMapper::countByIds); + } } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 6aff490dd3..a86e39275a 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 6aff490dd3321a760e2a519c0cb6aa6c90850f3f +Subproject commit a86e39275aae2a3e2e8aae705da5a4dddbd0089d diff --git a/frontend/src/business/components/api/definition/components/complete/ApiOtherInfo.vue b/frontend/src/business/components/api/definition/components/complete/ApiOtherInfo.vue index 731d9851ef..886f2d0e99 100644 --- a/frontend/src/business/components/api/definition/components/complete/ApiOtherInfo.vue +++ b/frontend/src/business/components/api/definition/components/complete/ApiOtherInfo.vue @@ -9,7 +9,10 @@ - + + @@ -24,13 +27,16 @@ import ApiInfoContainer from "@/business/components/api/definition/components/co import DependenciesList from "@/business/components/common/components/graph/DependenciesList"; import FormRichTextItem from "@/business/components/track/case/components/FormRichTextItem"; import {hasPermissions} from "@/common/js/utils"; +import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount"; +import {getRelationshipCountApi} from "@/network/api"; export default { name: "ApiOtherInfo", - components: {FormRichTextItem, DependenciesList, ApiInfoContainer, MsFormDivider}, + components: {TabPaneCount, FormRichTextItem, DependenciesList, ApiInfoContainer, MsFormDivider}, props: ['api','readOnly'], data() { return { - activeName: 'remark' + activeName: 'remark', + relationshipCount: 0 } }, computed: { @@ -43,8 +49,18 @@ export default { if (this.activeName === 'dependencies') { this.$refs.dependencies.open(); } - } + }, }, + mounted() { + getRelationshipCountApi(this.api.id, (data) => { + this.relationshipCount = data; + }); + }, + methods: { + setCount(count) { + this.relationshipCount = count; + }, + } } diff --git a/frontend/src/business/components/api/definition/components/complete/ApiRelationshipList.vue b/frontend/src/business/components/api/definition/components/complete/ApiRelationshipList.vue index 37658023ee..45172eda63 100644 --- a/frontend/src/business/components/api/definition/components/complete/ApiRelationshipList.vue +++ b/frontend/src/business/components/api/definition/components/complete/ApiRelationshipList.vue @@ -26,6 +26,17 @@ min-width="120"> + + + + { this.data = data; + this.$emit('setCount', data.length); }); }, openRelevance() { diff --git a/frontend/src/business/components/common/components/graph/DependenciesList.vue b/frontend/src/business/components/common/components/graph/DependenciesList.vue index a5a969cc0b..4fb14f30a2 100644 --- a/frontend/src/business/components/common/components/graph/DependenciesList.vue +++ b/frontend/src/business/components/common/components/graph/DependenciesList.vue @@ -1,11 +1,23 @@