From 11f5a5a21152209c7f79e2d2ccd0b0f393d3a265 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 17 Mar 2023 18:51:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6=E5=90=8C=E6=AD=A5=E6=A8=A1?= =?UTF-8?q?=E7=89=88=E5=8F=82=E6=95=B0=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84?= =?UTF-8?q?=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/metersphere/metersphere/issues/22847 --- .../ApiDefinitionImportUtilService.java | 15 +++++++++++++-- .../frontend/src/components/MxNoticeTemplate.vue | 7 ++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java index fd8c36105d..cfa973d8e8 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java @@ -8,7 +8,10 @@ import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler; import io.metersphere.api.dto.mock.config.MockConfigImportDTO; import io.metersphere.api.parse.api.ApiDefinitionImport; import io.metersphere.base.domain.*; -import io.metersphere.base.mapper.*; +import io.metersphere.base.mapper.ApiDefinitionMapper; +import io.metersphere.base.mapper.ApiModuleMapper; +import io.metersphere.base.mapper.ApiTestCaseMapper; +import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ext.BaseProjectVersionMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper; import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper; @@ -17,13 +20,16 @@ import io.metersphere.commons.enums.ApiTestDataStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; import io.metersphere.dto.ProjectConfig; +import io.metersphere.dto.UserDTO; import io.metersphere.i18n.Translator; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.BaseProjectApplicationService; +import io.metersphere.service.BaseUserService; import io.metersphere.service.MockConfigService; import io.metersphere.service.ServiceUtils; import io.metersphere.service.ext.ExtApiScheduleService; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -34,7 +40,6 @@ import org.json.JSONObject; import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -69,6 +74,8 @@ public class ApiDefinitionImportUtilService { private ExtApiTestCaseMapper extApiTestCaseMapper; @Resource private ApiTestCaseService apiTestCaseService; + @Resource + private BaseUserService baseUserService; public void checkUrl(ApiTestImportRequest request, Project project) { @@ -89,9 +96,11 @@ public class ApiDefinitionImportUtilService { public void sendImportNotice(ApiTestImportRequest request, List apiImportSendNoticeDTOS, Project project) { if (StringUtils.equals(request.getType(), SCHEDULE)) { String scheduleId = extApiScheduleService.getScheduleInfo(request.getResourceId()); + UserDTO userDTO = baseUserService.getUserDTO(request.getUserId()); String context = request.getSwaggerUrl() + "导入成功"; Map paramMap = new HashMap<>(); paramMap.put("url", request.getSwaggerUrl()); + paramMap.put("operator", userDTO.getName()); NoticeModel noticeModel = NoticeModel.builder().operator(project.getCreateUser()).context(context).testId(scheduleId).subject(Translator.get("swagger_url_scheduled_import_notification")).paramMap(paramMap).event(NoticeConstants.Event.EXECUTE_SUCCESSFUL).build(); noticeSendService.send(NoticeConstants.Mode.SCHEDULE, StringUtils.EMPTY, noticeModel); } @@ -142,10 +151,12 @@ public class ApiDefinitionImportUtilService { public void sendFailMessage(ApiTestImportRequest request, Project project) { if (StringUtils.equals(request.getType(), SCHEDULE)) { String scheduleId = extApiScheduleService.getScheduleInfo(request.getResourceId()); + UserDTO userDTO = baseUserService.getUserDTO(request.getUserId()); String context = request.getSwaggerUrl() + "导入失败"; Map paramMap = new HashMap<>(); paramMap.put("url", request.getSwaggerUrl()); paramMap.put("projectId", request.getProjectId()); + paramMap.put("operator", userDTO.getName()); NoticeModel noticeModel = NoticeModel.builder().operator(project.getCreateUser()).context(context).testId(scheduleId).subject(Translator.get("swagger_url_scheduled_import_notification")).paramMap(paramMap).event(NoticeConstants.Event.EXECUTE_FAILED).build(); noticeSendService.send(NoticeConstants.Mode.SCHEDULE, StringUtils.EMPTY, noticeModel); } diff --git a/framework/sdk-parent/frontend/src/components/MxNoticeTemplate.vue b/framework/sdk-parent/frontend/src/components/MxNoticeTemplate.vue index 65ff9763a4..01e3a03d10 100644 --- a/framework/sdk-parent/frontend/src/components/MxNoticeTemplate.vue +++ b/framework/sdk-parent/frontend/src/components/MxNoticeTemplate.vue @@ -53,11 +53,8 @@ export default { { label: this.$t('group.operator'), value: 'operator', - }, - { - label: this.$t('commons.name'), - value: 'name', - }]; + } + ]; } } },