From a0165f2dd6a08960416706277c92d3708f6cb354 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 23 Oct 2023 14:29:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B6=88=E6=81=AF=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E8=8E=B7=E5=8F=96=E6=A8=A1=E7=89=88=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=86=85=E5=AE=B9=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/NoticeTemplateService.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeTemplateService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeTemplateService.java index 58755f52cb..305feb7791 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeTemplateService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeTemplateService.java @@ -44,52 +44,52 @@ public class NoticeTemplateService { switch (taskType) { case NoticeConstants.TaskType.API_DEFINITION_TASK -> { Field[] allFields = FieldUtils.getAllFields(ApiDefinitionCaseDTO.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, null); addCustomFiled(messageTemplateFieldDTOList, projectId, TemplateScene.API.toString()); //TODO:获取报告 } case NoticeConstants.TaskType.API_SCENARIO_TASK -> { Field[] allFields = FieldUtils.getAllFields(ApiScenario.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "api_scenario_"); //TODO:获取报告 } case NoticeConstants.TaskType.TEST_PLAN_TASK -> { Field[] allFields = FieldUtils.getAllFields(TestPlan.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "test_plan_"); addCustomFiled(messageTemplateFieldDTOList, projectId, TemplateScene.TEST_PLAN.toString()); //TODO:获取报告 } case NoticeConstants.TaskType.CASE_REVIEW_TASK -> { Field[] allFields = FieldUtils.getAllFields(CaseReview.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "case_review_"); //TODO:获取报告 } case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> { Field[] allFields = FieldUtils.getAllFields(FunctionalCaseMessageDTO.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, null); addCustomFiled(messageTemplateFieldDTOList, projectId, TemplateScene.FUNCTIONAL.toString()); //TODO:获取报告 } case NoticeConstants.TaskType.BUG_TASK -> { Field[] allFields = FieldUtils.getAllFields(Bug.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "bug_"); addCustomFiled(messageTemplateFieldDTOList, projectId, TemplateScene.BUG.toString()); //TODO:获取报告 } case NoticeConstants.TaskType.UI_SCENARIO_TASK -> { Field[] allFields = FieldUtils.getAllFields(UiScenario.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "ui_"); addCustomFiled(messageTemplateFieldDTOList, projectId, TemplateScene.UI.toString()); //TODO:获取报告 } case NoticeConstants.TaskType.LOAD_TEST_TASK -> { Field[] allFields = FieldUtils.getAllFields(LoadTest.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "load_"); //TODO:获取报告 } case NoticeConstants.TaskType.SCHEDULE_TASK -> { Field[] allFields = FieldUtils.getAllFields(Schedule.class); - addOptionDto(messageTemplateFieldDTOList, allFields); + addOptionDto(messageTemplateFieldDTOList, allFields, "schedule_"); //TODO:获取报告 } case NoticeConstants.TaskType.JENKINS_TASK -> { @@ -132,7 +132,7 @@ public class NoticeTemplateService { * @param messageTemplateFieldDTOS messageTemplateFieldDTOS * @param allFields allFields */ - private static void addOptionDto(List messageTemplateFieldDTOS, Field[] allFields) { + private static void addOptionDto(List messageTemplateFieldDTOS, Field[] allFields, String tableName) { Field[] sensitiveFields = FieldUtils.getAllFields(NoticeConstants.SensitiveField.class); ArrayList sensitiveFieldList = new ArrayList<>(sensitiveFields.length); Collections.addAll(sensitiveFieldList, sensitiveFields); @@ -146,7 +146,12 @@ public class NoticeTemplateService { Schema annotation = allField.getAnnotation(Schema.class); if (annotation != null) { messageTemplateFieldDTO.setId(allField.getName()); - String description = annotation.description(); + String description; + if (StringUtils.isBlank(tableName)) { + description = Translator.get(annotation.description()); + } else { + description = Translator.get("message.domain." + tableName + allField.getName()); + } messageTemplateFieldDTO.setName(description); messageTemplateFieldDTO.setFieldSource(NoticeConstants.FieldSource.CASE_FIELD); messageTemplateFieldDTOS.add(messageTemplateFieldDTO); @@ -184,4 +189,5 @@ public class NoticeTemplateService { messageTemplateResultDTO.setFieldSourceList(optionDTOList); return messageTemplateResultDTO; } + }