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 9504dc3b1b..e5e9570598 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -173,6 +173,7 @@ public class ApiDefinitionService { private final ThreadLocal currentApiOrder = new ThreadLocal<>(); private final ThreadLocal currentApiCaseOrder = new ThreadLocal<>(); private static final String COPY = "Copy"; + private static final String SCHEDULE = "schedule"; public List list(ApiDefinitionRequest request) { request = this.initRequest(request, true, true); @@ -1674,7 +1675,7 @@ public class ApiDefinitionService { MSException.throwException(e.getMessage()); } } - if (StringUtils.equals(request.getType(), "schedule")) { + if (StringUtils.equals(request.getType(), SCHEDULE)) { request.setProtocol("HTTP"); } try { @@ -1702,7 +1703,7 @@ public class ApiDefinitionService { request.setId(JSON.toJSONString(ids)); } // 发送通知 - if (StringUtils.equals(request.getType(), "schedule")) { + if (StringUtils.equals(request.getType(), SCHEDULE)) { String scheduleId = scheduleService.getScheduleInfo(request.getResourceId()); String context = request.getSwaggerUrl() + "导入成功"; Map paramMap = new HashMap<>(); @@ -1717,7 +1718,7 @@ public class ApiDefinitionService { .build(); noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel); } - if (CollectionUtils.isNotEmpty(apiImportSendNoticeDTOS)) { + if (!StringUtils.equals(request.getType(), SCHEDULE) && CollectionUtils.isNotEmpty(apiImportSendNoticeDTOS)) { for (ApiImportSendNoticeDTO apiImportSendNoticeDTO : apiImportSendNoticeDTOS) { if (apiImportSendNoticeDTO.getApiDefinitionResult() != null && !apiImportSendNoticeDTO.getApiDefinitionResult().isUpdated()) { sendImportApiCreateNotice(apiImportSendNoticeDTO.getApiDefinitionResult()); @@ -1729,8 +1730,7 @@ public class ApiDefinitionService { for (ApiTestCaseDTO apiTestCaseDTO : apiImportSendNoticeDTO.getCaseDTOList()) { if (apiTestCaseDTO.isUpdated()) { sendImportCaseUpdateNotice(apiTestCaseDTO); - } - if (!apiTestCaseDTO.isUpdated()) { + } else { sendImportCaseCreateNotice(apiTestCaseDTO); } } @@ -1746,7 +1746,7 @@ public class ApiDefinitionService { } private void sendFailMessage(ApiTestImportRequest request, Project project) { - if (StringUtils.equals(request.getType(), "schedule")) { + if (StringUtils.equals(request.getType(), SCHEDULE)) { String scheduleId = scheduleService.getScheduleInfo(request.getResourceId()); String context = request.getSwaggerUrl() + "导入失败"; Map paramMap = new HashMap<>();