From 86ad72b2c591ceeef26b204bc1ec73a050ad909f Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 25 Apr 2024 15:42:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF=E8=AE=BE=E7=BD=AE=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E7=9A=84=E6=A8=A1=E7=89=88=E9=A2=84=E8=A7=88=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=90=8C=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1040081 --user=王孝刚 【项目管理】消息设置-场景创建-模版设置完成后预览内容和模版设置中的更新预览显示不同 https://www.tapd.cn/55049933/s/1508976 --- .../definition/ApiReportLogService.java | 2 +- .../notice/utils/MessageTemplateUtils.java | 97 ++++++------------- 2 files changed, 29 insertions(+), 70 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportLogService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportLogService.java index 3b50354337..e779816f9f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportLogService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportLogService.java @@ -37,7 +37,7 @@ public class ApiReportLogService { apiReport.getProjectId(), project.getOrganizationId(), apiReport.getId(), - apiReport.getUpdateUser(), + null, OperationLogType.DELETE.name(), OperationLogModule.API_REPORT, apiReport.getName()); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/utils/MessageTemplateUtils.java b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/utils/MessageTemplateUtils.java index 6ae3bece2a..f17fce45db 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/utils/MessageTemplateUtils.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/utils/MessageTemplateUtils.java @@ -1,6 +1,5 @@ package io.metersphere.system.notice.utils; -import io.metersphere.api.domain.ApiScenario; import io.metersphere.functional.domain.CaseReview; import io.metersphere.load.domain.LoadTest; import io.metersphere.plan.domain.TestPlan; @@ -12,6 +11,8 @@ import io.metersphere.system.domain.Schedule; import io.metersphere.system.domain.User; import io.metersphere.system.dto.BugMessageDTO; import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO; +import io.metersphere.system.dto.sdk.ApiReportMessageDTO; +import io.metersphere.system.dto.sdk.ApiScenarioMessageDTO; import io.metersphere.system.dto.sdk.FunctionalCaseMessageDTO; import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.notice.constants.NoticeConstants; @@ -141,39 +142,19 @@ public class MessageTemplateUtils { } public static Field[] getDomainTemplateFields(String taskType) { - Field[] allFields; - switch (taskType) { - case NoticeConstants.TaskType.API_DEFINITION_TASK -> { - allFields = FieldUtils.getAllFields(ApiDefinitionCaseDTO.class); - } - case NoticeConstants.TaskType.API_SCENARIO_TASK -> { - allFields = FieldUtils.getAllFields(ApiScenario.class); - } - case NoticeConstants.TaskType.TEST_PLAN_TASK -> { - allFields = FieldUtils.getAllFields(TestPlan.class); - } - case NoticeConstants.TaskType.CASE_REVIEW_TASK -> { - allFields = FieldUtils.getAllFields(CaseReview.class); - } - case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> { - allFields = FieldUtils.getAllFields(FunctionalCaseMessageDTO.class); - } - case NoticeConstants.TaskType.BUG_TASK -> { - allFields = FieldUtils.getAllFields(BugMessageDTO.class); - } - case NoticeConstants.TaskType.UI_SCENARIO_TASK -> { - allFields = FieldUtils.getAllFields(UiScenario.class); - } - case NoticeConstants.TaskType.LOAD_TEST_TASK -> { - allFields = FieldUtils.getAllFields(LoadTest.class); - } - case NoticeConstants.TaskType.SCHEDULE_TASK -> { - allFields = FieldUtils.getAllFields(Schedule.class); - } - default -> allFields = new Field[0]; - } - - return allFields; + return switch (taskType) { + case NoticeConstants.TaskType.API_DEFINITION_TASK -> FieldUtils.getAllFields(ApiDefinitionCaseDTO.class); + case NoticeConstants.TaskType.API_SCENARIO_TASK -> FieldUtils.getAllFields(ApiScenarioMessageDTO.class); + case NoticeConstants.TaskType.API_REPORT_TASK -> FieldUtils.getAllFields(ApiReportMessageDTO.class); + case NoticeConstants.TaskType.TEST_PLAN_TASK -> FieldUtils.getAllFields(TestPlan.class); + case NoticeConstants.TaskType.CASE_REVIEW_TASK -> FieldUtils.getAllFields(CaseReview.class); + case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> FieldUtils.getAllFields(FunctionalCaseMessageDTO.class); + case NoticeConstants.TaskType.BUG_TASK -> FieldUtils.getAllFields(BugMessageDTO.class); + case NoticeConstants.TaskType.UI_SCENARIO_TASK -> FieldUtils.getAllFields(UiScenario.class); + case NoticeConstants.TaskType.LOAD_TEST_TASK -> FieldUtils.getAllFields(LoadTest.class); + case NoticeConstants.TaskType.SCHEDULE_TASK -> FieldUtils.getAllFields(Schedule.class); + default -> new Field[0]; + }; } public static String getContent(String template, Map context) { @@ -249,9 +230,9 @@ public class MessageTemplateUtils { if (taskType.contains(value.toString())) { List customFields = customFielddMap.get(value.toString()); if (CollectionUtils.isNotEmpty(customFields)) { - Map customFielddNameMap = new HashMap<>(); + Map customFielddNameMap = new HashMap<>(); for (CustomField customField : customFields) { - customFielddNameMap.put(customField.getName(), StringUtils.isBlank(customField.getName()) ? "-" : "<"+customField.getName()+">"); + customFielddNameMap.put(customField.getName(), StringUtils.isBlank(customField.getName()) ? "-" : "<" + customField.getName() + ">"); } map.putAll(customFielddNameMap); } @@ -261,39 +242,17 @@ public class MessageTemplateUtils { private static void setMap(String taskType, Field[] domainTemplateFields, Map map) { switch (taskType) { - case NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> { - putDescription(domainTemplateFields, map); - } - case NoticeConstants.TaskType.API_SCENARIO_TASK -> { - String tableName = "api_scenario_"; - putDomainName(domainTemplateFields, map, tableName); - } - case NoticeConstants.TaskType.TEST_PLAN_TASK -> { - String tableName = "test_plan_"; - putDomainName(domainTemplateFields, map, tableName); - } - case NoticeConstants.TaskType.CASE_REVIEW_TASK -> { - String tableName = "case_review_"; - putDomainName(domainTemplateFields, map, tableName); - } - case NoticeConstants.TaskType.BUG_TASK -> { - String tableName = "bug_"; - putDomainName(domainTemplateFields, map, tableName); - } - case NoticeConstants.TaskType.UI_SCENARIO_TASK -> { - String tableName = "ui_"; - putDomainName(domainTemplateFields, map, tableName); - } - case NoticeConstants.TaskType.LOAD_TEST_TASK -> { - String tableName = "load_"; - putDomainName(domainTemplateFields, map, tableName); - } - case NoticeConstants.TaskType.SCHEDULE_TASK -> { - String tableName = "schedule_"; - putDomainName(domainTemplateFields, map, tableName); - } - default -> { - } + case NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> + putDescription(domainTemplateFields, map); + case NoticeConstants.TaskType.API_SCENARIO_TASK -> putDescription(domainTemplateFields, map); + case NoticeConstants.TaskType.API_REPORT_TASK -> putDescription(domainTemplateFields, map); + case NoticeConstants.TaskType.TEST_PLAN_TASK -> putDomainName(domainTemplateFields, map, "test_plan_"); + case NoticeConstants.TaskType.CASE_REVIEW_TASK -> putDomainName(domainTemplateFields, map, "case_review_"); + case NoticeConstants.TaskType.BUG_TASK -> putDomainName(domainTemplateFields, map, "bug_"); + case NoticeConstants.TaskType.UI_SCENARIO_TASK -> putDomainName(domainTemplateFields, map, "ui_"); + case NoticeConstants.TaskType.LOAD_TEST_TASK -> putDomainName(domainTemplateFields, map, "load_"); + case NoticeConstants.TaskType.SCHEDULE_TASK -> putDomainName(domainTemplateFields, map, "schedule_"); + default -> {} } }