From 22acc0a44be2086cf89af7b96b71c7ddb102375d Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 22 Aug 2022 16:40:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001016065 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015922 refactor(接口测试): 接口同步发消息功能优化 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015943 refactor(接口测试): 接口同步功能优化 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001016065 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015922 --- .../api/service/ApiCaseBatchSyncService.java | 4 +++- .../api/service/ApiDefinitionService.java | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiCaseBatchSyncService.java b/backend/src/main/java/io/metersphere/api/service/ApiCaseBatchSyncService.java index 4ed1157499..779c7b5288 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiCaseBatchSyncService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiCaseBatchSyncService.java @@ -5,10 +5,12 @@ import io.metersphere.base.domain.ApiTestCase; import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.base.mapper.ApiTestCaseMapper; +import java.util.Map; + public interface ApiCaseBatchSyncService { void oneClickSyncCase(String apiUpdateRule, ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, ApiTestCaseMapper apiTestCaseMapper, ApiTestCaseWithBLOBs testCases); - void sendApiNotice(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs); + void sendApiNotice(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, Map paramMap); void sendCaseNotice(ApiTestCase apiTestCase); } 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 04f5e0b3bf..46dc319af6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -421,10 +421,24 @@ public class ApiDefinitionService { mockConfigService.updateMockReturnMsgByApi(returnModel); FileUtils.createBodyFiles(request.getRequest().getId(), bodyFiles); + String context = SessionUtils.getUserId().concat(Translator.get("update_api")).concat(":").concat(returnModel.getName()); + Map paramMap = new HashMap<>(); + getParamMap(paramMap, returnModel.getProjectId(), SessionUtils.getUserId(), returnModel.getId(), returnModel.getName(), returnModel.getCreateUser()); + paramMap.put("userId", returnModel.getUserId()); // 发送通知 if (apiCaseSyncService != null) { - apiCaseSyncService.sendApiNotice(returnModel); + apiCaseSyncService.sendApiNotice(returnModel, paramMap); } + NoticeModel noticeModel = NoticeModel.builder() + .operator(SessionUtils.getUserId()) + .context(context) + .testId(returnModel.getId()) + .subject(Translator.get("api_update_notice")) + .paramMap(paramMap) + .excludeSelf(true) + .event(NoticeConstants.Event.UPDATE) + .build(); + noticeSendService.send(NoticeConstants.TaskType.API_DEFINITION_TASK, noticeModel); return getById(returnModel.getId()); }