From 3d85e8a48c7bfa596677ce2b634d4748c653a966 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 20 Sep 2024 18:55:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E6=A0=87=E7=AD=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/FunctionalCaseBatchEditRequest.java | 3 +++ .../functional/service/FunctionalCaseService.java | 10 +++++++++- .../controller/FunctionalCaseControllerTests.java | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseBatchEditRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseBatchEditRequest.java index cac7d02c33..c351188596 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseBatchEditRequest.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalCaseBatchEditRequest.java @@ -22,6 +22,9 @@ public class FunctionalCaseBatchEditRequest extends BaseFunctionalCaseBatchDTO { @Schema(description = "是否追加") private boolean append; + @Schema(description = "是否清空") + private boolean clear; + @Schema(description = "标签") private List tags; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index 3f74c9914f..6eb685c81e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -1026,7 +1026,15 @@ public class FunctionalCaseService { }); sqlSession.flushStatements(); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); - } else { + } else if (request.isClear()) { + //清空标签 + FunctionalCase functionalCase = new FunctionalCase(); + functionalCase.setTags(new ArrayList<>()); + functionalCase.setProjectId(request.getProjectId()); + functionalCase.setUpdateTime(System.currentTimeMillis()); + functionalCase.setUpdateUser(userId); + extFunctionalCaseMapper.batchUpdate(functionalCase, ids); + }else { //替换标签 FunctionalCase functionalCase = new FunctionalCase(); functionalCase.setTags(request.getTags()); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java index edd59e86bc..37466a91ee 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java @@ -663,16 +663,19 @@ public class FunctionalCaseControllerTests extends BaseTest { FunctionalCaseBatchEditRequest request = new FunctionalCaseBatchEditRequest(); request.setProjectId(DEFAULT_PROJECT_ID); request.setAppend(false); + request.setClear(false); request.setSelectAll(false); this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request); request.setSelectIds(Arrays.asList("TEST_FUNCTIONAL_CASE_ID_1", "TEST_FUNCTIONAL_CASE_ID_2")); this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request); request.setAppend(true); + request.setClear(false); request.setTags(Arrays.asList("追加标签_1", "追加标签_2")); this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request); request.setTags(Arrays.asList("追加标签_1", "追加标签_2", "追加标签_3", "追加标签_4", "追加标签_5", "追加标签_6", "追加标签_7", "追加标签_8", "追加标签_9", "追加标签_10", "追加标签_11")); this.requestPost(FUNCTIONAL_CASE_BATCH_EDIT_URL, request); request.setAppend(false); + request.setClear(false); request.setTags(Arrays.asList("覆盖标签1", "覆盖标签2")); request.setSelectAll(true); CaseCustomFieldDTO caseCustomFieldDTO = new CaseCustomFieldDTO(); @@ -680,6 +683,14 @@ public class FunctionalCaseControllerTests extends BaseTest { caseCustomFieldDTO.setValue("批量编辑自定义字段"); request.setCustomField(caseCustomFieldDTO); this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request); + FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey("TEST_FUNCTIONAL_CASE_ID_1"); + Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCase.getTags())); + request.setAppend(false); + request.setClear(true); + request.setSelectAll(true); + this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request); + functionalCase = functionalCaseMapper.selectByPrimaryKey("TEST_FUNCTIONAL_CASE_ID_1"); + Assertions.assertTrue(CollectionUtils.isEmpty(functionalCase.getTags())); }