From 363b668b05cdf17b6ead05f91aabfa1d3a715ce4 Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Thu, 20 Jun 2024 17:54:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=92=E6=A1=A3=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=8A=B6=E6=80=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=BB=9F=E8=AE=A1=E7=AE=97=E6=B3=95=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1042760 --user=宋天阳 【测试计划】计划组列表-删除已归档子计划-计划组状态更新为未开始 https://www.tapd.cn/55049933/s/1533068 --- .../log/constants/OperationLogModule.java | 3 +- .../mapper/ExtTestPlanCollectionMapper.xml | 8 ++++- .../TestPlanBatchOperationService.java | 2 +- .../plan/service/TestPlanLogService.java | 29 ++++++++++++------- .../plan/service/TestPlanService.java | 5 ++-- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java index c2270285d0..b3de7ecb30 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java @@ -154,7 +154,8 @@ public class OperationLogModule { public static final String BUG_MANAGEMENT_RECYCLE = "BUG_MANAGEMENT_BUG_RECYCLE"; //测试计划 public static final String TEST_PLAN = "TEST_PLAN"; - public static final String TEST_PLAN_INDEX = "TEST_PLAN_INDEX"; + public static final String TEST_PLAN_TEST_PLAN = "TEST_PLAN_PLAN"; + public static final String TEST_PLAN_TEST_PLAN_GROUP = "TEST_PLAN_GROUP"; public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE"; public static final String TEST_PLAN_REPORT = "TEST_PLAN_REPORT_TEST_PLAN"; public static final String TEST_PLAN_GROUP_REPORT = "TEST_PLAN_REPORT_TEST_PLAN_GROUP"; diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanCollectionMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanCollectionMapper.xml index ccd6b711d1..f1f499cf59 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanCollectionMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanCollectionMapper.xml @@ -53,6 +53,12 @@ and tpc.test_plan_id = #{testPlanId} \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchOperationService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchOperationService.java index 2c45d4e191..1631232b51 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchOperationService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchOperationService.java @@ -170,7 +170,7 @@ public class TestPlanBatchOperationService extends TestPlanBaseUtilsService { throw new MSException(Translator.get("test_plan.group.error")); } pos = testPlanGroupService.getNextOrder(targetId); - moduleId = group.getId(); + moduleId = group.getModuleId(); } groupId = targetId; } else { diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanLogService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanLogService.java index 7da5e7ae3d..4338951ba2 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanLogService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanLogService.java @@ -7,6 +7,7 @@ import io.metersphere.plan.mapper.TestPlanMapper; import io.metersphere.project.domain.Project; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.HttpMethodConstants; +import io.metersphere.sdk.constants.TestPlanConstants; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.LogInsertModule; @@ -30,7 +31,6 @@ import java.util.stream.Collectors; @Transactional(rollbackFor = Exception.class) public class TestPlanLogService { - private String logModule = OperationLogModule.TEST_PLAN_INDEX; @Resource private ProjectMapper projectMapper; @@ -46,7 +46,7 @@ public class TestPlanLogService { .projectId(project.getId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.UPDATE.name()) - .module(logModule) + .module(getLogModule(testPlan)) .sourceId(testPlan.getId()) .content(Translator.get("test_plan_schedule") + ":" + testPlan.getName()) .build().getLogDTO(); @@ -67,7 +67,7 @@ public class TestPlanLogService { .projectId(module.getProjectId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.ADD.name()) - .module(logModule) + .module(getLogModule(module)) .method(requestMethod) .path(requestUrl) .sourceId(module.getId()) @@ -94,7 +94,7 @@ public class TestPlanLogService { .projectId(projectId) .organizationId(project.getOrganizationId()) .type(OperationLogType.UPDATE.name()) - .module(logModule) + .module(getLogModule(newTestPlan)) .method(requestMethod) .path(requestUrl) .sourceId(newTestPlan.getId()) @@ -120,7 +120,7 @@ public class TestPlanLogService { .projectId(deleteTestPlan.getProjectId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.DELETE.name()) - .module(logModule) + .module(getLogModule(deleteTestPlan)) .method(requestMethod) .path(requestUrl) .sourceId(deleteTestPlan.getId()) @@ -145,7 +145,7 @@ public class TestPlanLogService { testPlan.getId(), null, OperationLogType.ARCHIVED.name(), - logModule, + getLogModule(testPlan), testPlan.getName()); dto.setPath("/test-plan/archived"); dto.setMethod(HttpMethodConstants.GET.name()); @@ -164,8 +164,8 @@ public class TestPlanLogService { project.getOrganizationId(), testPlan.getId(), operator, - OperationLogType.COPY.name(), - logModule, + OperationLogType.ADD.name(), + getLogModule(testPlan), testPlan.getName()); dto.setPath("/test-plan/copy"); dto.setMethod(HttpMethodConstants.POST.name()); @@ -192,7 +192,7 @@ public class TestPlanLogService { .projectId(plan.getProjectId()) .organizationId(project.getOrganizationId()) .type(requestType) - .module(logModule) + .module(getLogModule(plan)) .method(requestMethod) .path(requestUrl) .sourceId(plan.getId()) @@ -228,7 +228,7 @@ public class TestPlanLogService { testPlan.getId(), null, OperationLogType.UPDATE.name(), - logModule, + getLogModule(testPlan), testPlan.getName()); dto.setPath("/test-plan/batch-edit"); dto.setMethod(HttpMethodConstants.POST.name()); @@ -246,7 +246,7 @@ public class TestPlanLogService { .projectId(testPlan.getProjectId()) .organizationId(project.getOrganizationId()) .type(OperationLogType.UPDATE.name()) - .module(logModule) + .module(getLogModule(testPlan)) .method(logInsertModule.getRequestMethod()) .path(logInsertModule.getRequestUrl()) .sourceId(moveId) @@ -256,4 +256,11 @@ public class TestPlanLogService { operationLogService.add(dto); } + private String getLogModule(TestPlan testPlan) { + if (StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_TYPE_PLAN)) { + return OperationLogModule.TEST_PLAN_TEST_PLAN; + } else { + return OperationLogModule.TEST_PLAN_TEST_PLAN_GROUP; + } + } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java index a69e5df1fd..b8eabaab28 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -840,10 +840,11 @@ public class TestPlanService extends TestPlanBaseUtilsService { groupStatus = TestPlanConstants.TEST_PLAN_STATUS_UNDERWAY; } } + TestPlanExample testPlanExample = new TestPlanExample(); + testPlanExample.createCriteria().andIdEqualTo(testPlanGroupId).andStatusNotEqualTo(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED); TestPlan updateGroupPlan = new TestPlan(); - updateGroupPlan.setId(testPlanGroupId); updateGroupPlan.setStatus(groupStatus); - testPlanMapper.updateByPrimaryKeySelective(updateGroupPlan); + testPlanMapper.updateByExampleSelective(updateGroupPlan, testPlanExample); if (StringUtils.equalsIgnoreCase(updateGroupPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_COMPLETED)) { extTestPlanMapper.setActualEndTime(testPlanGroupId, System.currentTimeMillis()); }