From feee6e323be922aeb13e7d98d2ea0be7bc85fac0 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 14 Jan 2022 19:43:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=9B=E5=BB=BA=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=89=88=E6=9C=AC=E6=97=B6=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=E5=92=8C=E4=BE=9D=E8=B5=96=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definition/SaveApiDefinitionRequest.java | 4 ++ .../api/service/ApiDefinitionService.java | 25 +++++++++ .../metersphere/dto/RelationshipEdgeDTO.java | 1 + .../complete/ApiRelationshipList.vue | 54 ++++++++++++++----- .../complete/EditCompleteHTTPApi.vue | 40 ++++++++++++-- 5 files changed, 109 insertions(+), 15 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java index cf44e0fc1b..b54197e599 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java @@ -60,4 +60,8 @@ public class SaveApiDefinitionRequest { private String esbDataStruct; private String backEsbDataStruct; private String backScript; + + // 创建新版本时用到的 + private boolean newVersionRemark; + private boolean newVersionDeps; } 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 ff0b0781b3..fd45cc1711 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -32,6 +32,7 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.json.JSONSchemaToDocumentUtils; import io.metersphere.commons.json.JSONToDocumentUtils; import io.metersphere.commons.utils.*; +import io.metersphere.controller.request.RelationshipEdgeRequest; import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.ScheduleRequest; import io.metersphere.dto.MsExecResponseDTO; @@ -554,7 +555,30 @@ public class ApiDefinitionService { test.setCreateUser(SessionUtils.getUserId()); test.setOrder(oldApi.getOrder()); test.setRefId(oldApi.getRefId()); + // 创建新版是否关联备注 + if (!request.isNewVersionRemark()) { + test.setRemark(null); + } apiDefinitionMapper.insertSelective(test); + + // 创建新版是否关联依赖关系 + if (request.isNewVersionDeps()) { + List pre = this.getRelationshipApi(oldApi.getId(), "PRE"); + List targetIds = pre.stream().map(RelationshipEdgeKey::getTargetId).collect(Collectors.toList()); + RelationshipEdgeRequest req = new RelationshipEdgeRequest(); + req.setSourceIds(targetIds); + req.setType("API"); + req.setId(test.getId()); + relationshipEdgeService.saveBatch(req); + + List post = this.getRelationshipApi(oldApi.getId(), "POST"); + List sourceIds = post.stream().map(RelationshipEdgeKey::getSourceId).collect(Collectors.toList()); + RelationshipEdgeRequest req2 = new RelationshipEdgeRequest(); + req2.setSourceIds(sourceIds); + req2.setType("API"); + req2.setId(test.getId()); + relationshipEdgeService.saveBatch(req2); + } } // 同步修改用例路径 @@ -1719,6 +1743,7 @@ public class ApiDefinitionService { relationshipEdgeDTO.setCreator(apiDefinition.getUserId()); relationshipEdgeDTO.setTargetNum(apiDefinition.getNum()); relationshipEdgeDTO.setStatus(apiDefinition.getStatus()); + relationshipEdgeDTO.setVersionId(apiDefinition.getVersionId()); results.add(relationshipEdgeDTO); } return results; diff --git a/backend/src/main/java/io/metersphere/dto/RelationshipEdgeDTO.java b/backend/src/main/java/io/metersphere/dto/RelationshipEdgeDTO.java index 0a90fc0a05..3802ae3014 100644 --- a/backend/src/main/java/io/metersphere/dto/RelationshipEdgeDTO.java +++ b/backend/src/main/java/io/metersphere/dto/RelationshipEdgeDTO.java @@ -10,4 +10,5 @@ public class RelationshipEdgeDTO extends RelationshipEdge { private String targetCustomNum; private String status; private String creator; + private String versionId; } 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 45172eda63..d876a70127 100644 --- a/frontend/src/business/components/api/definition/components/complete/ApiRelationshipList.vue +++ b/frontend/src/business/components/api/definition/components/complete/ApiRelationshipList.vue @@ -1,6 +1,6 @@