From 92c7b2c31d75b766175829fe4d71df0cd502b726 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 20 Aug 2021 11:15:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E5=92=8C=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?case=E9=AB=98=E7=BA=A7=E6=90=9C=E7=B4=A2=E4=B8=AD=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E5=B7=B2=E8=A2=AB=E5=9C=BA=E6=99=AF=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6#1002505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1002505 --user=宋天阳 【github#5376】[FEATURE]接口定义和接口case,提供已被引用的筛选条件 https://www.tapd.cn/55049933/s/1037089 --- .../dto/definition/ApiTestBatchRequest.java | 1 + .../api/service/ApiTestCaseService.java | 15 +++++++------ .../mapper/ext/ExtApiDefinitionMapper.xml | 9 ++++++++ .../base/mapper/ext/ExtApiTestCaseMapper.xml | 10 ++++++++- .../track/service/TestPlanReportService.java | 11 ++++++++++ .../track/service/TestPlanService.java | 1 + .../components/search/search-components.js | 21 +++++++++++++++++-- 7 files changed, 59 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestBatchRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestBatchRequest.java index 5267403544..a85a6e4d95 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestBatchRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestBatchRequest.java @@ -14,6 +14,7 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs { private List ids; private List orders; private String projectId; + private Map combine; /** * isSelectAllDate:选择的数据是否是全部数据(全部数据是不受分页影响的数据) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 7d11bb75a0..728373c475 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -522,7 +522,7 @@ public class ApiTestCaseService { public void deleteBatchByParam(ApiTestBatchRequest request) { List ids = request.getIds(); if (request.isSelectAll()) { - ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), null); + ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), null,request.getCombine()); } this.deleteBatch(ids); } @@ -530,7 +530,7 @@ public class ApiTestCaseService { public void editApiBathByParam(ApiTestBatchRequest request) { List ids = request.getIds(); if (request.isSelectAll()) { - ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), null); + ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), null,request.getCombine()); } ApiTestCaseExample apiDefinitionExample = new ApiTestCaseExample(); apiDefinitionExample.createCriteria().andIdIn(ids); @@ -595,7 +595,7 @@ public class ApiTestCaseService { } } - private List getAllApiCaseIdsByFontedSelect(Map> filters, List moduleIds, String name, String projectId, String protocol, List unSelectIds, String status, String apiId) { + private List getAllApiCaseIdsByFontedSelect(Map> filters, List moduleIds, String name, String projectId, String protocol, List unSelectIds, String status, String apiId,Map combine) { ApiTestCaseRequest selectRequest = new ApiTestCaseRequest(); selectRequest.setFilters(filters); selectRequest.setModuleIds(moduleIds); @@ -605,6 +605,9 @@ public class ApiTestCaseService { selectRequest.setStatus(status); selectRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); selectRequest.setApiDefinitionId(apiId); + if(combine != null){ + selectRequest.setCombine(combine); + } List list = extApiTestCaseMapper.listSimple(selectRequest); List allIds = list.stream().map(ApiTestCaseDTO::getId).collect(Collectors.toList()); List ids = allIds.stream().filter(id -> !unSelectIds.contains(id)).collect(Collectors.toList()); @@ -856,7 +859,7 @@ public class ApiTestCaseService { public void deleteToGcByParam(ApiTestBatchRequest request) { List ids = request.getIds(); if (request.isSelectAll()) { - ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), request.getApiDefinitionId()); + ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), request.getApiDefinitionId(),request.getCombine()); } this.deleteToGc(ids); } @@ -864,7 +867,7 @@ public class ApiTestCaseService { public List reduction(ApiTestBatchRequest request) { List ids = request.getIds(); if (request.isSelectAll()) { - ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), null); + ids = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), null,request.getCombine()); } List cannotReductionAPiName = new ArrayList<>(); @@ -898,7 +901,7 @@ public class ApiTestCaseService { public DeleteCheckResult checkDeleteDatas(ApiTestBatchRequest request) { List deleteIds = request.getIds(); if (request.isSelectAll()) { - deleteIds = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), request.getApiDefinitionId()); + deleteIds = this.getAllApiCaseIdsByFontedSelect(request.getFilters(), request.getModuleIds(), request.getName(), request.getProjectId(), request.getProtocol(), request.getUnSelectIds(), request.getStatus(), request.getApiDefinitionId(),request.getCombine()); } DeleteCheckResult result = new DeleteCheckResult(); List checkMsgList = new ArrayList<>(); 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 7464a5c5f3..8b6bd29ed2 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 @@ -131,6 +131,15 @@ + + and api_definition.id + + in (SELECT reference_id FROM api_scenario_reference_id WHERE reference_id is not null ) + + + not in (SELECT reference_id FROM api_scenario_reference_id WHERE reference_id is not null ) + + and api_definition.user_id diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 73f3bc48d4..309ae222da 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -187,7 +187,15 @@ - + + and t1.id + + in (SELECT reference_id FROM api_scenario_reference_id WHERE reference_id is not null ) + + + not in (SELECT reference_id FROM api_scenario_reference_id WHERE reference_id is not null ) + + and t2.status diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 2d776f5c7d..8963c908cb 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -1237,4 +1237,15 @@ public class TestPlanReportService { return report; } + + public void deleteByPlanId(String planId) { + TestPlanReportExample example = new TestPlanReportExample(); + example.createCriteria().andTestPlanIdEqualTo(planId); + List reportList = this.testPlanReportMapper.selectByExample(example); + List testPlanReportIdList = new ArrayList<>(); + for (TestPlanReport report:reportList) { + testPlanReportIdList.add(report.getId()); + } + this.delete(testPlanReportIdList); + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index c212098b7c..3f2714fd32 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -285,6 +285,7 @@ public class TestPlanService { testPlanApiCaseService.deleteByPlanId(planId); testPlanScenarioCaseService.deleteByPlanId(planId); testPlanLoadCaseService.deleteByPlanId(planId); + testPlanReportService.deleteByPlanId(planId); //删除定时任务 scheduleService.deleteByResourceId(planId, ScheduleGroup.TEST_PLAN_TEST.name()); diff --git a/frontend/src/business/components/common/components/search/search-components.js b/frontend/src/business/components/common/components/search/search-components.js index febfee6b59..93b7d43eb3 100644 --- a/frontend/src/business/components/common/components/search/search-components.js +++ b/frontend/src/business/components/common/components/search/search-components.js @@ -290,6 +290,23 @@ export const EXECUTOR = { } } +export const ISREFERENCE = { + key: "isReference", + name: 'MsTableSearchSelect', + label: 'api_test.scenario.reference', + operator: { + options: [OPERATORS.IN] + }, + options: [ + {value: '', label: 'commons.default'}, + {value: 'true', label: 'commons.yes'}, + {value: 'false', label: 'commons.no'} + ], + props: { // 尾部控件的props,一般为element ui控件的props + multiple: false + } +} + export const TRIGGER_MODE = { key: "triggerMode", name: 'MsTableSearchSelect', @@ -473,9 +490,9 @@ export const TEST_CASE_CONFIGS = [NAME, API_TAGS, MODULE, PRIORITY, CREATE_TIME, export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE]; -export const API_DEFINITION_CONFIGS = [NAME, API_METHOD, API_PATH, API_STATUS, API_TAGS, UPDATE_TIME, CREATE_TIME, CREATOR]; +export const API_DEFINITION_CONFIGS = [NAME, API_METHOD, API_PATH, API_STATUS, API_TAGS, UPDATE_TIME, CREATE_TIME, CREATOR,ISREFERENCE]; -export const API_CASE_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, API_CASE_RESULT, UPDATE_TIME, CREATE_TIME, CREATOR]; +export const API_CASE_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, API_CASE_RESULT, UPDATE_TIME, CREATE_TIME, CREATOR,ISREFERENCE]; export const API_SCENARIO_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, API_SCENARIO_RESULT, UPDATE_TIME, CREATE_TIME, CREATOR];