Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
oms
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
oms
Commits
1fac5124
Commit
1fac5124
authored
Oct 19, 2018
by
黄毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
双语
parent
05373446
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
6 deletions
+121
-6
I18Config.java
src/main/java/com/egolm/oms/config/I18Config.java
+34
-0
OrderServiceImpl.java
...ain/java/com/egolm/oms/service/impl/OrderServiceImpl.java
+9
-5
I18NUtils.java
src/main/java/com/egolm/oms/util/I18NUtils.java
+64
-0
application.properties
src/main/resources/application.properties
+2
-1
messages.properties
src/main/resources/messages.properties
+4
-0
messages_en.properties
src/main/resources/messages_en.properties
+4
-0
messages_zh_CN.properties
src/main/resources/messages_zh_CN.properties
+4
-0
No files found.
src/main/java/com/egolm/oms/config/I18Config.java
0 → 100644
View file @
1fac5124
package
com
.
egolm
.
oms
.
config
;
import
java.util.Locale
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.LocaleResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.web.servlet.i18n.LocaleChangeInterceptor
;
import
org.springframework.web.servlet.i18n.SessionLocaleResolver
;
@Configuration
public
class
I18Config
extends
WebMvcConfigurerAdapter
{
@Bean
public
LocaleResolver
localeResolver
()
{
SessionLocaleResolver
slr
=
new
SessionLocaleResolver
();
// 默认语言
slr
.
setDefaultLocale
(
Locale
.
SIMPLIFIED_CHINESE
);
return
slr
;
}
@Bean
public
LocaleChangeInterceptor
localeChangeInterceptor
()
{
LocaleChangeInterceptor
lci
=
new
LocaleChangeInterceptor
();
// 参数名
lci
.
setParamName
(
"LangID"
);
return
lci
;
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
localeChangeInterceptor
());
}
}
src/main/java/com/egolm/oms/service/impl/OrderServiceImpl.java
View file @
1fac5124
...
...
@@ -16,6 +16,7 @@ import com.egolm.common.jdbc.JdbcTemplate;
import
com.egolm.common.jdbc.Page
;
import
com.egolm.common.jdbc.dialect.SqlServerDialect
;
import
com.egolm.oms.service.OrderService
;
import
com.egolm.oms.util.I18NUtils
;
@Service
public
class
OrderServiceImpl
implements
OrderService
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
OrderServiceImpl
.
class
);
...
...
@@ -32,6 +33,7 @@ public class OrderServiceImpl implements OrderService {
*/
public
String
orderCheck
(
Map
<
String
,
Object
>
params
)
{
jdbcTemplate
.
setDialect
(
new
SqlServerDialect
());
String
LangID
=
params
.
get
(
"langID"
)+
""
;
try
{
Rjx
rjx
=
Rjx
.
json
();
String
shopNO
=
params
.
get
(
"shopNO"
)+
""
;
...
...
@@ -54,11 +56,12 @@ public class OrderServiceImpl implements OrderService {
String
errorSubMsg
=
errorFullMsg
.
substring
(
errorFullMsg
.
lastIndexOf
(
key
)+
key
.
length
(),
errorFullMsg
.
length
());
System
.
out
.
println
(
errorFullMsg
);
System
.
out
.
println
(
errorSubMsg
);
return
Rjx
.
jsonErr
().
setMessage
(
"提交商品异常"
).
set
(
"result"
,
errorSubMsg
).
toJson
();
return
Rjx
.
jsonErr
().
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Submit_Goods_error"
)).
set
(
"result"
,
errorSubMsg
).
toJson
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"e...."
+
e
.
getMessage
());
e
.
printStackTrace
();
return
Rjx
.
jsonErr
().
setMessage
(
"提交商品失败"
).
toJson
();
return
Rjx
.
jsonErr
().
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Submit_Goods_failure"
)
).
toJson
();
}
}
...
...
@@ -72,7 +75,8 @@ public class OrderServiceImpl implements OrderService {
* @throws
*/
public
String
submit
(
JSONObject
submitObj
)
{
jdbcTemplate
.
setDialect
(
new
SqlServerDialect
());
jdbcTemplate
.
setDialect
(
new
SqlServerDialect
());
String
LangID
=
""
+
submitObj
.
get
(
"langID"
);
try
{
String
shopNO
=
""
+
submitObj
.
get
(
"shopNO"
);
String
payID
=
""
+
submitObj
.
get
(
"payTypeID"
);
...
...
@@ -93,12 +97,12 @@ public class OrderServiceImpl implements OrderService {
}
else
{
errorMsg
=
(
String
)
commitMap
.
get
(
0
).
get
(
"StatusName"
);
}
return
Rjx
.
jsonErr
().
setMessage
(
"订单提交失败"
).
set
(
"errorMsg"
,
errorMsg
).
toJson
();
return
Rjx
.
jsonErr
().
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Submit_Order_failure"
)
).
set
(
"errorMsg"
,
errorMsg
).
toJson
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Rjx
.
jsonErr
().
setMessage
(
"订单提交异常"
).
toJson
();
return
Rjx
.
jsonErr
().
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Submit_Order_error"
)
).
toJson
();
}
}
...
...
src/main/java/com/egolm/oms/util/I18NUtils.java
0 → 100644
View file @
1fac5124
package
com
.
egolm
.
oms
.
util
;
import
java.text.MessageFormat
;
import
java.util.Locale
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Component
;
import
com.egolm.common.StringUtil
;
/**
*
* @ClassName: I18NUtil
* @Description: TODO( 图际化工具类)
* @author 张永
* @date 2018年4月11日 下午5:36:27
*
*/
@Component
public
class
I18NUtils
{
private
static
MessageSource
source
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
getMessage
(
"zh"
,
"Msg_check_key_set"
,
"AAA"
));
}
@Autowired
public
void
init
(
MessageSource
source
)
{
I18NUtils
.
source
=
source
;
}
/**
*
* <p>Title: </p>
* <p>Description: </p>
* @param LangID 语言标识 与IDC中设置 的对应
* @param key 获取的key
* @param values key中对应的值用于替换 里面的 {0} {1}...
* @return
* @author 张永
* @date 2018年4月11日 下午8:35:15
*/
public
static
String
getMessage
(
String
LangID
,
String
key
,
Object
...
values
){
if
(
StringUtil
.
isEmpty
(
LangID
)){
//为空默认为中文
Locale
.
setDefault
(
Locale
.
CHINA
);
}
else
{
if
(
LangID
.
equals
(
"900"
)){
//英文
Locale
.
setDefault
(
Locale
.
ENGLISH
);
}
else
{
Locale
.
setDefault
(
Locale
.
CHINA
);
}
}
Locale
locale
=
LocaleContextHolder
.
getLocale
();
System
.
out
.
println
(
"locale---------------"
+
locale
);
String
msg
=
source
.
getMessage
(
key
,
null
,
locale
);
return
MessageFormat
.
format
(
msg
,
values
);
}
}
src/main/resources/application.properties
View file @
1fac5124
spring.profiles.active
=
dev
\ No newline at end of file
spring.profiles.active
=
dev
spring.messages.basename
=
messages
\ No newline at end of file
src/main/resources/messages.properties
0 → 100644
View file @
1fac5124
Msg_Submit_Goods_error
=
提交商品异常
Msg_Submit_Goods_failure
=
提交商品失败
Msg_Submit_Order_failure
=
订单提交失败
Msg_Submit_Order_error
=
订单提交异常
\ No newline at end of file
src/main/resources/messages_en.properties
0 → 100644
View file @
1fac5124
Msg_Submit_Goods_error
=
Submit goods exception
Msg_Submit_Goods_failure
=
Submit goods failure
Msg_Submit_Order_failure
=
Submit order failure
Msg_Submit_Order_error
=
Submit order exception
src/main/resources/messages_zh_CN.properties
0 → 100644
View file @
1fac5124
Msg_Submit_Goods_error
=
\u
63D0
\u
4EA4
\u5546\u
54C1
\u
5F02
\u
5E38
Msg_Submit_Goods_failure
=
\u
63D0
\u
4EA4
\u5546\u
54C1
\u5931\u
8D25
Msg_Submit_Order_failure
=
\u
8BA2
\u5355\u
63D0
\u
4EA4
\u5931\u
8D25
Msg_Submit_Order_error
=
\u
8BA2
\u5355\u
63D0
\u
4EA4
\u
5F02
\u
5E38
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment