From 9628430583a6bc58e21f97e1cdf3d65b842a83b1 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 8 May 2023 11:14:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0=E7=94=A8=E4=BE=8B=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=B0=83=E7=94=A8=E6=8F=92=E4=BB=B6=E9=A2=84?= =?UTF-8?q?=E7=95=99=E7=9A=84=E9=9C=80=E6=B1=82=E6=9B=B4=E6=96=B0=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../metersphere/service/TestCaseService.java | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf9d390a02..fd4e64ea1f 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 17 2022.0.2 2.7.22 - 1.5.0 + 1.6.0 1.11.0 1.5.3 3.1.1 diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index 8da2e9a3eb..e87bc9e3b8 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -33,6 +33,8 @@ import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.track.TestCaseReference; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.service.TestPlanTestCaseService; +import io.metersphere.platform.domain.DemandUpdateRequest; +import io.metersphere.platform.domain.TestCaseDemandDTO; import io.metersphere.request.OrderRequest; import io.metersphere.request.ProjectVersionRequest; import io.metersphere.request.ResetOrderRequest; @@ -186,6 +188,8 @@ public class TestCaseService { private ExtTestCaseCountMapper extTestCaseCountMapper; @Resource private ExtTestAnalysisMapper extTestAnalysisMapper; + @Resource + private PlatformPluginService platformPluginService; private ThreadLocal importCreateNum = new ThreadLocal<>(); @@ -237,6 +241,8 @@ public class TestCaseService { // 同步用例与需求的关联关系 addDemandHyperLink(request, "add"); + handleDemandUpdate(request, DemandUpdateRequest.OperateType.ADD, + projectMapper.selectByPrimaryKey(request.getProjectId())); testCaseMapper.insert(request); saveFollows(request.getId(), request.getFollows()); @@ -256,6 +262,37 @@ public class TestCaseService { } } + private void handleDemandUpdate(EditTestCaseRequest request, DemandUpdateRequest.OperateType type, Project project) { + handleDemandUpdate(request, type, project, null); + } + + /** + * 用例变更时,调用插件的需求变更的方法 + * @param request + * @param type + * @param project + * @param originDemandId + */ + private void handleDemandUpdate(EditTestCaseRequest request, DemandUpdateRequest.OperateType type, + Project project, String originDemandId) { + try { + if (!StringUtils.isAllBlank(request.getDemandId(), originDemandId) && PlatformPluginService.isPluginPlatform(project.getPlatform())) { + String projectConfig = PlatformPluginService.getCompatibleProjectConfig(project); + DemandUpdateRequest demandUpdateRequest = new DemandUpdateRequest(); + TestCaseDemandDTO testCaseDemandDTO = new TestCaseDemandDTO(); + BeanUtils.copyBean(testCaseDemandDTO, request); + testCaseDemandDTO.setOriginDemandId(originDemandId); + demandUpdateRequest.setTestCase(testCaseDemandDTO); + demandUpdateRequest.setProjectConfig(projectConfig); + demandUpdateRequest.setOperateType(type); + platformPluginService.getPlatform(project.getPlatform()) + .handleDemandUpdate(demandUpdateRequest); + } + } catch (Exception e) { + LogUtil.error(e); + } + } + private void doAddDemandHyperLink(EditTestCaseRequest request, String type, IssuesRequest updateRequest, Project project) { updateRequest.setWorkspaceId(project.getWorkspaceId()); List platformList = getAddPlatforms(updateRequest); @@ -389,6 +426,9 @@ public class TestCaseService { // 同步用例与需求的关联关系 addDemandHyperLink(testCase, "edit"); + + handleDemandUpdate(testCase, DemandUpdateRequest.OperateType.EDIT, + projectMapper.selectByPrimaryKey(testCase.getProjectId()), originCase.getDemandId()); } catch (Exception e) { LogUtil.error(e); } @@ -722,6 +762,9 @@ public class TestCaseService { EditTestCaseRequest request = new EditTestCaseRequest(); BeanUtils.copyBean(request, testCaseWithBLOBs); addDemandHyperLink(request, "delete"); + + handleDemandUpdate(request, DemandUpdateRequest.OperateType.DELETE, + projectMapper.selectByPrimaryKey(testCase.getProjectId())); } DeleteTestCaseRequest request = new DeleteTestCaseRequest();