fix(项目管理): 修复消息设置场景的模版预览显示不同的缺陷

--bug=1040081 --user=王孝刚 【项目管理】消息设置-场景创建-模版设置完成后预览内容和模版设置中的更新预览显示不同
https://www.tapd.cn/55049933/s/1508976
This commit is contained in:
wxg0103 2024-04-25 15:42:23 +08:00 committed by Craftsman
parent 7cd6b0717c
commit 86ad72b2c5
2 changed files with 29 additions and 70 deletions

View File

@ -37,7 +37,7 @@ public class ApiReportLogService {
apiReport.getProjectId(), apiReport.getProjectId(),
project.getOrganizationId(), project.getOrganizationId(),
apiReport.getId(), apiReport.getId(),
apiReport.getUpdateUser(), null,
OperationLogType.DELETE.name(), OperationLogType.DELETE.name(),
OperationLogModule.API_REPORT, OperationLogModule.API_REPORT,
apiReport.getName()); apiReport.getName());

View File

@ -1,6 +1,5 @@
package io.metersphere.system.notice.utils; package io.metersphere.system.notice.utils;
import io.metersphere.api.domain.ApiScenario;
import io.metersphere.functional.domain.CaseReview; import io.metersphere.functional.domain.CaseReview;
import io.metersphere.load.domain.LoadTest; import io.metersphere.load.domain.LoadTest;
import io.metersphere.plan.domain.TestPlan; 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.domain.User;
import io.metersphere.system.dto.BugMessageDTO; import io.metersphere.system.dto.BugMessageDTO;
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO; 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.dto.sdk.FunctionalCaseMessageDTO;
import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.notice.constants.NoticeConstants;
@ -141,39 +142,19 @@ public class MessageTemplateUtils {
} }
public static Field[] getDomainTemplateFields(String taskType) { public static Field[] getDomainTemplateFields(String taskType) {
Field[] allFields; return switch (taskType) {
switch (taskType) { case NoticeConstants.TaskType.API_DEFINITION_TASK -> FieldUtils.getAllFields(ApiDefinitionCaseDTO.class);
case NoticeConstants.TaskType.API_DEFINITION_TASK -> { case NoticeConstants.TaskType.API_SCENARIO_TASK -> FieldUtils.getAllFields(ApiScenarioMessageDTO.class);
allFields = FieldUtils.getAllFields(ApiDefinitionCaseDTO.class); case NoticeConstants.TaskType.API_REPORT_TASK -> FieldUtils.getAllFields(ApiReportMessageDTO.class);
} case NoticeConstants.TaskType.TEST_PLAN_TASK -> FieldUtils.getAllFields(TestPlan.class);
case NoticeConstants.TaskType.API_SCENARIO_TASK -> { case NoticeConstants.TaskType.CASE_REVIEW_TASK -> FieldUtils.getAllFields(CaseReview.class);
allFields = FieldUtils.getAllFields(ApiScenario.class); case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> FieldUtils.getAllFields(FunctionalCaseMessageDTO.class);
} case NoticeConstants.TaskType.BUG_TASK -> FieldUtils.getAllFields(BugMessageDTO.class);
case NoticeConstants.TaskType.TEST_PLAN_TASK -> { case NoticeConstants.TaskType.UI_SCENARIO_TASK -> FieldUtils.getAllFields(UiScenario.class);
allFields = FieldUtils.getAllFields(TestPlan.class); case NoticeConstants.TaskType.LOAD_TEST_TASK -> FieldUtils.getAllFields(LoadTest.class);
} case NoticeConstants.TaskType.SCHEDULE_TASK -> FieldUtils.getAllFields(Schedule.class);
case NoticeConstants.TaskType.CASE_REVIEW_TASK -> { default -> new Field[0];
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;
} }
public static String getContent(String template, Map<String, Object> context) { public static String getContent(String template, Map<String, Object> context) {
@ -249,9 +230,9 @@ public class MessageTemplateUtils {
if (taskType.contains(value.toString())) { if (taskType.contains(value.toString())) {
List<CustomField> customFields = customFielddMap.get(value.toString()); List<CustomField> customFields = customFielddMap.get(value.toString());
if (CollectionUtils.isNotEmpty(customFields)) { if (CollectionUtils.isNotEmpty(customFields)) {
Map <String,String>customFielddNameMap = new HashMap<>(); Map<String, String> customFielddNameMap = new HashMap<>();
for (CustomField customField : customFields) { 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); map.putAll(customFielddNameMap);
} }
@ -261,39 +242,17 @@ public class MessageTemplateUtils {
private static void setMap(String taskType, Field[] domainTemplateFields, Map<String, Object> map) { private static void setMap(String taskType, Field[] domainTemplateFields, Map<String, Object> map) {
switch (taskType) { switch (taskType) {
case NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> { case NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK ->
putDescription(domainTemplateFields, map); putDescription(domainTemplateFields, map);
} case NoticeConstants.TaskType.API_SCENARIO_TASK -> putDescription(domainTemplateFields, map);
case NoticeConstants.TaskType.API_SCENARIO_TASK -> { case NoticeConstants.TaskType.API_REPORT_TASK -> putDescription(domainTemplateFields, map);
String tableName = "api_scenario_"; case NoticeConstants.TaskType.TEST_PLAN_TASK -> putDomainName(domainTemplateFields, map, "test_plan_");
putDomainName(domainTemplateFields, map, tableName); case NoticeConstants.TaskType.CASE_REVIEW_TASK -> putDomainName(domainTemplateFields, map, "case_review_");
} case NoticeConstants.TaskType.BUG_TASK -> putDomainName(domainTemplateFields, map, "bug_");
case NoticeConstants.TaskType.TEST_PLAN_TASK -> { case NoticeConstants.TaskType.UI_SCENARIO_TASK -> putDomainName(domainTemplateFields, map, "ui_");
String tableName = "test_plan_"; case NoticeConstants.TaskType.LOAD_TEST_TASK -> putDomainName(domainTemplateFields, map, "load_");
putDomainName(domainTemplateFields, map, tableName); case NoticeConstants.TaskType.SCHEDULE_TASK -> putDomainName(domainTemplateFields, map, "schedule_");
} default -> {}
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 -> {
}
} }
} }