Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 73e9a9ae
由
LN
编写于
2021-12-16 09:09:05 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加csv文件导入功能。语言设置增加名称和图标字段。
1 个父辈
746e03c3
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
215 行增加
和
136 行删除
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
src/main/java/com/neotel/smfcore/core/language/rest/LanguageMsgController.java
src/main/java/com/neotel/smfcore/core/language/rest/LanguageSetController.java
src/main/java/com/neotel/smfcore/core/language/service/nanager/impl/LanguageMsgManagerImpl.java
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
查看文件 @
73e9a9a
...
...
@@ -10,6 +10,9 @@ import com.neotel.smfcore.common.utils.StringUtils;
import
com.neotel.smfcore.common.utils.YmlUpdateUtil
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
com.neotel.smfcore.core.storage.bean.InventoryItem
;
import
com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
...
...
@@ -102,6 +105,15 @@ public class DataCache {
return
null
;
}
public
List
<
LanguageInfo
>
getLanguageList
(){
List
<
LanguageInfo
>
lanList
=
getCache
(
Constants
.
CACHE_languageType
);
if
(
lanList
==
null
||
lanList
.
size
()
<=
0
)
{
lanList
=
MessageUtils
.
getDefaultLanList
();
updateCache
(
Constants
.
CACHE_languageType
,
lanList
);
}
return
lanList
;
}
/**
* 更新缓存信息
*/
...
...
src/main/java/com/neotel/smfcore/core/language/rest/LanguageMsgController.java
查看文件 @
73e9a9a
...
...
@@ -3,9 +3,11 @@ package com.neotel.smfcore.core.language.rest;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.csv.CsvReader
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.FileUtil
;
import
com.neotel.smfcore.common.utils.Md5Utls
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.rest.bean.dto.LanguageMsgDto
;
...
...
@@ -13,15 +15,18 @@ import com.neotel.smfcore.core.language.rest.bean.dto.LanguageResourceDto;
import
com.neotel.smfcore.core.language.rest.bean.mapstruct.LanguageMsgMapper
;
import
com.neotel.smfcore.core.language.rest.bean.query.LanguageMsgCriteria
;
import
com.neotel.smfcore.core.language.service.bean.Content
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.bean.FileProperties
;
import
com.neotel.smfcore.security.service.po.User
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.mapstruct.ap.shaded.freemarker.ext.beans.HashAdapter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.core.query.Criteria
;
...
...
@@ -54,18 +59,15 @@ public class LanguageMsgController {
@Autowired
DataCache
dataCache
;
public
List
<
String
>
getAllLanList
()
{
public
List
<
String
>
getAllLanList
()
{
List
<
String
>
lanList
=
dataCache
.
getCache
(
Constants
.
CACHE_languageType
);
if
(
lanList
==
null
||
lanList
.
size
()
<=
0
)
{
lanList
=
new
ArrayList
<>();
lanList
.
add
(
MessageUtils
.
ZH_CN
);
lanList
.
add
(
MessageUtils
.
ZH_TW
);
lanList
.
add
(
MessageUtils
.
EN_US
);
lanList
.
add
(
MessageUtils
.
JA_JP
);
dataCache
.
updateCache
(
Constants
.
CACHE_languageType
,
lanList
);
List
<
LanguageInfo
>
lanList
=
dataCache
.
getLanguageList
();
List
<
String
>
list
=
new
ArrayList
<>();
for
(
LanguageInfo
lan
:
lanList
)
{
list
.
add
(
lan
.
getLanCode
());
}
return
l
anL
ist
;
return
list
;
}
...
...
@@ -73,14 +75,15 @@ public class LanguageMsgController {
@PostMapping
(
value
=
"/upload"
)
public
ResultBean
upload
(
@RequestParam
MultipartFile
uploadFile
)
throws
Exception
{
// 验证文件上传的格式
String
smfco
d
eType
=
"properties"
;
String
smfco
r
eType
=
"properties"
;
String
smfclientType
=
"js"
;
String
csvType
=
"csv"
;
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
if
(
fileType
==
null
)
{
throw
new
ValidateException
(
"smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
smfclientType
+
"/"
+
smfcod
eType
});
throw
new
ValidateException
(
"smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
csvType
+
"/"
+
smfclientType
+
"/"
+
smfcor
eType
});
}
if
((!
smfclientType
.
contains
(
fileType
))
&&
!
smfco
de
Type
.
contains
(
fileType
))
{
throw
new
ValidateException
(
"smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
smfclientType
+
"/"
+
smfcod
eType
});
if
((!
smfclientType
.
contains
(
fileType
))
&&
!
smfco
reType
.
contains
(
fileType
)
&&
!
csv
Type
.
contains
(
fileType
))
{
throw
new
ValidateException
(
"smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
csvType
+
"/"
+
smfclientType
+
"/"
+
smfcor
eType
});
}
File
folder
=
new
File
(
properties
.
getPath
(),
"resource"
);
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
...
...
@@ -92,10 +95,14 @@ public class LanguageMsgController {
//客户端js文件处理
Map
<
String
,
String
>
proMap
=
readJsFile
(
file
);
resultMsg
=
ResourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
"smfclient"
);
}
else
if
(
smfco
d
eType
.
contains
(
fileType
))
{
}
else
if
(
smfco
r
eType
.
contains
(
fileType
))
{
Map
<
String
,
String
>
proMap
=
MessageUtils
.
ReadPropertiesFile
(
file
);
resultMsg
=
ResourceUpload
(
uploadFile
.
getOriginalFilename
(),
proMap
,
lanType
,
""
);
}
if
(
csvType
.
equals
(
fileType
)){
List
<
LanguageMsg
>
list
=
CsvFileRead
(
file
.
getAbsolutePath
());
msgListUpload
(
list
);
}
return
ResultBean
.
newOkResult
(
resultMsg
);
}
...
...
@@ -118,6 +125,7 @@ public class LanguageMsgController {
query
.
addCriteria
(
Criteria
.
where
(
proName
).
exists
(
false
));
}
}
List
<
LanguageMsg
>
list
=
languageMsgManager
.
findByQuery
(
query
);
//下载
languageMsgManager
.
download
(
list
,
response
);
...
...
@@ -413,66 +421,130 @@ public class LanguageMsgController {
}
// private void msgListUpload(String type, List<LanguageMsg> msgList) {
//
// List<LanguageMsg> newLanguageList = new ArrayList<>();
// List<LanguageMsg> updateLanguageList = new ArrayList<>();
// for (LanguageMsg msg :
// msgList) {
// msg.setType(type);
// if(ObjectUtil.isEmpty(msg.getCode())) {
// //code不能为空
// continue;
// }
// if(ObjectUtil.isEmpty(msg.getMsg())){
// //内容不能为空
// continue;
// }
//
// List<Content> contentList = new ArrayList<>();
// for (Content con :
// msg.getContentList()) {
// if (ObjectUtil.isEmpty(con.getLanCode()) || ObjectUtil.isEmpty(con.getMsg())) {
// continue;
// }
// contentList.add(con);
// }
//
//
// //判断是否是新增
// LanguageMsg oldMsg=MessageUtils.getMsg(msg.getCode());
// if(oldMsg==null){
// newLanguageList.add(msg);
// }
// else{
// //只新增不修改
// List<String> allLanList=getAllLanList();
// for (String lanType :
// allLanList) {
// String oldValue= oldMsg.getContent(lanType);
// if(ObjectUtil.isEmpty(oldValue)){
// oldMsg.setContent(lanType,msg.getContent(lanType));
// }
// }
// updateLanguageList.add(oldMsg);
// languageMsgManager.save(oldMsg);
// MessageUtils.updateMsg(oldMsg);
// }
//
// }
//
//
//
// if (newLanguageList.size() > 0) {
// languageMsgManager.insertAll(newLanguageList);
// for (LanguageMsg msg :
// newLanguageList) {
// MessageUtils.updateMsg(msg);
// }
// }
// log.info("导入[" + type + "]类型的资源列表,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源");
//
// }
private
List
<
LanguageMsg
>
CsvFileRead
(
String
fileURL
)
throws
Exception
{
CsvReader
csvRead
=
CsvReader
.
newReader
(
fileURL
,
"编号"
,
"code"
);
int
codeIndex
=
csvRead
.
getCsvIndex
(
"编号"
,
"code"
);
int
typeIndex
=
csvRead
.
getCsvIndex
(
"类型"
,
"type"
);
int
msgIndex
=
csvRead
.
getCsvIndex
(
"内容"
,
"msg"
);
Map
<
String
,
Integer
>
lanCodeIndex
=
new
HashMap
<>()
;
List
<
LanguageInfo
>
languageInfos
=
dataCache
.
getLanguageList
();
for
(
LanguageInfo
lan:
languageInfos
)
{
int
lanIndex
=
csvRead
.
getCsvIndex
(
lan
.
getLanCode
(),
lan
.
getLanName
());
if
(
lanIndex
>=
0
){
lanCodeIndex
.
put
(
lan
.
getLanCode
(),
lanIndex
);
}
}
int
row
=
1
;
int
newRowCount
=
0
;
int
updateRowCount
=
0
;
String
msg
=
""
;
List
<
LanguageMsg
>
list
=
new
ArrayList
<>();
while
(
csvRead
.
readRecord
())
{
row
++;
String
[]
lineValues
=
csvRead
.
getValues
();
LanguageMsg
languageMsg
=
new
LanguageMsg
();
String
code
=
lineValues
[
codeIndex
];
String
type
=
lineValues
[
typeIndex
];
String
msgStr
=
lineValues
[
msgIndex
];
if
(
code
.
isEmpty
()
||
type
.
isEmpty
()
||
msgStr
.
isEmpty
())
{
log
.
warn
(
"第"
+
row
+
"行中有空白内容,此行忽略"
);
continue
;
}
languageMsg
.
setMsg
(
msgStr
);
languageMsg
.
setCode
(
code
);
languageMsg
.
setType
(
type
);
for
(
String
lan
:
lanCodeIndex
.
keySet
())
{
int
lanIndex
=
lanCodeIndex
.
get
(
lan
);
String
lanMsg
=
lineValues
[
lanIndex
];
if
(!
lanMsg
.
isEmpty
()){
languageMsg
.
setContent
(
lan
,
lanMsg
);
}
}
list
.
add
(
languageMsg
);
}
return
list
;
}
private
void
msgListUpload
(
List
<
LanguageMsg
>
msgList
)
{
List
<
LanguageMsg
>
newLanguageList
=
new
ArrayList
<>();
List
<
LanguageMsg
>
updateLanguageList
=
new
ArrayList
<>();
for
(
LanguageMsg
msg
:
msgList
)
{
if
(
ObjectUtil
.
isEmpty
(
msg
.
getCode
()))
{
//code不能为空
continue
;
}
if
(
ObjectUtil
.
isEmpty
(
msg
.
getMsg
())){
//内容不能为空
continue
;
}
if
(
ObjectUtil
.
isEmpty
(
msg
.
getType
())){
//内容不能为空
continue
;
}
List
<
Content
>
contentList
=
new
ArrayList
<>();
for
(
Content
con
:
msg
.
getContentList
())
{
if
(
ObjectUtil
.
isEmpty
(
con
.
getLanCode
())
||
ObjectUtil
.
isEmpty
(
con
.
getMsg
()))
{
continue
;
}
contentList
.
add
(
con
);
}
//判断是否是新增
LanguageMsg
oldMsg
=
MessageUtils
.
getMsg
(
msg
.
getCode
());
if
(
oldMsg
==
null
){
newLanguageList
.
add
(
msg
);
}
else
{
boolean
isUpdate
=
false
;
//只新增不修改
List
<
String
>
allLanList
=
getAllLanList
();
for
(
String
lanType
:
allLanList
)
{
String
oldValue
=
oldMsg
.
getContent
(
lanType
);
if
(
ObjectUtil
.
isEmpty
(
oldValue
)){
oldMsg
.
setContent
(
lanType
,
msg
.
getContent
(
lanType
));
isUpdate
=
true
;
//内容默认更改为中文
if
(
lanType
.
equals
(
MessageUtils
.
ZH_CN
)){
if
(!
oldMsg
.
getMsg
().
equals
(
oldValue
)){
oldMsg
.
setMsg
(
oldValue
);
}
}
}
}
if
(
isUpdate
){
updateLanguageList
.
add
(
oldMsg
);
languageMsgManager
.
save
(
oldMsg
);
MessageUtils
.
updateMsg
(
oldMsg
);
}
}
}
if
(
newLanguageList
.
size
()
>
0
)
{
languageMsgManager
.
insertAll
(
newLanguageList
);
for
(
LanguageMsg
msg
:
newLanguageList
)
{
MessageUtils
.
updateMsg
(
msg
);
}
}
log
.
info
(
"导入csv资源,共["
+
msgList
.
size
()+
"]条数据,共更新["
+
updateLanguageList
.
size
()
+
"]条资源,新增["
+
newLanguageList
.
size
()
+
"]条资源"
);
}
}
src/main/java/com/neotel/smfcore/core/language/rest/LanguageSetController.java
查看文件 @
73e9a9a
...
...
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
@Slf4j
...
...
@@ -34,36 +35,21 @@ public class LanguageSetController {
@Autowired
DataCache
dataCache
;
public
List
<
LanguageInfo
>
getAllLanList
()
{
public
List
<
LanguageInfo
>
getAllLanList
()
{
// List<
String
> lanList = dataCache.getCache(Constants.CACHE_languageType);
// List<
LanguageInfo
> lanList = dataCache.getCache(Constants.CACHE_languageType);
// if (lanList == null || lanList.size() <= 0) {
// lanList=new ArrayList<>();
// lanList.add(MessageUtils.ZH_CN);
// lanList.add(MessageUtils.ZH_TW);
// lanList.add(MessageUtils.EN_US);
// lanList.add(MessageUtils.JA_JP);
// lanList = MessageUtils.getDefaultLanList();
// dataCache.updateCache(Constants.CACHE_languageType, lanList);
// }
// return lanList;
List
<
LanguageInfo
>
lanList
=
dataCache
.
getCache
(
Constants
.
CACHE_languageType
);
if
(
lanList
==
null
||
lanList
.
size
()
<=
0
)
{
lanList
=
new
ArrayList
<>();
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
ZH_CN
,
"简体中文"
,
""
));
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
ZH_TW
,
"简体中文"
,
""
));
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
EN_US
,
"简体中文"
,
""
));
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
JA_JP
,
"简体中文"
,
""
));
dataCache
.
updateCache
(
Constants
.
CACHE_languageType
,
lanList
);
}
return
lanList
;
return
dataCache
.
getLanguageList
();
}
@ApiOperation
(
"获取语言列表"
)
@GetMapping
@PreAuthorize
(
"@el.check('translation')"
)
public
List
<
LanguageInfo
>
getList
(){
return
getAllLanList
();
return
getAllLanList
();
}
@ApiOperation
(
"新增语言"
)
@PostMapping
...
...
@@ -111,12 +97,25 @@ public class LanguageSetController {
}
}
List
<
LanguageInfo
>
newList
=
new
ArrayList
<>();
for
(
LanguageInfo
lan
:
languageTypeList
)
{
if
(
lanCodes
.
contains
(
lan
.
getLanCode
())){
log
.
info
(
"用户["
+
SecurityUtils
.
getCurrentUsername
()+
"] 删除语言:"
+
lan
.
getLanCode
());
}
else
{
//如果是四种默认语言,不能删除
String
lancode
=
lan
.
getLanCode
();
if
(
lancode
.
equals
(
MessageUtils
.
ZH_CN
)
||
lancode
.
equals
(
MessageUtils
.
ZH_TW
)
||
lancode
.
equals
(
MessageUtils
.
JA_JP
)
||
lancode
.
equals
(
MessageUtils
.
EN_US
)
)
{
throw
new
ValidateException
(
"smfcode.canotRemove"
,
"不能删除此语言"
);
}
}
List
<
LanguageInfo
>
newList
=
new
ArrayList
<>();
for
(
LanguageInfo
lan
:
languageTypeList
)
{
if
(
lanCodes
.
contains
(
lan
.
getLanCode
()))
{
log
.
info
(
"用户["
+
SecurityUtils
.
getCurrentUsername
()
+
"] 删除语言:"
+
lan
.
getLanCode
());
}
else
{
newList
.
add
(
lan
);
}
}
...
...
@@ -124,6 +123,7 @@ public class LanguageSetController {
throw
new
ValidateException
(
"smfcode.languageCanotRemoveAll"
,
"不能删除所有语言"
);
}
dataCache
.
updateCache
(
Constants
.
CACHE_languageType
,
newList
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
}
...
...
src/main/java/com/neotel/smfcore/core/language/service/nanager/impl/LanguageMsgManagerImpl.java
查看文件 @
73e9a9a
...
...
@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.service.bean.Content
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.dao.ILanguageMsgDao
;
import
com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
...
...
@@ -64,18 +65,6 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
@Autowired
DataCache
dataCache
;
public
List
<
String
>
getAllLanList
(){
List
<
String
>
lanList
=
dataCache
.
getCache
(
Constants
.
CACHE_languageType
);
if
(
lanList
==
null
||
lanList
.
size
()<=
0
){
lanList
.
add
(
MessageUtils
.
ZH_CN
);
lanList
.
add
(
MessageUtils
.
ZH_TW
);
lanList
.
add
(
MessageUtils
.
EN_US
);
lanList
.
add
(
MessageUtils
.
JA_JP
);
dataCache
.
updateCache
(
Constants
.
CACHE_languageType
,
lanList
);
}
return
lanList
;
}
@Override
public
void
download
(
List
<
LanguageMsg
>
msgList
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
...
...
@@ -83,16 +72,16 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"编号"
,
msg
.
getCode
());
map
.
put
(
"类型"
,
msg
.
getType
());
map
.
put
(
"
默认值
"
,
msg
.
getMsg
());
List
<
String
>
lanList
=
getAllLan
List
();
for
(
String
lanType
:
map
.
put
(
"
内容
"
,
msg
.
getMsg
());
List
<
LanguageInfo
>
lanList
=
dataCache
.
getLanguage
List
();
for
(
LanguageInfo
languageInfo
:
lanList
)
{
map
.
put
(
lanType
,
msg
.
getContent
(
lanType
));
String
title
=
languageInfo
.
getLanCode
()
;
if
(
ObjectUtil
.
isNotEmpty
(
languageInfo
.
getLanName
())){
title
=
languageInfo
.
getLanName
();
}
map
.
put
(
title
,
msg
.
getContent
(
languageInfo
.
getLanCode
()));
}
// map.put("简体中文", msg.getContent(MessageUtils.ZH_CN));
// map.put("繁体中文", msg.getContent(MessageUtils.ZH_TW));
// map.put("英文", msg.getContent(MessageUtils.EN_US));
// map.put("日文", msg.getContent(MessageUtils.JA_JP));
list
.
add
(
map
);
}
FileUtil
.
downloadExcel
(
list
,
response
);
...
...
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
查看文件 @
73e9a9a
package
com
.
neotel
.
smfcore
.
core
.
language
.
util
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.service.bean.Content
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -27,11 +30,11 @@ public class MessageUtils {
// return new Locale("zh-CH");
// }
private
static
MessageSource
messageSource
;
//
private static MessageSource messageSource;
public
MessageUtils
(
MessageSource
messageSource
)
{
MessageUtils
.
messageSource
=
messageSource
;
}
//
public MessageUtils(MessageSource messageSource) {
//
MessageUtils.messageSource = messageSource;
//
}
// public static String getText(String msgKey, Locale locale,String defaultMsg) {
// return getText(msgKey,null, locale,defaultMsg);
...
...
@@ -57,13 +60,15 @@ public class MessageUtils {
/**
* key=code
*
资源集合,
key=code
*/
private
static
Map
<
String
,
LanguageMsg
>
msgMap
=
new
HashMap
<>();
@Autowired
ILanguageMsgManager
languageMsgManager
;
public
static
final
String
ZH_CN
=
"zh-CN"
;
public
static
final
String
ZH_TW
=
"zh-TW"
;
public
static
final
String
EN_US
=
"en-US"
;
...
...
@@ -75,18 +80,6 @@ public class MessageUtils {
initLanguageMsgList
();
}
// public static List<String> getAllLanList(){
//
//
// List<String> lanList=new ArrayList<>();
// lanList.add(ZH_CN);
// lanList.add(ZH_TW);
// lanList.add(EN_US);
// lanList.add(JA_JP);
// return lanList;
// }
public
static
Locale
getDefaultLocal
(){
return
new
Locale
(
"zh-CH"
);
}
...
...
@@ -164,6 +157,19 @@ public class MessageUtils {
return
msgMap
;
}
public
static
List
<
LanguageInfo
>
getDefaultLanList
()
{
List
<
LanguageInfo
>
lanList
=
new
ArrayList
<>();
if
(
lanList
==
null
||
lanList
.
size
()
<=
0
)
{
lanList
=
new
ArrayList
<>();
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
ZH_CN
,
"简体中文"
,
""
));
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
ZH_TW
,
"繁体中文"
,
""
));
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
EN_US
,
"English"
,
""
));
lanList
.
add
(
new
LanguageInfo
(
MessageUtils
.
JA_JP
,
"日本语"
,
""
));
}
return
lanList
;
}
private
void
initLanguageMsgList
()
{
msgMap
=
loadMsgMap
();
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论