From 35adc6a4803ddeb802a4445265b57afecd8bd8d0 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Thu, 25 Aug 2022 16:22:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20xp?= =?UTF-8?q?ack=E4=BB=A3=E7=A0=81=E5=BC=95=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiDefinitionService.java | 8 +++---- .../api/service/ApiTestCaseService.java | 23 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) 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 0b56483a56..a81319b51c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -161,10 +161,7 @@ public class ApiDefinitionService { @Lazy @Resource private ProjectService projectService; - @Resource - private ApiDefinitionSyncService apiDefinitionSyncService; - @Resource - private ApiCaseBatchSyncService apiCaseSyncService; + @Lazy @Resource private ApiAutomationService apiAutomationService; @@ -411,6 +408,7 @@ public class ApiDefinitionService { } // 设置是否需要进入待更新列表 + ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class); if (apiDefinitionSyncService != null) { apiDefinitionSyncService.syncApi(request); } @@ -426,6 +424,7 @@ public class ApiDefinitionService { getParamMap(paramMap, returnModel.getProjectId(), SessionUtils.getUserId(), returnModel.getId(), returnModel.getName(), returnModel.getCreateUser()); paramMap.put("userId", returnModel.getUserId()); // 发送通知 + ApiCaseBatchSyncService apiCaseSyncService = CommonBeanFactory.getBean(ApiCaseBatchSyncService.class); if (apiCaseSyncService != null) { apiCaseSyncService.sendApiNotice(returnModel, paramMap); } @@ -1276,6 +1275,7 @@ public class ApiDefinitionService { } ApiSyncCaseRequest apiSyncCaseRequest = new ApiSyncCaseRequest(); Boolean toUpdate = false; + ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class); if (apiDefinitionSyncService != null) { toUpdate = apiDefinitionSyncService.getProjectApplications(existApi.getProjectId()); apiSyncCaseRequest = apiDefinitionSyncService.getApiSyncCaseRequest(existApi.getProjectId()); 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 15f6549564..c039cb4709 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -122,10 +122,6 @@ public class ApiTestCaseService { @Resource private FileAssociationService fileAssociationService; @Resource - private ApiCaseBatchSyncService apiCaseSyncService; - @Resource - private ApiTestCaseSyncService apiTestCaseSyncService; - @Resource private ApiScenarioReferenceIdMapper apiScenarioReferenceIdMapper; @@ -336,6 +332,7 @@ public class ApiTestCaseService { FileUtils.createBodyFiles(request.getId(), bodyFiles); } // 发送通知 + ApiCaseBatchSyncService apiCaseSyncService = CommonBeanFactory.getBean(ApiCaseBatchSyncService.class); if (apiCaseSyncService != null) { apiCaseSyncService.sendCaseNotice(test); } @@ -462,7 +459,11 @@ public class ApiTestCaseService { } else { test.setTags(request.getTags()); } - apiTestCaseSyncService.setCaseUpdateValue(test); + ApiTestCaseSyncService apiTestCaseSyncService = CommonBeanFactory.getBean(ApiTestCaseSyncService.class); + if(apiTestCaseSyncService!=null){ + apiTestCaseSyncService.setCaseUpdateValue(test); + } + apiTestCaseMapper.updateByPrimaryKeySelective(test); saveFollows(test.getId(), request.getFollows()); } @@ -891,6 +892,7 @@ public class ApiTestCaseService { String requestStr = JSON.toJSONString(req); apiTestCase.setRequest(requestStr); // sync case + ApiCaseBatchSyncService apiCaseSyncService = CommonBeanFactory.getBean(ApiCaseBatchSyncService.class); if (apiCaseSyncService != null) { apiCaseSyncService.oneClickSyncCase(apiUpdateRule, test, batchMapper, apiTestCase); } @@ -1303,11 +1305,14 @@ public class ApiTestCaseService { if (request.isNoSearchStatus()) { request.setStatusList(new ArrayList<>()); } else { - List syncRuleCaseStatus = apiTestCaseSyncService.getSyncRuleCaseStatus(request.getProjectId()); - if (CollectionUtils.isEmpty(syncRuleCaseStatus)) { - syncRuleCaseStatus = new ArrayList<>(); + ApiTestCaseSyncService apiTestCaseSyncService = CommonBeanFactory.getBean(ApiTestCaseSyncService.class); + if (apiTestCaseSyncService !=null) { + List syncRuleCaseStatus = apiTestCaseSyncService.getSyncRuleCaseStatus(request.getProjectId()); + if (CollectionUtils.isEmpty(syncRuleCaseStatus)) { + syncRuleCaseStatus = new ArrayList<>(); + } + request.setStatusList(syncRuleCaseStatus); } - request.setStatusList(syncRuleCaseStatus); } }