refactor(消息管理): 修改模版的国际化显示

This commit is contained in:
guoyuqi 2023-10-23 09:51:05 +08:00 committed by f2c-ci-robot[bot]
parent d4d7307819
commit c1c11501c3
12 changed files with 693 additions and 94 deletions

View File

@ -8,76 +8,73 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class ApiDefinitionCaseDTO { public class ApiDefinitionCaseDTO {
@Schema(description = "接口名称") @Schema(description ="message.domain.name")
private String name; private String name;
@Schema(description = "接口协议") @Schema(description ="message.domain.protocol")
private String protocol; private String protocol;
@Schema(description = "http协议类型post/get/其它协议则是协议名(mqtt)") @Schema(description ="message.domain.method")
private String method; private String method;
@Schema(description = "http协议路径/其它协议则为空") @Schema(description ="message.domain.path")
private String path; private String path;
@Schema(description = "接口状态/进行中/已完成") @Schema(description ="message.domain.status")
private String status; private String status;
@Schema(description = "描述") @Schema(description ="message.domain.description")
private String description; private String description;
@Schema(description = "创建时间") @Schema(description ="message.domain.create_time")
private Long createTime; private Long createTime;
@Schema(description = "创建人") @Schema(description ="message.domain.create_user")
private String createUser; private String createUser;
@Schema(description = "修改时间") @Schema(description ="message.domain.update_time")
private Long updateTime; private Long updateTime;
@Schema(description = "修改人") @Schema(description ="message.domain.update_user")
private String updateUser; private String updateUser;
@Schema(description = "删除人") @Schema(description ="message.domain.delete_user")
private String deleteUser; private String deleteUser;
@Schema(description = "删除时间") @Schema(description ="message.domain.delete_time")
private Long deleteTime; private Long deleteTime;
@Schema(description = "接口用例名称") @Schema(description ="message.domain.case_name")
private String caseName; private String caseName;
@Schema(description = "用例等级") @Schema(description ="message.domain.priority")
private String priority; private String priority;
@Schema(description = "用例状态") @Schema(description ="message.domain.case_status")
private String caseStatus; private String caseStatus;
@Schema(description = "用例最新执行结果状态") @Schema(description ="message.domain.last_report_status")
private String lastReportStatus; private String lastReportStatus;
@Schema(description = "用例最后执行结果报告fk") @Schema(description ="message.domain.principal")
private String lastReportId;
@Schema(description = "用例责任人")
private String principal; private String principal;
@Schema(description = "用例创建时间") @Schema(description ="message.domain.case_create_time")
private Long caseCreateTime; private Long caseCreateTime;
@Schema(description = "用例创建人") @Schema(description ="message.domain.case_create_user")
private String caseCreateUser; private String caseCreateUser;
@Schema(description = "用例更新时间") @Schema(description ="message.domain.case_update_time")
private Long caseUpdateTime; private Long caseUpdateTime;
@Schema(description = "用例更新人") @Schema(description ="message.domain.case_update_user")
private String caseUpdateUser; private String caseUpdateUser;
@Schema(description = "用例删除时间") @Schema(description ="message.domain.case_delete_time")
private Long caseDeleteTime; private Long caseDeleteTime;
@Schema(description = "用例删除人") @Schema(description ="message.domain.case_delete_user")
private String caseDeleteUser; private String caseDeleteUser;

View File

@ -8,40 +8,40 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class FunctionalCaseMessageDTO { public class FunctionalCaseMessageDTO {
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description ="message.domain.name")
private String name; private String name;
@Schema(description = "测试计划名称", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "message.domain.test_plan_name")
private String testPlanName; private String testPlanName;
@Schema(description = "评审名称", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "message.domain.review_name")
private String reviewName; private String reviewName;
@Schema(description = "评审状态:未开始/进行中/已完成/已结束", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "message.domain.review_status")
private String reviewStatus; private String reviewStatus;
@Schema(description = "编辑模式:步骤模式/文本模式", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "message.domain.case_model")
private String caseModel; private String caseModel;
@Schema(description = "最近的执行结果:未执行/通过/失败/阻塞/跳过", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "message.domain.last_execute_result")
private String lastExecuteResult; private String lastExecuteResult;
@Schema(description = "创建人") @Schema(description = "message.domain.create_user")
private String createUser; private String createUser;
@Schema(description = "更新人") @Schema(description = "message.domain.update_user")
private String updateUser; private String updateUser;
@Schema(description = "删除人") @Schema(description = "message.domain.delete_user")
private String deleteUser; private String deleteUser;
@Schema(description = "创建时间") @Schema(description = "message.domain.create_time")
private Long createTime; private Long createTime;
@Schema(description = "更新时间") @Schema(description = "message.domain.update_time")
private Long updateTime; private Long updateTime;
@Schema(description = "删除时间") @Schema(description = "message.domain.delete_time")
private Long deleteTime; private Long deleteTime;
} }

View File

@ -289,7 +289,126 @@ message.title.jenkins_task_execute_successful=Jenkins任务执行成功通知
message.title.jenkins_task_execute_failed=Jenkins任务执行失败通知 message.title.jenkins_task_execute_failed=Jenkins任务执行失败通知
message.title.schedule_task_open=开启定时任务通知 message.title.schedule_task_open=开启定时任务通知
message.title.schedule_task_close=关闭定时任务通知 message.title.schedule_task_close=关闭定时任务通知
#功能用例
message.domain.name=名称
message.domain.test_plan_name=测试计划名称
message.domain.review_name=评审名称
message.domain.review_status=评审状态
message.domain.case_model=编辑模式
message.domain.last_execute_result=最近的执行结果
message.domain.create_user=创建人
message.domain.update_user=更新人
message.domain.delete_user=删除人
message.domain.create_time=创建时间
message.domain.update_time=更新时间
message.domain.delete_time=删除时间
#接口定义和用例
message.domain.protocol=接口协议
message.domain.method=http协议类型
message.domain.path=http协议路径/其它协议则为空
message.domain.status=接口状态
message.domain.description=描述
message.domain.case_name=接口用例名称
message.domain.priority=用例等级
message.domain.case_status=用例状态
message.domain.last_report_status=用例最新执行结果状态
message.domain.principal=用例责任人
message.domain.case_create_time=用例创建时间
message.domain.case_create_user=用例创建人
message.domain.case_update_time=用例更新时间
message.domain.case_update_user=用例更新人
message.domain.case_delete_time=用例删除时间
message.domain.case_delete_user=用例删除人
#场景字段
message.domain.api_scenario_name=场景名称
message.domain.api_scenario_level=场景级别
message.domain.api_scenario_status=场景状态
message.domain.api_scenario_principal=责任人
message.domain.api_scenario_stepTotal=场景步骤总数
message.domain.api_scenario_num=编号
message.domain.api_scenario_passRate=通过率
message.domain.api_scenario_lastReportStatus=最后一次执行的结果状态
message.domain.api_scenario_description=描述
message.domain.api_scenario_tags=标签
message.domain.api_scenario_grouped=是否为环境组
message.domain.api_scenario_createUser=创建人
message.domain.api_scenario_updateUser=更新人
message.domain.api_scenario_deleteUser=删除人
message.domain.api_scenario_createTime=创建时间
message.domain.api_scenario_updateTime=更新时间
message.domain.api_scenario_deleteTime=删除时间
# 测试计划
message.domain.test_plan_stage=测试阶段
message.domain.test_plan_status=测试计划状态
message.domain.test_plan_description=描述
message.domain.test_plan_tags=标签
message.domain.test_plan_createUser=创建人
message.domain.test_plan_updateUser=更新人
message.domain.test_plan_createTime=创建时间
message.domain.test_plan_updateTime=更新时间
message.domain.test_plan_plannedStartTime=计划开始时间
message.domain.test_plan_plannedEndTime=计划结束时间
message.domain.test_plan_actualStartTime=实际开始时间
message.domain.test_plan_actualEndTime=实际结束时间
# 用例评审
message.domain.case_review_name=名称
message.domain.case_review_status=评审状态
message.domain.case_review_description=描述
message.domain.case_review_tags=标签
message.domain.case_review_createUser=创建人
message.domain.case_review_createTime=创建时间
message.domain.case_review_updateTime=更新时间
message.domain.case_review_updateUser=更新人
message.domain.case_review_endTime=评审结束时间
message.domain.case_review_reviewPassRule=评审规则
# 缺陷
message.domain.bug_num=业务ID
message.domain.bug_title=缺陷标题
message.domain.bug_assignUser=指派人
message.domain.bug_platform=缺陷平台
message.domain.bug_tags=标签
message.domain.bug_status=状态
message.domain.bug_createUser=创建人
message.domain.bug__updateUser=更新人
message.domain.bug_createTime=创建时间
message.domain.bug_updateTime=更新时间
message.domain.bug_deleteUser=删除人
message.domain.bug_deleteTime=删除时间
#UI
message.domain.ui_name=场景名称
message.domain.ui_level=用例等级
message.domain.ui_principal=责任人
message.domain.ui_stepTotal=步骤总数
message.domain.ui_tags=标签
message.domain.ui_status=状态
message.domain.ui_num=业务ID
message.domain.ui_lastResult=最后执行结果
message.domain.ui_createUser=创建人
message.domain.ui_updateUser=更新人
message.domain.ui_createTime=创建时间
message.domain.ui_updateTime=更新时间
message.domain.ui_deleteUser=删除人
message.domain.ui_deleteTime=删除时间
#性能
message.domain.load_name=测试名称
message.domain.load_status=状态
message.domain.load_num=业务ID
message.domain.load_createUser=创建人
message.domain.load_updateUser=更新人
message.domain.load_createTime=创建时间
message.domain.load_updateTime=更新时间
#定时任务
message.domain.schedule_key=qrtz UUID
message.domain.schedule_type=资源类型
message.domain.schedule_value=cron 表达式
message.domain.schedule_job=Schedule Job Class Name
message.domain.schedule_name=名称
message.domain.schedule_config=配置
message.domain.schedule_createUser=创建人
message.domain.schedule_updateUser=更新人
message.domain.schedule_createTime=创建时间
message.domain.schedule_updateTime=更新时间
#资源池
resource_pool_not_exist=资源池不存在 resource_pool_not_exist=资源池不存在
#file management #file management

View File

@ -323,6 +323,127 @@ message.title.jenkins_task_execute_failed=Jenkins task execution failure notific
message.title.schedule_task_open=Turn on scheduled task notifications message.title.schedule_task_open=Turn on scheduled task notifications
message.title.schedule_task_close=Turn off scheduled task notifications message.title.schedule_task_close=Turn off scheduled task notifications
#功能case
message.domain.name=Name
message.domain.test_plan_name=Test plan name
message.domain.review_name=Review name
message.domain.review_status=Review status
message.domain.case_model=Edit mode
message.domain.last_execute_result=Recent execution results
message.domain.create_user=Create user
message.domain.update_user=Update user
message.domain.delete_user=Delete user
message.domain.create_time=Create time
message.domain.update_time=Update time
message.domain.delete_time=Delete time
#接口定义和case
message.domain.protocol=Interface Protocol
message.domain.method=Http protocol type
message.domain.path=Http protocol path/other protocols are empty
message.domain.status=Interface status
message.domain.description=Description
message.domain.case_name=Interface case name
message.domain.priority=Case level
message.domain.case_status=Case status
message.domain.last_report_status=The latest execution result status of the use case
message.domain.principal=Case responsible
message.domain.case_create_time=Case create time
message.domain.case_create_user=Case create user
message.domain.case_update_time=Case update time
message.domain.case_update_user=Case update user
message.domain.case_delete_time=Case delete time
message.domain.case_delete_user=Case delete user
#Scenario字段
message.domain.api_scenario_name=Scenario name
message.domain.api_scenario_level=Scenario level
message.domain.api_scenario_status=Scenario status
message.domain.api_scenario_principal=Responsible
message.domain.api_scenario_stepTotal=Overview of scenario steps
message.domain.api_scenario_num=Number
message.domain.api_scenario_passRate=Passing rate
message.domain.api_scenario_lastReportStatus=The latest execution result status
message.domain.api_scenario_description=Description
message.domain.api_scenario_tags=Tag
message.domain.api_scenario_grouped=Whether it is an environment group
message.domain.api_scenario_createUser=Create user
message.domain.api_scenario_updateUser=Update user
message.domain.api_scenario_deleteUser=Delete user
message.domain.api_scenario_createTime=Create time
message.domain.api_scenario_updateTime=Update time
message.domain.api_scenario_deleteTime=Delete time
# Test plan
message.domain.test_plan_stage=Testing phase
message.domain.test_plan_status=Test plan status
message.domain.test_plan_description=Description
message.domain.test_plan_tags=Tag
message.domain.test_plan_createUser=Create user
message.domain.test_plan_updateUser=Update user
message.domain.test_plan_createTime=Create time
message.domain.test_plan_updateTime=Update time
message.domain.test_plan_plannedStartTime=Planned start time
message.domain.test_plan_plannedEndTime=Planned end time
message.domain.test_plan_actualStartTime=Actual start time
message.domain.test_plan_actualEndTime=Actual end time
# case Review
message.domain.case_review_name=Name
message.domain.case_review_status=Review status
message.domain.case_review_description=Description
message.domain.case_review_tags=Tag
message.domain.case_review_createUser=Create user
message.domain.case_review_createTime=Create time
message.domain.case_review_updateTime=Update time
message.domain.case_review_updateUser=Update user
message.domain.case_review_endTime=Review end time
message.domain.case_review_reviewPassRule=Review rules
# 缺陷
message.domain.bug_num=Business ID
message.domain.bug_title=Defect title
message.domain.bug_assignUser=Designed
message.domain.bug_platform=Defective platform
message.domain.bug_tags=Tag
message.domain.bug_status=Status
message.domain.bug_createUser=Create user
message.domain.bug__updateUser=Update user
message.domain.bug_createTime=Create time
message.domain.bug_updateTime=Update time
message.domain.bug_deleteUser=Delete user
message.domain.bug_deleteTime=Delete time
#UI
message.domain.ui_name=Scenario name
message.domain.ui_level=Case level
message.domain.ui_principal=Responsible
message.domain.ui_stepTotal=Total number of steps
message.domain.ui_tags=Tag
message.domain.ui_status=Status
message.domain.ui_num=Business ID
message.domain.ui_lastResult=Final execution result
message.domain.ui_createUser=Create user
message.domain.ui_updateUser=Update user
message.domain.ui_createTime=Create time
message.domain.ui_updateTime=Update time
message.domain.ui_deleteUser=Delete user
message.domain.ui_deleteTime=Delete time
#性能
message.domain.load_name=Test name
message.domain.load_status=Status
message.domain.load_num=Business ID
message.domain.load_createUser=Create user
message.domain.load_updateUser=Update user
message.domain.load_createTime=Create time
message.domain.load_updateTime=Update time
#定时任务
message.domain.schedule_key=qrtz UUID
message.domain.schedule_type=Resource Type
message.domain.schedule_value=Cron expression
message.domain.schedule_job=Schedule Job Class Name
message.domain.schedule_name=Name
message.domain.schedule_config=Configuration
message.domain.schedule_createUser=Create user
message.domain.schedule_updateUser=Update user
message.domain.schedule_createTime=Create time
message.domain.schedule_updateTime=Update time
resource_pool_not_exist=Resource pool does not exist resource_pool_not_exist=Resource pool does not exist
#file management #file management

View File

@ -323,6 +323,126 @@ message.title.jenkins_task_execute_failed=Jenkins任务执行失败通知
message.title.schedule_task_open=开启定时任务通知 message.title.schedule_task_open=开启定时任务通知
message.title.schedule_task_close=关闭定时任务通知 message.title.schedule_task_close=关闭定时任务通知
#功能用例
message.domain.name=名称
message.domain.test_plan_name=测试计划名称
message.domain.review_name=评审名称
message.domain.review_status=评审状态
message.domain.case_model=编辑模式
message.domain.last_execute_result=最近的执行结果
message.domain.create_user=创建人
message.domain.update_user=更新人
message.domain.delete_user=删除人
message.domain.create_time=创建时间
message.domain.update_time=更新时间
message.domain.delete_time=删除时间
#接口定义和用例
message.domain.protocol=接口协议
message.domain.method=http协议类型
message.domain.path=http协议路径/其它协议则为空
message.domain.status=接口状态
message.domain.description=描述
message.domain.case_name=接口用例名称
message.domain.priority=用例等级
message.domain.case_status=用例状态
message.domain.last_report_status=用例最新执行结果状态
message.domain.principal=用例责任人
message.domain.case_create_time=用例创建时间
message.domain.case_create_user=用例创建人
message.domain.case_update_time=用例更新时间
message.domain.case_update_user=用例更新人
message.domain.case_delete_time=用例删除时间
message.domain.case_delete_user=用例删除人
#场景字段
message.domain.api_scenario_name=场景名称
message.domain.api_scenario_level=场景级别
message.domain.api_scenario_status=场景状态
message.domain.api_scenario_principal=责任人
message.domain.api_scenario_stepTotal=场景步骤总数
message.domain.api_scenario_num=编号
message.domain.api_scenario_passRate=通过率
message.domain.api_scenario_lastReportStatus=最后一次执行的结果状态
message.domain.api_scenario_description=描述
message.domain.api_scenario_tags=标签
message.domain.api_scenario_grouped=是否为环境组
message.domain.api_scenario_createUser=创建人
message.domain.api_scenario_updateUser=更新人
message.domain.api_scenario_deleteUser=删除人
message.domain.api_scenario_createTime=创建时间
message.domain.api_scenario_updateTime=更新时间
message.domain.api_scenario_deleteTime=删除时间
# 测试计划
message.domain.test_plan_stage=测试阶段
message.domain.test_plan_status=测试计划状态
message.domain.test_plan_description=描述
message.domain.test_plan_tags=标签
message.domain.test_plan_createUser=创建人
message.domain.test_plan_updateUser=更新人
message.domain.test_plan_createTime=创建时间
message.domain.test_plan_updateTime=更新时间
message.domain.test_plan_plannedStartTime=计划开始时间
message.domain.test_plan_plannedEndTime=计划结束时间
message.domain.test_plan_actualStartTime=实际开始时间
message.domain.test_plan_actualEndTime=实际结束时间
# 用例评审
message.domain.case_review_name=名称
message.domain.case_review_status=评审状态
message.domain.case_review_description=描述
message.domain.case_review_tags=标签
message.domain.case_review_createUser=创建人
message.domain.case_review_createTime=创建时间
message.domain.case_review_updateTime=更新时间
message.domain.case_review_updateUser=更新人
message.domain.case_review_endTime=评审结束时间
message.domain.case_review_reviewPassRule=评审规则
# 缺陷
message.domain.bug_num=业务ID
message.domain.bug_title=缺陷标题
message.domain.bug_assignUser=指派人
message.domain.bug_platform=缺陷平台
message.domain.bug_tags=标签
message.domain.bug_status=状态
message.domain.bug_createUser=创建人
message.domain.bug__updateUser=更新人
message.domain.bug_createTime=创建时间
message.domain.bug_updateTime=更新时间
message.domain.bug_deleteUser=删除人
message.domain.bug_deleteTime=删除时间
#UI
message.domain.ui_name=场景名称
message.domain.ui_level=用例等级
message.domain.ui_principal=责任人
message.domain.ui_stepTotal=步骤总数
message.domain.ui_tags=标签
message.domain.ui_status=状态
message.domain.ui_num=业务ID
message.domain.ui_lastResult=最后执行结果
message.domain.ui_createUser=创建人
message.domain.ui_updateUser=更新人
message.domain.ui_createTime=创建时间
message.domain.ui_updateTime=更新时间
message.domain.ui_deleteUser=删除人
message.domain.ui_deleteTime=删除时间
#性能
message.domain.load_name=测试名称
message.domain.load_status=状态
message.domain.load_num=业务ID
message.domain.load_createUser=创建人
message.domain.load_updateUser=更新人
message.domain.load_createTime=创建时间
message.domain.load_updateTime=更新时间
#定时任务
message.domain.schedule_key=qrtz UUID
message.domain.schedule_type=资源类型
message.domain.schedule_value=cron 表达式
message.domain.schedule_job=Schedule Job Class Name
message.domain.schedule_name=名称
message.domain.schedule_config=配置
message.domain.schedule_createUser=创建人
message.domain.schedule_updateUser=更新人
message.domain.schedule_createTime=创建时间
message.domain.schedule_updateTime=更新时间
resource_pool_not_exist=资源池不存在 resource_pool_not_exist=资源池不存在
#file management #file management

View File

@ -195,9 +195,9 @@ message.case_delete=删除用例
message.case_execute_successful=用例執行成功 message.case_execute_successful=用例執行成功
message.case_execute_fake_error=用例執行誤報 message.case_execute_fake_error=用例執行誤報
message.case_execute_failed=用例執行失敗 message.case_execute_failed=用例執行失敗
message.scenario_execute_successful=景執行成功 message.scenario_execute_successful=景執行成功
message.scenario_execute_fake_error=景執行誤報 message.scenario_execute_fake_error=景執行誤報
message.scenario_execute_failed=景執行失敗 message.scenario_execute_failed=景執行失敗
message.execute_successful=執行成功 message.execute_successful=執行成功
message.execute_failed=執行失敗 message.execute_failed=執行失敗
message.execute_passed=執行通過 message.execute_passed=執行通過
@ -323,6 +323,127 @@ message.title.jenkins_task_execute_successful=Jenkins任務執行成功通知
message.title.jenkins_task_execute_failed=Jenkins任務執行失敗通知 message.title.jenkins_task_execute_failed=Jenkins任務執行失敗通知
message.title.schedule_task_open=開啟定時任務通知 message.title.schedule_task_open=開啟定時任務通知
message.title.schedule_task_close=關閉定時任務通知 message.title.schedule_task_close=關閉定時任務通知
#功能用例
message.domain.name=名稱
message.domain.test_plan_name=測試計劃名稱
message.domain.review_name=評審名稱
message.domain.review_status=評審狀態
message.domain.case_model=編輯模式
message.domain.last_execute_result=最近的執行結果
message.domain.create_user=創建人
message.domain.update_user=更新人
message.domain.delete_user=删除人
message.domain.create_time=創建時間
message.domain.update_time=更新時間
message.domain.delete_time=刪除時間
#接口定义和用例
message.domain.protocol=介面協定
message.domain.method=http協定類型
message.domain.path=http協定路徑/其它協定則為空
message.domain.status=介面狀態
message.domain.description=描述
message.domain.case_name=介面用例名稱
message.domain.priority=用例等級
message.domain.case_status=用例狀態
message.domain.last_report_status=使用案例最新執行結果狀態
message.domain.principal=用例責任人
message.domain.case_create_time=用例創建時間
message.domain.case_create_user=用例創建人
message.domain.case_update_time=用例更新時間
message.domain.case_update_user=用例更新人
message.domain.case_delete_time=用例刪除時間
message.domain.case_delete_user=用例刪除人
#場景字段
message.domain.api_scenario_name=場景名稱
message.domain.api_scenario_level=場景等級
message.domain.api_scenario_status=場景狀態
message.domain.api_scenario_principal=責任人
message.domain.api_scenario_stepTotal=場景步驟總數
message.domain.api_scenario_num=編號
message.domain.api_scenario_passRate=通過率
message.domain.api_scenario_lastReportStatus=最後一次執行的結果狀態
message.domain.api_scenario_description=描述
message.domain.api_scenario_tags=標籤
message.domain.api_scenario_grouped=是否為環境組
message.domain.api_scenario_createUser=創建人
message.domain.api_scenario_updateUser=更新人
message.domain.api_scenario_deleteUser=删除人
message.domain.api_scenario_createTime=創建時間
message.domain.api_scenario_updateTime=更新時間
message.domain.api_scenario_deleteTime=刪除時間
# 测试计划
message.domain.test_plan_stage=測試階段
message.domain.test_plan_status=測試計劃狀態
message.domain.test_plan_description=描述
message.domain.test_plan_tags=標籤
message.domain.test_plan_createUser=創建人
message.domain.test_plan_updateUser=更新人
message.domain.test_plan_createTime=創建時間
message.domain.test_plan_updateTime=更新時間
message.domain.test_plan_plannedStartTime=計劃開始時間
message.domain.test_plan_plannedEndTime=計劃結束時間
message.domain.test_plan_actualStartTime=實際開始時間
message.domain.test_plan_actualEndTime=實際結束時間
# 用例评审
message.domain.case_review_name=名稱
message.domain.case_review_status=评审狀態
message.domain.case_review_description=描述
message.domain.case_review_tags=標籤
message.domain.case_review_createUser=創建人
message.domain.case_review_createTime=創建時間
message.domain.case_review_updateTime=更新時間
message.domain.case_review_updateUser=更新人
message.domain.case_review_endTime=評審結束時間
message.domain.case_review_reviewPassRule=評審規則
# 缺陷
message.domain.bug_num=業務ID
message.domain.bug_title=缺陷標題
message.domain.bug_assignUser=指派人
message.domain.bug_platform=缺陷平台
message.domain.bug_tags=標籤
message.domain.bug_status=狀態
message.domain.bug_createUser=創建人
message.domain.bug__updateUser=更新人
message.domain.bug_createTime=創建時間
message.domain.bug_updateTime=更新時間
message.domain.bug_deleteUser=删除人
message.domain.bug_deleteTime=刪除時間
#UI
message.domain.ui_name=場景名稱
message.domain.ui_level=用例等級
message.domain.ui_principal=責任人
message.domain.ui_stepTotal=步驟總數
message.domain.ui_tags=標籤
message.domain.ui_status=狀態
message.domain.ui_num=業務ID
message.domain.ui_lastResult=最後執行結果
message.domain.ui_createUser=創建人
message.domain.ui_updateUser=更新人
message.domain.ui_createTime=創建時間
message.domain.ui_updateTime=更新時間
message.domain.ui_deleteUser=删除人
message.domain.ui_deleteTime=刪除時間
#性能
message.domain.load_name=測試名稱
message.domain.load_status=狀態
message.domain.load_num=業務ID
message.domain.load_createUser=創建人
message.domain.load_updateUser=更新人
message.domain.load_createTime=創建時間
message.domain.load_updateTime=更新時間
#定时任务
message.domain.schedule_key=qrtz UUID
message.domain.schedule_type=資源類型
message.domain.schedule_value=cron 表達式
message.domain.schedule_job=Schedule Job Class Name
message.domain.schedule_name=名稱
message.domain.schedule_config=配置
message.domain.schedule_createUser=創建人
message.domain.schedule_updateUser=更新人
message.domain.schedule_createTime=創建時間
message.domain.schedule_updateTime=更新時間
resource_pool_not_exist=資源池不存在 resource_pool_not_exist=資源池不存在
#file management #file management
file_module.not.exist=文件模塊不存在 file_module.not.exist=文件模塊不存在

View File

@ -97,7 +97,7 @@ public class CreateRobotResourceService implements CreateProjectResourceService
List<MessageTaskTypeDTO> messageTaskTypeDTOList = messageTaskDTO.getMessageTaskTypeDTOList(); List<MessageTaskTypeDTO> messageTaskTypeDTOList = messageTaskDTO.getMessageTaskTypeDTOList();
for (MessageTaskTypeDTO messageTaskTypeDTO : messageTaskTypeDTOList) { for (MessageTaskTypeDTO messageTaskTypeDTO : messageTaskTypeDTOList) {
String taskType = messageTaskTypeDTO.getTaskType(); String taskType = messageTaskTypeDTO.getTaskType();
if (taskType.contains(NoticeConstants.Mode.SCHEDULE) || taskType.contains("AT")) { if (taskType.contains("AT")) {
continue; continue;
} }
List<MessageTaskDetailDTO> messageTaskDetailDTOList = messageTaskTypeDTO.getMessageTaskDetailDTOList(); List<MessageTaskDetailDTO> messageTaskDetailDTOList = messageTaskTypeDTO.getMessageTaskDetailDTOList();

View File

@ -6,6 +6,7 @@ import io.metersphere.project.dto.*;
import io.metersphere.project.enums.ProjectRobotPlatform; import io.metersphere.project.enums.ProjectRobotPlatform;
import io.metersphere.project.enums.result.ProjectResultCode; import io.metersphere.project.enums.result.ProjectResultCode;
import io.metersphere.project.mapper.*; import io.metersphere.project.mapper.*;
import io.metersphere.sdk.constants.TemplateScene;
import io.metersphere.sdk.dto.OptionDTO; import io.metersphere.sdk.dto.OptionDTO;
import io.metersphere.sdk.dto.request.MessageTaskRequest; import io.metersphere.sdk.dto.request.MessageTaskRequest;
import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.exception.MSException;
@ -13,10 +14,8 @@ import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.domain.User; import io.metersphere.system.domain.*;
import io.metersphere.system.domain.UserExample; import io.metersphere.system.mapper.CustomFieldMapper;
import io.metersphere.system.domain.UserRoleRelation;
import io.metersphere.system.domain.UserRoleRelationExample;
import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleRelationMapper; import io.metersphere.system.mapper.UserRoleRelationMapper;
import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.notice.constants.NoticeConstants;
@ -59,6 +58,8 @@ public class NoticeMessageTaskService {
private ProjectMapper projectMapper; private ProjectMapper projectMapper;
@Resource @Resource
private ExtProjectUserRoleMapper extProjectUserRoleMapper; private ExtProjectUserRoleMapper extProjectUserRoleMapper;
@Resource
protected CustomFieldMapper customFieldMapper;
public static final String USER_IDS = "user_ids"; public static final String USER_IDS = "user_ids";
@ -287,6 +288,28 @@ public class NoticeMessageTaskService {
return map; return map;
} }
/**
* 获取自定义字段的解释
*
* @return Map<String, String>
*/
public Map<String, String> getCustomFielddMap(String projectId) {
Map<String, String> customFielddMap = new HashMap<>();
List<String> sceneList = new ArrayList<>();
sceneList.add(TemplateScene.API.toString());
sceneList.add(TemplateScene.TEST_PLAN.toString());
sceneList.add(TemplateScene.FUNCTIONAL.toString());
sceneList.add(TemplateScene.BUG.toString());
sceneList.add(TemplateScene.UI.toString());
CustomFieldExample example = new CustomFieldExample();
example.createCriteria().andScopeIdEqualTo(projectId).andSceneIn(sceneList);
List<CustomField> customFields = customFieldMapper.selectByExample(example);
for (CustomField customField : customFields) {
customFielddMap.put(customField.getName(), StringUtils.isBlank(customField.getRemark()) ? "-" : customField.getRemark());
}
return customFielddMap;
}
/** /**
* 根据项目id 获取当前项目的消息设置 * 根据项目id 获取当前项目的消息设置
* *
@ -337,6 +360,7 @@ public class NoticeMessageTaskService {
Map<String, String> eventMap = MessageTemplateUtils.getEventMap(); Map<String, String> eventMap = MessageTemplateUtils.getEventMap();
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap(); Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
Map<String, String> defaultTemplateSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap(); Map<String, String> defaultTemplateSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();
Map<String, String> customFielddMap = getCustomFielddMap(projectId);
ProjectRobot projectRobot = getDefaultRobot(projectId, null); ProjectRobot projectRobot = getDefaultRobot(projectId, null);
for (MessageTaskDTO messageTaskDTO : messageTaskDTOList) { for (MessageTaskDTO messageTaskDTO : messageTaskDTOList) {
messageTaskDTO.setProjectId(projectId); messageTaskDTO.setProjectId(projectId);
@ -356,7 +380,7 @@ public class NoticeMessageTaskService {
String defaultTemplate = defaultTemplateMap.get(messageTaskTypeDTO.getTaskType() + "_" + messageTaskDetailDTO.getEvent()); String defaultTemplate = defaultTemplateMap.get(messageTaskTypeDTO.getTaskType() + "_" + messageTaskDetailDTO.getEvent());
if (CollectionUtils.isEmpty(messageTaskList)) { if (CollectionUtils.isEmpty(messageTaskList)) {
String defaultSubject = defaultTemplateSubjectMap.get(messageTaskTypeDTO.getTaskType() + "_" + messageTaskDetailDTO.getEvent()); String defaultSubject = defaultTemplateSubjectMap.get(messageTaskTypeDTO.getTaskType() + "_" + messageTaskDetailDTO.getEvent());
ProjectRobotConfigDTO projectRobotConfigDTO = getDefaultProjectRobotConfigDTO(messageTaskTypeDTO.getTaskType(), defaultTemplate, defaultSubject, projectRobot); ProjectRobotConfigDTO projectRobotConfigDTO = getDefaultProjectRobotConfigDTO(messageTaskTypeDTO.getTaskType(), defaultTemplate, defaultSubject, projectRobot, customFielddMap);
projectRobotConfigMap.put(projectRobot.getId(), projectRobotConfigDTO); projectRobotConfigMap.put(projectRobot.getId(), projectRobotConfigDTO);
} else { } else {
for (MessageTask messageTask : messageTaskList) { for (MessageTask messageTask : messageTaskList) {
@ -372,7 +396,7 @@ public class NoticeMessageTaskService {
} else { } else {
defaultSubject = defaultTemplateSubjectMap.get(messageTaskTypeDTO.getTaskType() + "_" + messageTaskDetailDTO.getEvent()); defaultSubject = defaultTemplateSubjectMap.get(messageTaskTypeDTO.getTaskType() + "_" + messageTaskDetailDTO.getEvent());
} }
ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, robotMap.get(messageTask.getProjectRobotId()), messageTask, messageTaskBlob); ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, robotMap.get(messageTask.getProjectRobotId()), messageTask, messageTaskBlob, customFielddMap);
projectRobotConfigMap.put(messageTask.getProjectRobotId(), projectRobotConfigDTO); projectRobotConfigMap.put(messageTask.getProjectRobotId(), projectRobotConfigDTO);
} }
} }
@ -385,9 +409,9 @@ public class NoticeMessageTaskService {
return messageTaskDTOList; return messageTaskDTOList;
} }
private ProjectRobotConfigDTO getProjectRobotConfigDTO(String defaultTemplate, String defaultSubject, ProjectRobot projectRobot, MessageTask messageTask, MessageTaskBlob messageTaskBlob) { private ProjectRobotConfigDTO getProjectRobotConfigDTO(String defaultTemplate, String defaultSubject, ProjectRobot projectRobot, MessageTask messageTask, MessageTaskBlob messageTaskBlob, Map<String, String> customFielddMap) {
ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO(); ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO();
if (StringUtils.equalsIgnoreCase(projectRobot.getName(),"robot_in_site") || StringUtils.equalsIgnoreCase(projectRobot.getName(),"robot_mail")) { if (StringUtils.equalsIgnoreCase(projectRobot.getName(), "robot_in_site") || StringUtils.equalsIgnoreCase(projectRobot.getName(), "robot_mail")) {
projectRobotConfigDTO.setRobotName(Translator.get(projectRobot.getName())); projectRobotConfigDTO.setRobotName(Translator.get(projectRobot.getName()));
} else { } else {
projectRobotConfigDTO.setRobotName(projectRobot.getName()); projectRobotConfigDTO.setRobotName(projectRobot.getName());
@ -406,8 +430,8 @@ public class NoticeMessageTaskService {
} else { } else {
projectRobotConfigDTO.setTemplate(messageTaskBlob.getTemplate()); projectRobotConfigDTO.setTemplate(messageTaskBlob.getTemplate());
} }
String translateTemplate = MessageTemplateUtils.getTranslateTemplate(messageTask.getTaskType(), projectRobotConfigDTO.getTemplate()); String translateTemplate = MessageTemplateUtils.getTranslateTemplate(messageTask.getTaskType(), projectRobotConfigDTO.getTemplate(), customFielddMap);
String translateSubject = MessageTemplateUtils.getTranslateSubject(messageTask.getTaskType(), projectRobotConfigDTO.getSubject()); String translateSubject = MessageTemplateUtils.getTranslateSubject(messageTask.getTaskType(), projectRobotConfigDTO.getSubject(), customFielddMap);
projectRobotConfigDTO.setPreviewTemplate(translateTemplate); projectRobotConfigDTO.setPreviewTemplate(translateTemplate);
projectRobotConfigDTO.setPreviewSubject(translateSubject); projectRobotConfigDTO.setPreviewSubject(translateSubject);
projectRobotConfigDTO.setDefaultTemplate(defaultTemplate); projectRobotConfigDTO.setDefaultTemplate(defaultTemplate);
@ -417,7 +441,7 @@ public class NoticeMessageTaskService {
return projectRobotConfigDTO; return projectRobotConfigDTO;
} }
private static ProjectRobotConfigDTO getDefaultProjectRobotConfigDTO(String taskType, String defaultTemplate, String defaultSubject, ProjectRobot projectRobot) { private static ProjectRobotConfigDTO getDefaultProjectRobotConfigDTO(String taskType, String defaultTemplate, String defaultSubject, ProjectRobot projectRobot, Map<String, String> customFielddMap) {
ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO(); ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO();
projectRobotConfigDTO.setRobotId(projectRobot.getId()); projectRobotConfigDTO.setRobotId(projectRobot.getId());
projectRobotConfigDTO.setRobotName(Translator.get(projectRobot.getName())); projectRobotConfigDTO.setRobotName(Translator.get(projectRobot.getName()));
@ -430,8 +454,8 @@ public class NoticeMessageTaskService {
projectRobotConfigDTO.setDefaultSubject(defaultSubject); projectRobotConfigDTO.setDefaultSubject(defaultSubject);
projectRobotConfigDTO.setUseDefaultSubject(true); projectRobotConfigDTO.setUseDefaultSubject(true);
projectRobotConfigDTO.setUseDefaultTemplate(true); projectRobotConfigDTO.setUseDefaultTemplate(true);
String translateTemplate = MessageTemplateUtils.getTranslateTemplate(taskType, defaultTemplate); String translateTemplate = MessageTemplateUtils.getTranslateTemplate(taskType, defaultTemplate, customFielddMap);
String translateSubject = MessageTemplateUtils.getTranslateSubject(taskType, defaultSubject); String translateSubject = MessageTemplateUtils.getTranslateSubject(taskType, defaultSubject, customFielddMap);
projectRobotConfigDTO.setPreviewTemplate(translateTemplate); projectRobotConfigDTO.setPreviewTemplate(translateTemplate);
projectRobotConfigDTO.setPreviewSubject(translateSubject); projectRobotConfigDTO.setPreviewSubject(translateSubject);
return projectRobotConfigDTO; return projectRobotConfigDTO;
@ -455,6 +479,7 @@ public class NoticeMessageTaskService {
List<MessageTask> messageTasks = messageTaskMapper.selectByExample(messageTaskExample); List<MessageTask> messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap(); Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
Map<String, String> defaultTemplateSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap(); Map<String, String> defaultTemplateSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();
Map<String, String> customFielddMap = getCustomFielddMap(projectId);
ProjectRobot projectRobot = projectRobotMapper.selectByPrimaryKey(robotId); ProjectRobot projectRobot = projectRobotMapper.selectByPrimaryKey(robotId);
MessageTask messageTask; MessageTask messageTask;
if (projectRobot == null) { if (projectRobot == null) {
@ -484,7 +509,7 @@ public class NoticeMessageTaskService {
MessageTaskBlob messageTaskBlob = messageTaskBlobMapper.selectByPrimaryKey(messageTask.getId()); MessageTaskBlob messageTaskBlob = messageTaskBlobMapper.selectByPrimaryKey(messageTask.getId());
String defaultTemplate = defaultTemplateMap.get(messageTask.getTaskType() + "_" + messageTask.getEvent()); String defaultTemplate = defaultTemplateMap.get(messageTask.getTaskType() + "_" + messageTask.getEvent());
String defaultSubject = defaultTemplateSubjectMap.get(messageTask.getTaskType() + "_" + messageTask.getEvent()); String defaultSubject = defaultTemplateSubjectMap.get(messageTask.getTaskType() + "_" + messageTask.getEvent());
ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, projectRobot, messageTask, messageTaskBlob); ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, projectRobot, messageTask, messageTaskBlob, customFielddMap);
MessageTemplateConfigDTO messageTemplateConfigDTO = new MessageTemplateConfigDTO(); MessageTemplateConfigDTO messageTemplateConfigDTO = new MessageTemplateConfigDTO();
BeanUtils.copyBean(messageTemplateConfigDTO, projectRobotConfigDTO); BeanUtils.copyBean(messageTemplateConfigDTO, projectRobotConfigDTO);
Map<String, String> taskTypeMap = MessageTemplateUtils.getTaskTypeMap(); Map<String, String> taskTypeMap = MessageTemplateUtils.getTaskTypeMap();

View File

@ -5,11 +5,11 @@ import io.metersphere.bug.domain.Bug;
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;
import io.metersphere.sdk.dto.ApiDefinitionCaseDTO;
import io.metersphere.sdk.dto.FunctionalCaseMessageDTO;
import io.metersphere.project.dto.MessageTemplateFieldDTO; import io.metersphere.project.dto.MessageTemplateFieldDTO;
import io.metersphere.project.dto.MessageTemplateResultDTO; import io.metersphere.project.dto.MessageTemplateResultDTO;
import io.metersphere.sdk.constants.TemplateScene; import io.metersphere.sdk.constants.TemplateScene;
import io.metersphere.sdk.dto.ApiDefinitionCaseDTO;
import io.metersphere.sdk.dto.FunctionalCaseMessageDTO;
import io.metersphere.sdk.dto.OptionDTO; import io.metersphere.sdk.dto.OptionDTO;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.CustomField; import io.metersphere.system.domain.CustomField;
@ -164,9 +164,9 @@ public class NoticeTemplateService {
messageTemplateFieldDTOS.add(messageTemplateFieldFollow); messageTemplateFieldDTOS.add(messageTemplateFieldFollow);
MessageTemplateFieldDTO messageTemplateFieldTriggerMode = new MessageTemplateFieldDTO(); MessageTemplateFieldDTO messageTemplateFieldTriggerMode = new MessageTemplateFieldDTO();
messageTemplateFieldTriggerMode.setId("TRIGGER_MODE"); messageTemplateFieldTriggerMode.setId("TRIGGER_MODE");
messageTemplateFieldOperator.setFieldSource(NoticeConstants.FieldSource.CASE_FIELD); messageTemplateFieldTriggerMode.setFieldSource(NoticeConstants.FieldSource.CASE_FIELD);
messageTemplateFieldOperator.setName(Translator.get("message.trigger_mode")); messageTemplateFieldTriggerMode.setName(Translator.get("message.trigger_mode"));
messageTemplateFieldDTOS.add(messageTemplateFieldOperator); messageTemplateFieldDTOS.add(messageTemplateFieldTriggerMode);
} }
public MessageTemplateResultDTO getTemplateFields(String projectId, String taskType) { public MessageTemplateResultDTO getTemplateFields(String projectId, String taskType) {

View File

@ -487,10 +487,22 @@ public interface NoticeConstants {
} }
interface SensitiveField { interface SensitiveField {
String id = "id";
String deleted = "deleted"; String deleted = "deleted";
String refId = "refId"; String refId = "refId";
String latest = "latest";
String versionId = "versionId"; String versionId = "versionId";
String reportId = "reportId"; String reportId = "reportId";
String moduleId = "moduleId"; String moduleId = "moduleId";
String lastReportId = "lastReportId";
String pos = "pos";
String customNum = "customNum";
String projectId = "projectId";
String apiScenarioModuleId = "apiScenarioModuleId";
String parentId = "parentId";
String trash = "trash";
String templateId = "templateId";
String testResourcePoolId = "testResourcePoolId";
String resourceId = "resourceId";
} }
} }

View File

@ -124,6 +124,7 @@ public class MessageTemplateUtils {
/** /**
* 获取字段来源 * 获取字段来源
*
* @return FieldSourceMap * @return FieldSourceMap
*/ */
public static Map<String, String> getFieldSourceMap() { public static Map<String, String> getFieldSourceMap() {
@ -196,41 +197,100 @@ public class MessageTemplateUtils {
}); });
} }
public static String getTranslateTemplate(String taskType, String template) { public static String getTranslateTemplate(String taskType, String template, Map<String, String> customFielddMap) {
if (StringUtils.equalsIgnoreCase(taskType, NoticeConstants.TaskType.JENKINS_TASK)) { if (StringUtils.equalsIgnoreCase(taskType, NoticeConstants.TaskType.JENKINS_TASK)) {
if (StringUtils.isNotBlank(template) && template.contains("${name}")) { if (StringUtils.isNotBlank(template) && template.contains("${name}")) {
template = template.replace("${name}", "<"+Translator.get("message.jenkins_name")+">"); template = template.replace("${name}", "{{" + Translator.get("message.jenkins_name") + "}}");
} }
return template; return template;
} else { } else {
Field[] domainTemplateFields = getDomainTemplateFields(taskType); Field[] domainTemplateFields = getDomainTemplateFields(taskType);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (StringUtils.isNotBlank(template) && template.contains("${OPERATOR}")) { if (StringUtils.isNotBlank(template) && template.contains("${OPERATOR}")) {
template = template.replace("${OPERATOR}", "<"+Translator.get("message.operator")+">"); template = template.replace("${OPERATOR}", "<" + Translator.get("message.operator") + ">");
} }
if (StringUtils.isNotBlank(template) && template.contains("${total}")) { if (StringUtils.isNotBlank(template) && template.contains("${total}")) {
template = template.replace("${total}", "<n>"); template = template.replace("${total}", "<n>");
} }
for (Field allField : domainTemplateFields) { setMap(taskType, domainTemplateFields, map);
Schema annotation = allField.getAnnotation(Schema.class); Map<String, String> defaultRelatedUserMap = getDefaultRelatedUserMap();
if (annotation != null) { map.putAll(defaultRelatedUserMap);
String description = annotation.description(); map.putAll(customFielddMap);
if (StringUtils.equals(allField.getName(), "name") || StringUtils.equals(allField.getName(), "title")) {
description = "{{" + description + "}}";
} else {
description = "<" + description + ">";
}
map.put(allField.getName(), description);
}
}
return getContent(template, map); return getContent(template, map);
} }
} }
public static String getTranslateSubject(String taskType, String subject) { private static void setMap(String taskType, Field[] domainTemplateFields, Map<String, Object> 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 ->{}
}
}
private static void putDomainName(Field[] domainTemplateFields, Map<String, Object> map, String tableName) {
for (Field allField : domainTemplateFields) {
Schema annotation = allField.getAnnotation(Schema.class);
if (annotation != null) {
String description;
if (StringUtils.equals(allField.getName(), "name") || StringUtils.equals(allField.getName(), "title")) {
description = "{{" + Translator.get("message.domain."+ tableName +allField.getName()) + "}}";
} else {
description = "<" + Translator.get("message.domain."+ tableName +allField.getName()) + ">";
}
map.put(allField.getName(), description);
}
}
}
private static void putDescription(Field[] domainTemplateFields, Map<String, Object> map) {
for (Field allField : domainTemplateFields) {
Schema annotation = allField.getAnnotation(Schema.class);
if (annotation != null) {
String description = annotation.description();
if (StringUtils.equals(allField.getName(), "name") || StringUtils.equals(allField.getName(), "title")) {
description = "{{" + description + "}}";
} else {
description = "<" + description + ">";
}
map.put(allField.getName(), description);
}
}
}
public static String getTranslateSubject(String taskType, String subject, Map<String, String> customFielddMap) {
if (StringUtils.equalsIgnoreCase(taskType, NoticeConstants.TaskType.JENKINS_TASK)) { if (StringUtils.equalsIgnoreCase(taskType, NoticeConstants.TaskType.JENKINS_TASK)) {
if (StringUtils.isNotBlank(subject) && subject.contains("${name}")) { if (StringUtils.isNotBlank(subject) && subject.contains("${name}")) {
subject = subject.replace("${name}", Translator.get("message.jenkins_name")); subject = subject.replace("${name}", "{{" + Translator.get("message.jenkins_name") + "}}");
} }
return subject; return subject;
} else { } else {
@ -242,17 +302,13 @@ public class MessageTemplateUtils {
if (StringUtils.isNotBlank(subject) && subject.contains("${total}")) { if (StringUtils.isNotBlank(subject) && subject.contains("${total}")) {
subject = subject.replace("${total}", "n"); subject = subject.replace("${total}", "n");
} }
for (Field allField : domainTemplateFields) { setMap(taskType, domainTemplateFields, map);
Schema annotation = allField.getAnnotation(Schema.class); Map<String, String> defaultRelatedUserMap = getDefaultRelatedUserMap();
if (annotation != null) { map.putAll(defaultRelatedUserMap);
String description = annotation.description(); map.putAll(customFielddMap);
if (StringUtils.equals(allField.getName(), "name") || StringUtils.equals(allField.getName(), "title")) {
description = "{{" + description + "}}";
}
map.put(allField.getName(), description);
}
}
return getContent(subject, map); return getContent(subject, map);
} }
} }
} }

