Commit 70681bef LN

切换为使用数据库资源

1 个父辈 f7356bfd
......@@ -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());
......
......@@ -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!