Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 70681bef
由
LN
编写于
2021-12-15 09:54:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
切换为使用数据库资源
1 个父辈
f7356bfd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
47 行增加
和
46 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
70681be
...
...
@@ -71,7 +71,7 @@ public class DataInitManager {
role
=
roleManager
.
save
(
role
);
log
.
info
(
"创建默认角色:"
+
role
.
toString
());
admin
=
new
User
(
userName
,
"admin@qq.com"
,
"zh"
,
role
.
getId
(),
"$2a$10$Egp1/gvFlt7zhlXVfEFw4OfWQCGPw0ClmMcc6FjTnvXNRVf9zdMRa"
,
true
,
true
,
new
Date
(),
groupIds
,
""
);
admin
=
new
User
(
userName
,
"admin@qq.com"
,
"zh
-CN
"
,
role
.
getId
(),
"$2a$10$Egp1/gvFlt7zhlXVfEFw4OfWQCGPw0ClmMcc6FjTnvXNRVf9zdMRa"
,
true
,
true
,
new
Date
(),
groupIds
,
""
);
userManager
.
save
(
admin
);
log
.
info
(
"创建默认用户:"
+
admin
.
toString
());
...
...
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
查看文件 @
70681be
...
...
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import
javax.annotation.PostConstruct
;
import
java.io.*
;
import
java.text.MessageFormat
;
import
java.util.*
;
/**
...
...
@@ -22,9 +23,9 @@ import java.util.*;
public
class
MessageUtils
{
//-----------------以下为从配置文件读取资源-------------------------------------
public
static
Locale
getDefaultLocal
(){
return
new
Locale
(
"zh-CH"
);
}
//
public static Locale getDefaultLocal(){
//
return new Locale("zh-CH");
//
}
private
static
MessageSource
messageSource
;
...
...
@@ -32,25 +33,25 @@ public class MessageUtils {
MessageUtils
.
messageSource
=
messageSource
;
}
public
static
String
getText
(
String
msgKey
,
Locale
locale
,
String
defaultMsg
)
{
return
getText
(
msgKey
,
null
,
locale
,
defaultMsg
);
}
public
static
String
getText
(
String
msgKey
,
String
[]
params
,
Locale
locale
,
String
defaultMsg
)
{
try
{
if
(
params
==
null
)
{
return
messageSource
.
getMessage
(
msgKey
,
new
String
[]{},
locale
);
}
else
{
return
messageSource
.
getMessage
(
msgKey
,
params
,
locale
);
}
}
catch
(
Exception
ex
){
log
.
error
(
"获取资源["
+
msgKey
+
"]["
+
defaultMsg
+
"]["
+
locale
.
getLanguage
()+
"]出错:"
+
ex
.
toString
());
if
(
defaultMsg
!=
null
){
return
defaultMsg
;
}
return
msgKey
;
}
}
//
public static String getText(String msgKey, Locale locale,String defaultMsg) {
//
return getText(msgKey,null, locale,defaultMsg);
//
}
//
//
public static String getText(String msgKey, String[] params, Locale locale, String defaultMsg) {
//
try{
//
if (params == null) {
//
return messageSource.getMessage(msgKey, new String[]{}, locale);
//
} else {
//
return messageSource.getMessage(msgKey,params, locale);
//
}
//
}catch (Exception ex){
//
log.error("获取资源["+msgKey+"]["+defaultMsg+"]["+locale.getLanguage()+"]出错:"+ex.toString());
//
if(defaultMsg != null){
//
return defaultMsg;
//
}
//
return msgKey;
//
}
//
}
//-------------------------------------------------------------------------------
...
...
@@ -86,29 +87,29 @@ public class MessageUtils {
// }
//
public static Locale getDefaultLocal(){
//
return new Locale("zh-CH");
//
}
//
public static String getText(String msgKey, Locale locale,String defaultMsg) {
//
return getText(msgKey,null, locale,defaultMsg);
//
}
//
//
public static String getText(String msgKey, String[] params, Locale locale, String defaultMsg) {
//
try{
//
String msg=getMessage(msgKey,locale.toLanguageTag(),defaultMsg);
//
if (params == null) {
//
return msg;
//
} else {
//
return MessageFormat.format(msg,params);
//
}
//
}catch (Exception ex){
//
log.error("获取资源["+msgKey+"]["+defaultMsg+"]["+locale.getLanguage()+"]出错:"+ex.toString());
//
if(defaultMsg != null){
//
return defaultMsg;
//
}
//
return msgKey;
//
}
//
}
public
static
Locale
getDefaultLocal
(){
return
new
Locale
(
"zh-CH"
);
}
public
static
String
getText
(
String
msgKey
,
Locale
locale
,
String
defaultMsg
)
{
return
getText
(
msgKey
,
null
,
locale
,
defaultMsg
);
}
public
static
String
getText
(
String
msgKey
,
String
[]
params
,
Locale
locale
,
String
defaultMsg
)
{
try
{
String
msg
=
getMessage
(
msgKey
,
locale
.
toLanguageTag
(),
defaultMsg
);
if
(
params
==
null
)
{
return
msg
;
}
else
{
return
MessageFormat
.
format
(
msg
,
params
);
}
}
catch
(
Exception
ex
){
log
.
error
(
"获取资源["
+
msgKey
+
"]["
+
defaultMsg
+
"]["
+
locale
.
getLanguage
()+
"]出错:"
+
ex
.
toString
());
if
(
defaultMsg
!=
null
){
return
defaultMsg
;
}
return
msgKey
;
}
}
private
static
String
getMessage
(
String
msgKey
,
String
lanType
,
String
defaultMsg
)
{
if
(
msgMap
!=
null
)
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论