fix(接口测试): 修复定时任务发送显示英文的缺陷

--bug=1039397 --user=王孝刚 【项目管理】接口测试-消息设置,站内信-场景执行失败,执行误报,执行成功显示英文
https://www.tapd.cn/55049933/s/1502448
This commit is contained in:
wxg0103 2024-04-19 17:26:18 +08:00 committed by Craftsman
parent 9f382f8856
commit 332cf2c277
4 changed files with 13 additions and 2 deletions

View File

@ -115,6 +115,7 @@ public class ApiReportSendNoticeService {
User user = userMapper.selectByPrimaryKey(userId); User user = userMapper.selectByPrimaryKey(userId);
Map paramMap = new HashMap<>(beanMap); Map paramMap = new HashMap<>(beanMap);
noticeSendService.setLanguage(user.getLanguage());
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user != null ? user.getName() : ""); paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user != null ? user.getName() : "");
// TODO 是否需要国际化 根据状态判断给不同的key // TODO 是否需要国际化 根据状态判断给不同的key
String status = paramMap.containsKey("status") ? paramMap.get("status").toString() : null; String status = paramMap.containsKey("status") ? paramMap.get("status").toString() : null;
@ -182,5 +183,4 @@ public class ApiReportSendNoticeService {
noticeSendService.send(project, noticeType, noticeModel); noticeSendService.send(project, noticeType, noticeModel);
} }
} }

View File

@ -131,7 +131,7 @@ public class TaskCenterController {
@CheckOwner(resourceId = "#id", resourceType = "schedule") @CheckOwner(resourceId = "#id", resourceType = "schedule")
public void updateProject(@PathVariable String moduleType, @PathVariable String id, @RequestBody Object cron) { public void updateProject(@PathVariable String moduleType, @PathVariable String id, @RequestBody Object cron) {
hasPermission(PROJECT, moduleType); hasPermission(PROJECT, moduleType);
taskCenterService.update(id, cron.toString(), SessionUtils.getUserId(), "/task/center/project/schedule/update/", OperationLogModule.PROJECT_PROJECT_MANAGER); taskCenterService.update(id, cron.toString(), SessionUtils.getUserId(), "/task/center/project/schedule/update/", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
} }
@PostMapping("/system/schedule/batch-enable") @PostMapping("/system/schedule/batch-enable")

View File

@ -40,6 +40,7 @@ public class ApiScheduleNoticeService {
BeanMap beanMap = new BeanMap(schedule); BeanMap beanMap = new BeanMap(schedule);
Map paramMap = new HashMap<>(beanMap); Map paramMap = new HashMap<>(beanMap);
User user = userMapper.selectByPrimaryKey(userId); User user = userMapper.selectByPrimaryKey(userId);
noticeSendService.setLanguage(user.getLanguage());
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user != null ? user.getName() : ""); paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user != null ? user.getName() : "");
String template = defaultTemplateMap.get(NoticeConstants.TaskType.SCHEDULE_TASK + "_" + event); String template = defaultTemplateMap.get(NoticeConstants.TaskType.SCHEDULE_TASK + "_" + event);
Map<String, String> defaultSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap(); Map<String, String> defaultSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();

View File

@ -93,6 +93,16 @@ public class NoticeSendService {
LocaleContextHolder.setLocale(locale); LocaleContextHolder.setLocale(locale);
} }
public void setLanguage(String language) {
Locale locale = Locale.SIMPLIFIED_CHINESE;
if (StringUtils.containsIgnoreCase("US",language)) {
locale = Locale.US;
} else if (StringUtils.containsIgnoreCase("TW",language)){
locale = Locale.TAIWAN;
}
LocaleContextHolder.setLocale(locale);
}
/** /**
* jenkins 和定时任务触发的发送 * jenkins 和定时任务触发的发送
*/ */