Commit 73e9a9ae LN

增加csv文件导入功能。语言设置增加名称和图标字段。

1 个父辈 746e03c3
...@@ -10,6 +10,9 @@ import com.neotel.smfcore.common.utils.StringUtils; ...@@ -10,6 +10,9 @@ import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.common.utils.YmlUpdateUtil; import com.neotel.smfcore.common.utils.YmlUpdateUtil;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; 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.bean.InventoryItem;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE; import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
...@@ -102,6 +105,15 @@ public class DataCache { ...@@ -102,6 +105,15 @@ public class DataCache {
return null; 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;
}
/** /**
* 更新缓存信息 * 更新缓存信息
*/ */
......
...@@ -3,9 +3,11 @@ package com.neotel.smfcore.core.language.rest; ...@@ -3,9 +3,11 @@ package com.neotel.smfcore.core.language.rest;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.PageData; import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean; 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.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.FileUtil; 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.common.utils.QueryHelp;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.rest.bean.dto.LanguageMsgDto; import com.neotel.smfcore.core.language.rest.bean.dto.LanguageMsgDto;
...@@ -13,15 +15,18 @@ import com.neotel.smfcore.core.language.rest.bean.dto.LanguageResourceDto; ...@@ -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.mapstruct.LanguageMsgMapper;
import com.neotel.smfcore.core.language.rest.bean.query.LanguageMsgCriteria; 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.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.nanager.ILanguageMsgManager;
import com.neotel.smfcore.core.language.service.po.LanguageMsg; import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import com.neotel.smfcore.core.language.util.MessageUtils; import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties; import com.neotel.smfcore.security.bean.FileProperties;
import com.neotel.smfcore.security.service.po.User;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.mapstruct.ap.shaded.freemarker.ext.beans.HashAdapter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -54,18 +59,15 @@ public class LanguageMsgController { ...@@ -54,18 +59,15 @@ public class LanguageMsgController {
@Autowired @Autowired
DataCache dataCache; DataCache dataCache;
public List<String> getAllLanList() { public List<String> getAllLanList() {
List<String> lanList = dataCache.getCache(Constants.CACHE_languageType); List<LanguageInfo> lanList = dataCache.getLanguageList();
if (lanList == null || lanList.size() <= 0) { List<String> list = new ArrayList<>();
lanList = new ArrayList<>(); for (LanguageInfo lan : lanList
lanList.add(MessageUtils.ZH_CN); ) {
lanList.add(MessageUtils.ZH_TW); list.add(lan.getLanCode());
lanList.add(MessageUtils.EN_US);
lanList.add(MessageUtils.JA_JP);
dataCache.updateCache(Constants.CACHE_languageType, lanList);
} }
return lanList; return list;
} }
...@@ -73,14 +75,15 @@ public class LanguageMsgController { ...@@ -73,14 +75,15 @@ public class LanguageMsgController {
@PostMapping(value = "/upload") @PostMapping(value = "/upload")
public ResultBean upload(@RequestParam MultipartFile uploadFile) throws Exception { public ResultBean upload(@RequestParam MultipartFile uploadFile) throws Exception {
// 验证文件上传的格式 // 验证文件上传的格式
String smfcodeType = "properties"; String smfcoreType = "properties";
String smfclientType = "js"; String smfclientType = "js";
String csvType="csv";
String fileType = FileUtil.getExtensionName(uploadFile.getOriginalFilename()); String fileType = FileUtil.getExtensionName(uploadFile.getOriginalFilename());
if (fileType == null) { if (fileType == null) {
throw new ValidateException("smfcode.feleFormatError", "文件格式错误!, 仅支持{0}格式", new String[]{smfclientType + "/" + smfcodeType}); throw new ValidateException("smfcode.feleFormatError", "文件格式错误!, 仅支持{0}格式", new String[]{csvType+"/"+smfclientType + "/" + smfcoreType});
} }
if ((!smfclientType.contains(fileType)) && !smfcodeType.contains(fileType)) { if ((!smfclientType.contains(fileType)) && !smfcoreType.contains(fileType) && !csvType.contains(fileType)) {
throw new ValidateException("smfcode.feleFormatError", "文件格式错误!, 仅支持{0}格式", new String[]{smfclientType + "/" + smfcodeType}); throw new ValidateException("smfcode.feleFormatError", "文件格式错误!, 仅支持{0}格式", new String[]{csvType+"/"+smfclientType + "/" + smfcoreType});
} }
File folder = new File(properties.getPath(), "resource"); File folder = new File(properties.getPath(), "resource");
File file = FileUtil.upload(uploadFile, folder.getAbsolutePath()); File file = FileUtil.upload(uploadFile, folder.getAbsolutePath());
...@@ -92,10 +95,14 @@ public class LanguageMsgController { ...@@ -92,10 +95,14 @@ public class LanguageMsgController {
//客户端js文件处理 //客户端js文件处理
Map<String, String> proMap = readJsFile(file); Map<String, String> proMap = readJsFile(file);
resultMsg = ResourceUpload(uploadFile.getOriginalFilename(), proMap, lanType, "smfclient"); resultMsg = ResourceUpload(uploadFile.getOriginalFilename(), proMap, lanType, "smfclient");
} else if (smfcodeType.contains(fileType)) { } else if (smfcoreType.contains(fileType)) {
Map<String, String> proMap = MessageUtils.ReadPropertiesFile(file); Map<String, String> proMap = MessageUtils.ReadPropertiesFile(file);
resultMsg = ResourceUpload(uploadFile.getOriginalFilename(), proMap, lanType, ""); resultMsg = ResourceUpload(uploadFile.getOriginalFilename(), proMap, lanType, "");
} }
if(csvType.equals(fileType)){
List<LanguageMsg> list=CsvFileRead(file.getAbsolutePath());
msgListUpload(list);
}
return ResultBean.newOkResult(resultMsg); return ResultBean.newOkResult(resultMsg);
} }
...@@ -118,6 +125,7 @@ public class LanguageMsgController { ...@@ -118,6 +125,7 @@ public class LanguageMsgController {
query.addCriteria(Criteria.where(proName).exists(false)); query.addCriteria(Criteria.where(proName).exists(false));
} }
} }
List<LanguageMsg> list = languageMsgManager.findByQuery(query); List<LanguageMsg> list = languageMsgManager.findByQuery(query);
//下载 //下载
languageMsgManager.download(list, response); languageMsgManager.download(list, response);
...@@ -413,66 +421,130 @@ public class LanguageMsgController { ...@@ -413,66 +421,130 @@ public class LanguageMsgController {
} }
// private void msgListUpload(String type, List<LanguageMsg> msgList) { private List<LanguageMsg> CsvFileRead(String fileURL ) throws Exception{
// CsvReader csvRead = CsvReader.newReader(fileURL,"编号","code");
// List<LanguageMsg> newLanguageList = new ArrayList<>(); int codeIndex = csvRead.getCsvIndex("编号","code");
// List<LanguageMsg> updateLanguageList = new ArrayList<>(); int typeIndex = csvRead.getCsvIndex("类型","type");
// for (LanguageMsg msg : int msgIndex = csvRead.getCsvIndex("内容","msg");
// msgList) {
// msg.setType(type); Map<String,Integer> lanCodeIndex=new HashMap<>() ;
// if(ObjectUtil.isEmpty(msg.getCode())) { List<LanguageInfo> languageInfos=dataCache.getLanguageList();
// //code不能为空 for (LanguageInfo lan:languageInfos
// continue; ) {
// } int lanIndex = csvRead.getCsvIndex(lan.getLanCode(),lan.getLanName());
// if(ObjectUtil.isEmpty(msg.getMsg())){ if(lanIndex>=0){
// //内容不能为空 lanCodeIndex.put(lan.getLanCode(),lanIndex);
// continue; }
// } }
//
// List<Content> contentList = new ArrayList<>(); int row = 1;
// for (Content con : int newRowCount = 0;
// msg.getContentList()) { int updateRowCount = 0;
// if (ObjectUtil.isEmpty(con.getLanCode()) || ObjectUtil.isEmpty(con.getMsg())) { String msg="";
// continue; List<LanguageMsg> list=new ArrayList<>();
// } while(csvRead.readRecord()) {
// contentList.add(con); row++;
// } String[] lineValues = csvRead.getValues();
// LanguageMsg languageMsg=new LanguageMsg();
// String code = lineValues[codeIndex];
// //判断是否是新增 String type = lineValues[typeIndex];
// LanguageMsg oldMsg=MessageUtils.getMsg(msg.getCode()); String msgStr = lineValues[msgIndex];
// if(oldMsg==null){ if (code.isEmpty() || type.isEmpty() || msgStr.isEmpty()) {
// newLanguageList.add(msg); log.warn("第" + row + "行中有空白内容,此行忽略");
// } continue;
// else{ }
// //只新增不修改 languageMsg.setMsg(msgStr);
// List<String> allLanList=getAllLanList(); languageMsg.setCode(code);
// for (String lanType : languageMsg.setType(type);
// allLanList) {
// String oldValue= oldMsg.getContent(lanType); for (String lan :
// if(ObjectUtil.isEmpty(oldValue)){ lanCodeIndex.keySet()) {
// oldMsg.setContent(lanType,msg.getContent(lanType)); int lanIndex=lanCodeIndex.get(lan);
// } String lanMsg=lineValues[lanIndex];
// } if(!lanMsg.isEmpty()){
// updateLanguageList.add(oldMsg); languageMsg.setContent(lan,lanMsg);
// languageMsgManager.save(oldMsg); }
// MessageUtils.updateMsg(oldMsg); }
// }
// list.add(languageMsg);
// } }
// return list;
// }
//
// if (newLanguageList.size() > 0) { private void msgListUpload( List<LanguageMsg> msgList) {
// languageMsgManager.insertAll(newLanguageList);
// for (LanguageMsg msg : List<LanguageMsg> newLanguageList = new ArrayList<>();
// newLanguageList) { List<LanguageMsg> updateLanguageList = new ArrayList<>();
// MessageUtils.updateMsg(msg); for (LanguageMsg msg :
// } msgList) {
// }
// log.info("导入[" + type + "]类型的资源列表,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源"); 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() + "]条资源");
}
} }
...@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
@Slf4j @Slf4j
...@@ -34,36 +35,21 @@ public class LanguageSetController { ...@@ -34,36 +35,21 @@ public class LanguageSetController {
@Autowired @Autowired
DataCache dataCache; 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) { // if (lanList == null || lanList.size() <= 0) {
// lanList=new ArrayList<>(); // lanList = MessageUtils.getDefaultLanList();
// 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); // dataCache.updateCache(Constants.CACHE_languageType, lanList);
// } // }
// return lanList; return dataCache.getLanguageList();
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;
} }
@ApiOperation("获取语言列表") @ApiOperation("获取语言列表")
@GetMapping @GetMapping
@PreAuthorize("@el.check('translation')") @PreAuthorize("@el.check('translation')")
public List<LanguageInfo> getList(){ public List<LanguageInfo> getList(){
return getAllLanList(); return getAllLanList();
} }
@ApiOperation("新增语言") @ApiOperation("新增语言")
@PostMapping @PostMapping
...@@ -111,12 +97,25 @@ public class LanguageSetController { ...@@ -111,12 +97,25 @@ public class LanguageSetController {
} }
} }
List<LanguageInfo> newList=new ArrayList<>();
for (LanguageInfo lan : for (LanguageInfo lan :
languageTypeList) { 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); newList.add(lan);
} }
} }
...@@ -124,6 +123,7 @@ public class LanguageSetController { ...@@ -124,6 +123,7 @@ public class LanguageSetController {
throw new ValidateException("smfcode.languageCanotRemoveAll", "不能删除所有语言"); throw new ValidateException("smfcode.languageCanotRemoveAll", "不能删除所有语言");
} }
dataCache.updateCache(Constants.CACHE_languageType, newList); dataCache.updateCache(Constants.CACHE_languageType, newList);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
......
...@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.barcode.bean.PlateSizeBean; ...@@ -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.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache; 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.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.dao.ILanguageMsgDao;
import com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager; import com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager;
import com.neotel.smfcore.core.language.service.po.LanguageMsg; import com.neotel.smfcore.core.language.service.po.LanguageMsg;
...@@ -64,18 +65,6 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager { ...@@ -64,18 +65,6 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
@Autowired @Autowired
DataCache dataCache; 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 @Override
public void download(List<LanguageMsg> msgList, HttpServletResponse response) throws IOException { public void download(List<LanguageMsg> msgList, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
...@@ -83,16 +72,16 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager { ...@@ -83,16 +72,16 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("编号", msg.getCode()); map.put("编号", msg.getCode());
map.put("类型", msg.getType()); map.put("类型", msg.getType());
map.put("默认值", msg.getMsg()); map.put("内容", msg.getMsg());
List<String> lanList=getAllLanList(); List<LanguageInfo> lanList=dataCache.getLanguageList();
for (String lanType : for (LanguageInfo languageInfo :
lanList) { 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); list.add(map);
} }
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
......
package com.neotel.smfcore.core.language.util; package com.neotel.smfcore.core.language.util;
import cn.hutool.core.util.ObjectUtil; 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.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.nanager.ILanguageMsgManager;
import com.neotel.smfcore.core.language.service.po.LanguageMsg; import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -27,11 +30,11 @@ public class MessageUtils { ...@@ -27,11 +30,11 @@ public class MessageUtils {
// return new Locale("zh-CH"); // return new Locale("zh-CH");
// } // }
private static MessageSource messageSource; // private static MessageSource messageSource;
public MessageUtils(MessageSource messageSource) { // public MessageUtils(MessageSource messageSource) {
MessageUtils.messageSource = messageSource; // MessageUtils.messageSource = messageSource;
} // }
// public static String getText(String msgKey, Locale locale,String defaultMsg) { // public static String getText(String msgKey, Locale locale,String defaultMsg) {
// return getText(msgKey,null, locale,defaultMsg); // return getText(msgKey,null, locale,defaultMsg);
...@@ -57,13 +60,15 @@ public class MessageUtils { ...@@ -57,13 +60,15 @@ public class MessageUtils {
/** /**
* key=code * 资源集合,key=code
*/ */
private static Map<String, LanguageMsg> msgMap = new HashMap<>(); private static Map<String, LanguageMsg> msgMap = new HashMap<>();
@Autowired @Autowired
ILanguageMsgManager languageMsgManager; ILanguageMsgManager languageMsgManager;
public static final String ZH_CN = "zh-CN"; public static final String ZH_CN = "zh-CN";
public static final String ZH_TW = "zh-TW"; public static final String ZH_TW = "zh-TW";
public static final String EN_US = "en-US"; public static final String EN_US = "en-US";
...@@ -75,18 +80,6 @@ public class MessageUtils { ...@@ -75,18 +80,6 @@ public class MessageUtils {
initLanguageMsgList(); 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(){ public static Locale getDefaultLocal(){
return new Locale("zh-CH"); return new Locale("zh-CH");
} }
...@@ -164,6 +157,19 @@ public class MessageUtils { ...@@ -164,6 +157,19 @@ public class MessageUtils {
return msgMap; 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() { private void initLanguageMsgList() {
msgMap = loadMsgMap(); msgMap = loadMsgMap();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!