fix(项目管理): 修复发送邮件通知标题语言环境获取问题
This commit is contained in:
parent
e3499e11c2
commit
8778a78db9
|
@ -10,6 +10,7 @@ import io.metersphere.system.service.NoticeSendService;
|
||||||
import io.metersphere.system.service.SystemParameterService;
|
import io.metersphere.system.service.SystemParameterService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ public class AfterReturningNoticeSendService {
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendNotice(String taskType, String event, List<Map> resources, SessionUser sessionUser, String currentProjectId) {
|
public void sendNotice(String taskType, String event, List<Map> resources, SessionUser sessionUser, String currentProjectId) {
|
||||||
|
setLanguage(sessionUser.getLanguage());
|
||||||
// 有批量操作发送多次
|
// 有批量操作发送多次
|
||||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||||
for (Map resource : resources) {
|
for (Map resource : resources) {
|
||||||
|
@ -73,6 +74,16 @@ public class AfterReturningNoticeSendService {
|
||||||
return defaultTemplateTitleMap.get(taskType + "_" + event);
|
return defaultTemplateTitleMap.get(taskType + "_" + event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有些默认的值,避免通知里出现 ${key}
|
* 有些默认的值,避免通知里出现 ${key}
|
||||||
|
|
Loading…
Reference in New Issue