View File

@ -1,6 +1,11 @@
package io.metersphere.system.controller; package io.metersphere.system.controller;
import io.metersphere.sdk.constants.TemplateScene;
import io.metersphere.system.domain.CustomField;
import io.metersphere.system.domain.CustomFieldExample;
import io.metersphere.system.mapper.CustomFieldMapper;
import io.metersphere.system.notice.utils.MessageTemplateUtils; import io.metersphere.system.notice.utils.MessageTemplateUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
@ -9,14 +14,14 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Set;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc @AutoConfigureMockMvc
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class MessageTemplateUtilsTests { public class MessageTemplateUtilsTests {
@Resource
protected CustomFieldMapper customFieldMapper;
@Test @Test
@Order(1) @Order(1)
@ -34,6 +39,7 @@ public class MessageTemplateUtilsTests {
Assertions.assertTrue(MapUtils.isNotEmpty(defaultRelatedUserMap)); Assertions.assertTrue(MapUtils.isNotEmpty(defaultRelatedUserMap));
Map<String, String> fieldSourceMap = MessageTemplateUtils.getFieldSourceMap(); Map<String, String> fieldSourceMap = MessageTemplateUtils.getFieldSourceMap();
Assertions.assertTrue(MapUtils.isNotEmpty(fieldSourceMap)); Assertions.assertTrue(MapUtils.isNotEmpty(fieldSourceMap));
Map<String, String> customFielddMap = getCustomFielddMap("100001100001");
for (String type : typeList) { for (String type : typeList) {
Field[] domainTemplateFields = MessageTemplateUtils.getDomainTemplateFields(type); Field[] domainTemplateFields = MessageTemplateUtils.getDomainTemplateFields(type);
Assertions.assertNotNull(domainTemplateFields); Assertions.assertNotNull(domainTemplateFields);
@ -41,9 +47,9 @@ public class MessageTemplateUtilsTests {
eventMap.forEach((event, name) -> { eventMap.forEach((event, name) -> {
String template = defaultTemplateMap.get(type + "_" + event); String template = defaultTemplateMap.get(type + "_" + event);
if (StringUtils.isNotBlank(template)) { if (StringUtils.isNotBlank(template)) {
String translateTemplate = MessageTemplateUtils.getTranslateTemplate(type, template); String translateTemplate = MessageTemplateUtils.getTranslateTemplate(type, template, customFielddMap);
Assertions.assertTrue(StringUtils.isNotBlank(translateTemplate)); Assertions.assertTrue(StringUtils.isNotBlank(translateTemplate));
String translateSubject= MessageTemplateUtils.getTranslateSubject(type, template); String translateSubject= MessageTemplateUtils.getTranslateSubject(type, template, customFielddMap);
Assertions.assertTrue(StringUtils.isNotBlank(translateSubject)); Assertions.assertTrue(StringUtils.isNotBlank(translateSubject));
} }
}); });
@ -51,4 +57,26 @@ public class MessageTemplateUtilsTests {
} }
} }
/**
* 获取自定义字段的解释
*
* @return Map<String, String>
*/
public Map<String, String> getCustomFielddMap(String projectId) {
Map<String, String> customFielddMap = new HashMap<>();
List<String> sceneList = new ArrayList<>();
sceneList.add(TemplateScene.API.toString());
sceneList.add(TemplateScene.TEST_PLAN.toString());
sceneList.add(TemplateScene.FUNCTIONAL.toString());
sceneList.add(TemplateScene.BUG.toString());
sceneList.add(TemplateScene.UI.toString());
CustomFieldExample example = new CustomFieldExample();
example.createCriteria().andScopeIdEqualTo(projectId).andSceneIn(sceneList);
List<CustomField> customFields = customFieldMapper.selectByExample(example);
for (CustomField customField : customFields) {
customFielddMap.put(customField.getName(), org.apache.commons.lang3.StringUtils.isBlank(customField.getRemark()) ? "-" : customField.getRemark());
}
return customFielddMap;
}
} }