Commit 70681bef LN

切换为使用数据库资源

1 个父辈 f7356bfd
...@@ -71,7 +71,7 @@ public class DataInitManager { ...@@ -71,7 +71,7 @@ public class DataInitManager {
role = roleManager.save(role); role = roleManager.save(role);
log.info("创建默认角色:" + role.toString()); 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); userManager.save(admin);
log.info("创建默认用户:" + admin.toString()); log.info("创建默认用户:" + admin.toString());
......
...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; ...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.*; import java.io.*;
import java.text.MessageFormat;
import java.util.*; import java.util.*;
/** /**
...@@ -22,9 +23,9 @@ import java.util.*; ...@@ -22,9 +23,9 @@ import java.util.*;
public class MessageUtils { public class MessageUtils {
//-----------------以下为从配置文件读取资源------------------------------------- //-----------------以下为从配置文件读取资源-------------------------------------
public static Locale getDefaultLocal(){ // public static Locale getDefaultLocal(){
return new Locale("zh-CH"); // return new Locale("zh-CH");
} // }
private static MessageSource messageSource; private static MessageSource messageSource;
...@@ -32,25 +33,25 @@ public class MessageUtils { ...@@ -32,25 +33,25 @@ public class MessageUtils {
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);
} // }
//
public static String getText(String msgKey, String[] params, Locale locale, String defaultMsg) { // public static String getText(String msgKey, String[] params, Locale locale, String defaultMsg) {
try{ // try{
if (params == null) { // if (params == null) {
return messageSource.getMessage(msgKey, new String[]{}, locale); // return messageSource.getMessage(msgKey, new String[]{}, locale);
} else { // } else {
return messageSource.getMessage(msgKey,params, locale); // return messageSource.getMessage(msgKey,params, locale);
} // }
}catch (Exception ex){ // }catch (Exception ex){
log.error("获取资源["+msgKey+"]["+defaultMsg+"]["+locale.getLanguage()+"]出错:"+ex.toString()); // log.error("获取资源["+msgKey+"]["+defaultMsg+"]["+locale.getLanguage()+"]出错:"+ex.toString());
if(defaultMsg != null){ // if(defaultMsg != null){
return defaultMsg; // return defaultMsg;
} // }
return msgKey; // return msgKey;
} // }
} // }
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
...@@ -86,29 +87,29 @@ public class MessageUtils { ...@@ -86,29 +87,29 @@ public class MessageUtils {
// } // }
// public static Locale getDefaultLocal(){ public static Locale getDefaultLocal(){
// return new Locale("zh-CH"); return new Locale("zh-CH");
// } }
// 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);
// } }
//
// public static String getText(String msgKey, String[] params, Locale locale, String defaultMsg) { public static String getText(String msgKey, String[] params, Locale locale, String defaultMsg) {
// try{ try{
// String msg=getMessage(msgKey,locale.toLanguageTag(),defaultMsg); String msg=getMessage(msgKey,locale.toLanguageTag(),defaultMsg);
// if (params == null) { if (params == null) {
// return msg; return msg;
// } else { } else {
// return MessageFormat.format(msg,params); return MessageFormat.format(msg,params);
// } }
// }catch (Exception ex){ }catch (Exception ex){
// log.error("获取资源["+msgKey+"]["+defaultMsg+"]["+locale.getLanguage()+"]出错:"+ex.toString()); log.error("获取资源["+msgKey+"]["+defaultMsg+"]["+locale.getLanguage()+"]出错:"+ex.toString());
// if(defaultMsg != null){ if(defaultMsg != null){
// return defaultMsg; return defaultMsg;
// } }
// return msgKey; return msgKey;
// } }
// } }
private static String getMessage(String msgKey, String lanType, String defaultMsg) { private static String getMessage(String msgKey, String lanType, String defaultMsg) {
if (msgMap != null) { if (msgMap != null) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!