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 eb31b76f8e..a5386457d9 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -17,7 +17,6 @@ import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiTestEnvironmentService; import io.metersphere.api.service.EsbApiParamService; import io.metersphere.api.service.EsbImportService; -import io.metersphere.base.domain.ApiDefinitionWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; import io.metersphere.base.domain.Schedule; import io.metersphere.commons.constants.NoticeConstants; @@ -333,6 +332,11 @@ public class ApiDefinitionController { return apiDefinitionService.getRelationshipRelateList(request, goPage, pageSize); } + @PostMapping("/relationship/add") + public void saveRelationshipBatch(@RequestBody ApiDefinitionRelationshipEdgeRequest request) { + apiDefinitionService.saveRelationshipBatch(request); + } + @GetMapping("/follow/{definitionId}") public List getFollows(@PathVariable String definitionId) { return apiDefinitionService.getFollows(definitionId); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRelationshipEdgeRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRelationshipEdgeRequest.java new file mode 100644 index 0000000000..36ef336262 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRelationshipEdgeRequest.java @@ -0,0 +1,14 @@ +package io.metersphere.api.dto.definition; + +import io.metersphere.controller.request.RelationshipEdgeRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class ApiDefinitionRelationshipEdgeRequest extends RelationshipEdgeRequest { + private List ids; + private ApiDefinitionRequest condition; +} 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 2feb7a28b8..62c176e9dc 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -2321,4 +2321,21 @@ public class ApiDefinitionService { } } + public void saveRelationshipBatch(ApiDefinitionRelationshipEdgeRequest request) { + List relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); + request.getCondition().setNotInIds(relationshipIds); + request.getCondition().setId(null); + ServiceUtils.getSelectAllIds(request, request.getCondition(), + (query) -> extApiDefinitionMapper.selectIds(query)); + List ids = request.getIds(); + ids.remove(request.getId()); + if (CollectionUtils.isNotEmpty(ids)) { + if (CollectionUtils.isNotEmpty(request.getTargetIds())) { + request.setTargetIds(ids); + } else if (CollectionUtils.isNotEmpty(request.getSourceIds())) { + request.setSourceIds(ids); + } + relationshipEdgeService.saveBatch(request); + } + } } 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 1a10b49a67..ad69727010 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 @@ -581,6 +581,12 @@ #{id} + + and test_case.id not in + + #{id} + + and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >= #{request.createTime}) 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 de8380c296..29731134cd 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -122,6 +122,11 @@ public class TestCaseController { return testCaseService.getRelationshipCase(id, relationshipType); } + @PostMapping("/relationship/add") + public void saveRelationshipBatch(@RequestBody TestCaseRelationshipEdgeRequest request) { + testCaseService.saveRelationshipBatch(request); + } + @GetMapping("/relationship/case/count/{id}") public int getRelationshipCase(@PathVariable("id") String id) { return testCaseService.getRelationshipCount(id); diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseRelationshipEdgeRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseRelationshipEdgeRequest.java new file mode 100644 index 0000000000..f344405ee0 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseRelationshipEdgeRequest.java @@ -0,0 +1,14 @@ +package io.metersphere.track.request.testcase; + +import io.metersphere.controller.request.RelationshipEdgeRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class TestCaseRelationshipEdgeRequest extends RelationshipEdgeRequest { + private List ids; + private QueryTestCaseRequest condition; +} 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 211fb3e442..de0b81b80d 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -2751,4 +2751,20 @@ public class TestCaseService { return testCaseNodeService.getNodeByTestCases(testCaseDTOS); } + public void saveRelationshipBatch(TestCaseRelationshipEdgeRequest request) { + List relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); + request.getCondition().setNotInIds(relationshipIds); + ServiceUtils.getSelectAllIds(request, request.getCondition(), + (query) -> extTestCaseMapper.selectIds(query)); + List ids = request.getIds(); + ids.remove(request.getId()); + if (CollectionUtils.isNotEmpty(ids)) { + if (CollectionUtils.isNotEmpty(request.getTargetIds())) { + request.setTargetIds(ids); + } else if (CollectionUtils.isNotEmpty(request.getSourceIds())) { + request.setSourceIds(ids); + } + relationshipEdgeService.saveBatch(request); + } + } } diff --git a/frontend/src/business/components/api/definition/components/complete/ApiRelationshipRelevance.vue b/frontend/src/business/components/api/definition/components/complete/ApiRelationshipRelevance.vue index 2556d44166..9dcf1a3480 100644 --- a/frontend/src/business/components/api/definition/components/complete/ApiRelationshipRelevance.vue +++ b/frontend/src/business/components/api/definition/components/complete/ApiRelationshipRelevance.vue @@ -81,6 +81,7 @@ }, methods: { open() { + this.condition = {}; this.$refs.baseRelevance.open(); this.initTable(); if (this.$refs.nodeTree) { @@ -138,8 +139,9 @@ } param.id = this.apiDefinitionId; param.type = 'API'; + param.condition = this.condition; - this.result = this.$post('/relationship/edge/save/batch', param, () => { + this.result = this.$post('/api/definition/relationship/add', param, () => { this.$success(this.$t('commons.save_success')); this.$refs.baseRelevance.close(); this.$emit('refresh'); diff --git a/frontend/src/business/components/track/case/components/RelationshipFunctionalRelevance.vue b/frontend/src/business/components/track/case/components/RelationshipFunctionalRelevance.vue index 575cfdf40e..3a55a5cf57 100644 --- a/frontend/src/business/components/track/case/components/RelationshipFunctionalRelevance.vue +++ b/frontend/src/business/components/track/case/components/RelationshipFunctionalRelevance.vue @@ -57,8 +57,9 @@ export default { } param.id = this.caseId; param.type = 'TEST_CASE'; + param.condition = this.page.condition; - vueObj.result = this.$post('/relationship/edge/save/batch', param, () => { + vueObj.result = this.$post('/test/case/relationship/add', param, () => { vueObj.isSaving = false; this.$success(this.$t('commons.save_success')); vueObj.$refs.baseRelevance.close(); diff --git a/frontend/src/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase.vue b/frontend/src/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase.vue index 23e2753e60..81dd3b4108 100644 --- a/frontend/src/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase.vue +++ b/frontend/src/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase.vue @@ -116,6 +116,7 @@ export default { open() { this.getProject(); + this.selectCounts = null; this.$refs.relevanceDialog.open(); }, diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue index e48a59130c..634f9cde06 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue @@ -193,6 +193,7 @@ export default { }, methods: { open() { + this.page.condition = {}; this.isSaving = false; this.$refs.baseRelevance.open(); if (this.$refs.table) {