From 6aadd379f609ecabe736a16bd0c6256d4b760e80 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 25 Jul 2022 17:16:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=B9=E9=87=8F=E5=8F=96=E6=B6=88=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --bug=1015281 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015281 --- .../api/dto/definition/ApiBatchRequest.java | 5 +++++ .../api/dto/definition/ApiTestBatchRequest.java | 4 ++++ .../metersphere/api/service/ApiDefinitionService.java | 10 +++++++++- .../io/metersphere/api/service/ApiTestCaseService.java | 7 +++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiBatchRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiBatchRequest.java index 80fd7ebdc1..3a72d28316 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiBatchRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiBatchRequest.java @@ -26,4 +26,9 @@ public class ApiBatchRequest extends ApiDefinitionWithBLOBs { */ private boolean appendTag = false; private ApiDefinitionRequest condition; + + /** + * 关注 + */ + private String follow; } 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 78f4261ffe..98b6928a8d 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 @@ -54,4 +54,8 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs { */ private boolean appendTag = false; + /** + * 关注 + */ + private String follow; } 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 6dfee2a5e1..822cbe4fdc 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1789,6 +1789,9 @@ public class ApiDefinitionService { } public void editApiByParam(ApiBatchRequest request) { + if (request == null) { + return; + } if (StringUtils.equals("tags", request.getType())) { this.batchEditDefinitionTags(request); return; @@ -1800,7 +1803,7 @@ public class ApiDefinitionService { definitionWithBLOBs.setUpdateTime(System.currentTimeMillis()); ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extApiDefinitionMapper.selectIds(query)); - if (request != null && (request.getIds() != null || !request.getIds().isEmpty())) { + if (CollectionUtils.isNotEmpty(request.getIds())) { request.getIds().forEach(apiId -> { ApiDefinitionWithBLOBs api = apiDefinitionMapper.selectByPrimaryKey(apiId); if (api == null) { @@ -1831,6 +1834,11 @@ public class ApiDefinitionService { apiDefinitionRequest.setVersionId(api.getVersionId()); checkNameExist(apiDefinitionRequest, false); }); + if (StringUtils.isNotEmpty(request.getFollow())) { + if (StringUtils.equals(request.getFollow(), "cancel")) { + this.deleteFollows(request.getIds()); + } + } } apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, getBatchExample(request)); } 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 91cd7f01fa..b0271bc000 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -793,6 +793,13 @@ public class ApiTestCaseService { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } } + if (StringUtils.isNotEmpty(request.getFollow())) { + if (StringUtils.equals(request.getFollow(), "cancel")) { + ApiTestCaseFollowExample apiTestCaseFollowExample = new ApiTestCaseFollowExample(); + apiTestCaseFollowExample.createCriteria().andCaseIdIn(ids); + apiTestCaseFollowMapper.deleteByExample(apiTestCaseFollowExample); + } + } } private void batchEditTags(ApiTestBatchRequest request, List ids) {