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 022b233597..dc4a7ad959 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -163,10 +163,7 @@ public class ApiDefinitionService { @Lazy @Resource private ProjectService projectService; - @Resource - private ApiDefinitionSyncService apiDefinitionSyncService; - @Resource - private ApiCaseBatchSyncService apiCaseSyncService; + @Lazy @Resource private ApiAutomationService apiAutomationService; @@ -413,6 +410,7 @@ public class ApiDefinitionService { } // 设置是否需要进入待更新列表 + ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class); if (apiDefinitionSyncService != null) { apiDefinitionSyncService.syncApi(request); } @@ -428,6 +426,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); } @@ -1278,6 +1277,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); } }