fix(测试跟踪): 功能、接口用例添加依赖关系全选失效

--bug=1013801 --user=陈建星 【测试跟踪】功能用例-依赖关系-添加 部分问题处理 https://www.tapd.cn/55049933/s/1178280
This commit is contained in:
chenjianxing 2022-06-10 17:21:52 +08:00 committed by f2c-ci-robot[bot]
parent d7e5cf0495
commit a4097f9f02
11 changed files with 84 additions and 3 deletions

View File

@ -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<String> getFollows(@PathVariable String definitionId) {
return apiDefinitionService.getFollows(definitionId);

View File

@ -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<String> ids;
private ApiDefinitionRequest condition;
}

View File

@ -2172,4 +2172,21 @@ public class ApiDefinitionService {
}
}
public void saveRelationshipBatch(ApiDefinitionRelationshipEdgeRequest request) {
List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId());
request.getCondition().setNotInIds(relationshipIds);
request.getCondition().setId(null);
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiDefinitionMapper.selectIds(query));
List<String> 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);
}
}
}

View File

@ -539,6 +539,12 @@
#{id}
</foreach>
</if>
<if test="request.notInIds != null and request.notInIds.size() > 0">
and test_case.id not in
<foreach collection="request.notInIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
<if test="request.relevanceCreateTime >0">
and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >=
#{request.createTime})

View File

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

View File

@ -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<String> ids;
private QueryTestCaseRequest condition;
}

View File

@ -2741,4 +2741,20 @@ public class TestCaseService {
return testCaseNodeService.getNodeByTestCases(testCaseDTOS);
}
public void saveRelationshipBatch(TestCaseRelationshipEdgeRequest request) {
List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId());
request.getCondition().setNotInIds(relationshipIds);
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extTestCaseMapper.selectIds(query));
List<String> 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);
}
}
}

View File

@ -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');

View File

@ -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();

View File

@ -116,6 +116,7 @@ export default {
open() {
this.getProject();
this.selectCounts = null;
this.$refs.relevanceDialog.open();
},

View File

@ -193,6 +193,7 @@ export default {
},
methods: {
open() {
this.page.condition = {};
this.isSaving = false;
this.$refs.baseRelevance.open();
if (this.$refs.table) {