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 @@