Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
admin
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
曲欣亮
admin
Commits
d6edff1a
Commit
d6edff1a
authored
Aug 07, 2018
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
双语
parent
9dbe236d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
172 additions
and
23 deletions
+172
-23
I18Config.java
src/main/java/com/egolm/admin/config/I18Config.java
+34
-0
LinkListController.java
...n/java/com/egolm/admin/controller/LinkListController.java
+28
-11
OSSFileController.java
...in/java/com/egolm/admin/controller/OSSFileController.java
+8
-4
LinkListServiceImpl.java
...ava/com/egolm/admin/service/impl/LinkListServiceImpl.java
+11
-7
AdminContstrant.java
src/main/java/com/egolm/admin/util/AdminContstrant.java
+2
-0
I18NUtils.java
src/main/java/com/egolm/admin/util/I18NUtils.java
+64
-0
application.properties
src/main/resources/application.properties
+1
-1
messages.properties
src/main/resources/messages.properties
+8
-0
messages_en.properties
src/main/resources/messages_en.properties
+8
-0
messages_zh_CN.properties
src/main/resources/messages_zh_CN.properties
+8
-0
No files found.
src/main/java/com/egolm/admin/config/I18Config.java
0 → 100644
View file @
d6edff1a
package
com
.
egolm
.
admin
.
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/admin/controller/LinkListController.java
View file @
d6edff1a
...
...
@@ -3,17 +3,22 @@ package com.egolm.admin.controller;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.egolm.admin.pojo.TLinkList
;
import
com.egolm.admin.service.LinkListService
;
import
com.egolm.admin.util.AdminContstrant
;
import
com.egolm.admin.util.I18NUtils
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.jdbc.Page
;
...
...
@@ -31,6 +36,8 @@ public class LinkListController {
@Autowired
private
LinkListService
linkListService
;
@ApiOperation
(
"新增"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"linkNO"
,
dataType
=
"String"
,
required
=
true
,
value
=
"链接编号"
,
defaultValue
=
""
),
...
...
@@ -51,9 +58,10 @@ public class LinkListController {
String
memo
=
request
.
getParameter
(
"memo"
);
String
userNO
=
request
.
getParameter
(
"userNO"
);
String
tag
=
request
.
getParameter
(
"tag"
);
String
LangID
=
request
.
getParameter
(
"LangID"
);
if
(!
StringUtil
.
isNotEmpty
(
linkNO
,
linkName
,
linkType
,
linkPath
,
userNO
,
tag
))
{
return
Rjx
.
json
().
setCode
(-
1
).
setMessage
(
"参数不能为空"
).
toJson
();
if
(!
StringUtil
.
isNotEmpty
(
linkNO
,
linkName
,
linkType
,
linkPath
,
userNO
,
tag
,
LangID
))
{
return
Rjx
.
json
().
setCode
(-
1
).
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Parameter_empty"
)
).
toJson
();
}
TLinkList
tLinkList
=
new
TLinkList
();
...
...
@@ -67,8 +75,11 @@ public class LinkListController {
tLinkList
.
setsUpdateUser
(
userNO
.
trim
());
Rjx
rjx
=
linkListService
.
save
(
tLinkList
);
Rjx
result
=
Rjx
.
json
();
result
.
setCode
(
rjx
.
getCode
());
result
.
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
rjx
.
get
(
AdminContstrant
.
I18n_KEY
)+
""
));
return
r
jx
.
toJson
();
return
r
esult
.
toJson
();
}
...
...
@@ -92,9 +103,10 @@ public class LinkListController {
String
memo
=
request
.
getParameter
(
"memo"
);
String
userNO
=
request
.
getParameter
(
"userNO"
);
String
tag
=
request
.
getParameter
(
"tag"
);
String
LangID
=
request
.
getParameter
(
"LangID"
);
if
(!
StringUtil
.
isNotEmpty
(
linkNO
,
linkName
,
linkType
,
linkPath
,
userNO
,
tag
))
{
return
Rjx
.
json
().
setCode
(-
1
).
setMessage
(
"参数不能为空"
).
toJson
();
if
(!
StringUtil
.
isNotEmpty
(
linkNO
,
linkName
,
linkType
,
linkPath
,
userNO
,
tag
,
LangID
))
{
return
Rjx
.
json
().
setCode
(-
1
).
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Parameter_empty"
)
).
toJson
();
}
TLinkList
tLinkList
=
linkListService
.
getTLinkListByNO
(
linkNO
);
...
...
@@ -107,9 +119,13 @@ public class LinkListController {
tLinkList
.
setnTag
(
Integer
.
valueOf
(
tag
));
tLinkList
.
setsUpdateUser
(
userNO
.
trim
());
Rjx
rjx
=
linkListService
.
modify
(
tLinkList
);
return
rjx
.
toJson
();
Rjx
result
=
Rjx
.
json
();
result
.
setCode
(
rjx
.
getCode
());
result
.
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
rjx
.
get
(
AdminContstrant
.
I18n_KEY
)+
""
));
return
result
.
toJson
();
}
else
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"数据不存在"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Data_not_exists"
)
).
toJson
();
}
}
...
...
@@ -126,7 +142,10 @@ public class LinkListController {
String
queryMsg
=
request
.
getParameter
(
"queryMsg"
);
String
index
=
request
.
getParameter
(
"index"
);
String
limit
=
request
.
getParameter
(
"limit"
);
System
.
out
.
println
(
"queryMsg---"
+
queryMsg
);
String
LangID
=
request
.
getParameter
(
"LangID"
);
if
(!
StringUtil
.
isNotEmpty
(
index
,
limit
,
LangID
))
{
return
Rjx
.
json
().
setCode
(-
1
).
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Parameter_empty"
)).
toJson
();
}
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"queryMsg"
,
queryMsg
);
...
...
@@ -137,9 +156,7 @@ public class LinkListController {
page
.
setLimitKey
(
" lastUpdateTime desc "
);
List
<
Map
<
String
,
Object
>>
tLinkList
=
linkListService
.
query
(
params
,
page
);
List
<
Map
<
String
,
Object
>>
tLinkList
=
linkListService
.
query
(
params
,
page
);
return
Rjx
.
jsonOk
().
set
(
"list"
,
tLinkList
).
setPage
(
page
).
toString
();
}
...
...
src/main/java/com/egolm/admin/controller/OSSFileController.java
View file @
d6edff1a
...
...
@@ -75,18 +75,22 @@ public class OSSFileController {
*/
@ApiOperation
(
"上传(文件、图片)"
)
@ApiImplicitParams
({
})
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"LangID"
,
dataType
=
"String"
,
required
=
true
,
value
=
"语言"
,
defaultValue
=
"936"
),
})
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
//
public
String
upload
(
@RequestParam
(
"file"
)
MultipartFile
file
,
HttpServletRequest
request
)
throws
IOException
{
String
LangID
=
request
.
getParameter
(
"LangID"
);
if
(!
StringUtil
.
isNotEmpty
(
LangID
))
{
return
Rjx
.
json
().
setCode
(-
1
).
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Parameter_empty"
)).
toJson
();
}
List
<
String
>
codeList
=
new
ArrayList
<
String
>();
codeList
.
add
(
AdminContstrant
.
OSS_UPLOAD_CONFIG_KEY
);
codeList
.
add
(
AdminContstrant
.
OSS_UPLOAD_SECRET_KEY
);
System
.
out
.
println
(
"-----"
+
StringUtil
.
join
(
","
,
codeList
));
List
<
Map
<
String
,
Object
>>
listCtl
=
systemCtlService
.
getTSystemCtrlByCode
(
codeList
);
if
(
listCtl
.
isEmpty
()
||
listCtl
.
size
()
!=
2
)
{
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
"请检查"
+
StringUtil
.
join
(
","
,
codeList
)+
"参数是否配置"
).
toJson
();
return
Rjx
.
jsonErr
().
setCode
(-
100
).
setMessage
(
I18NUtils
.
getMessage
(
LangID
,
"Msg_Check_Key_Set"
,
StringUtil
.
join
(
","
,
codeList
))
).
toJson
();
}
String
ossUrl
=
""
;
//上传的URL
...
...
src/main/java/com/egolm/admin/service/impl/LinkListServiceImpl.java
View file @
d6edff1a
...
...
@@ -4,13 +4,15 @@ import java.util.Date;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
org.springframework.stereotype.Service
;
import
com.egolm.admin.pojo.TLinkList
;
import
com.egolm.admin.service.LinkListService
;
import
com.egolm.admin.util.AdminContstrant
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.jdbc.JdbcTemplate
;
...
...
@@ -26,6 +28,8 @@ import com.egolm.common.jdbc.Page;
*/
@Service
public
class
LinkListServiceImpl
implements
LinkListService
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
LinkListServiceImpl
.
class
);
@Autowired
@Qualifier
(
"shopJdbcTemplate"
)
private
JdbcTemplate
jdbcTemplate
;
...
...
@@ -45,13 +49,13 @@ public class LinkListServiceImpl implements LinkListService {
linkList
.
setdLastUpdateTime
(
new
Date
());
TLinkList
link
=
getTLinkListByNO
(
linkList
.
getsLinkNO
());
if
(
link
!=
null
)
{
return
Rjx
.
jsonErr
().
setMessage
(
"链接编号已存在"
);
return
Rjx
.
jsonErr
().
set
(
AdminContstrant
.
I18n_KEY
,
"Msg_LinkNo_exists"
).
set
Message
(
"链接编号已存在"
);
}
else
{
int
i
=
jdbcTemplate
.
save
(
linkList
);
if
(
i
>
0
)
{
return
Rjx
.
jsonOk
().
setMessage
(
"保存成功"
);
return
Rjx
.
jsonOk
().
set
(
AdminContstrant
.
I18n_KEY
,
"Msg_Save_Success"
).
set
Message
(
"保存成功"
);
}
return
Rjx
.
jsonErr
().
setMessage
(
"保存失败"
);
return
Rjx
.
jsonErr
().
set
(
AdminContstrant
.
I18n_KEY
,
"Msg_Save_Error"
).
set
Message
(
"保存失败"
);
}
}
...
...
@@ -70,9 +74,9 @@ public class LinkListServiceImpl implements LinkListService {
int
i
=
jdbcTemplate
.
update
(
linkList
);
if
(
i
>
0
)
{
return
Rjx
.
jsonOk
().
setMessage
(
"更新成功"
);
return
Rjx
.
jsonOk
().
set
(
AdminContstrant
.
I18n_KEY
,
"Msg_Update_Success"
).
set
Message
(
"更新成功"
);
}
return
Rjx
.
jsonErr
().
setMessage
(
"更新失败"
);
return
Rjx
.
jsonErr
().
set
(
AdminContstrant
.
I18n_KEY
,
"Msg_Update_Error"
).
set
Message
(
"更新失败"
);
}
/**
...
...
@@ -88,7 +92,7 @@ public class LinkListServiceImpl implements LinkListService {
String
sql
=
"SELECT * FROM tLinkList WHERE sLinkNO = ? AND nTag&1=0"
;
return
jdbcTemplate
.
queryForBean
(
sql
,
TLinkList
.
class
,
linkNO
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
logger
.
info
(
"链接资源不存在 linkNo:"
+
linkNO
);
}
return
null
;
}
...
...
src/main/java/com/egolm/admin/util/AdminContstrant.java
View file @
d6edff1a
...
...
@@ -13,4 +13,6 @@ public class AdminContstrant {
public
static
final
String
OSS_UPLOAD_CONFIG_KEY
=
"OSS_UPLOAD_CONFIG"
;
//自建OSS上传参数配置
public
static
final
String
OSS_UPLOAD_SECRET_KEY
=
"OSS_UPLOAD_SECRET"
;
//自建OSS上传密钥,算签名的
public
static
final
String
I18n_KEY
=
"i18nKey"
;
//service 返回到 controller设置的key
}
src/main/java/com/egolm/admin/util/I18NUtils.java
0 → 100644
View file @
d6edff1a
package
com
.
egolm
.
admin
.
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 @
d6edff1a
spring.profiles.active
=
dev
spring.messages.basename
=
i18n/messages
\ No newline at end of file
spring.messages.basename
=
messages
\ No newline at end of file
src/main/resources/messages.properties
0 → 100644
View file @
d6edff1a
Msg_Parameter_empty
=
参数不能为空
Msg_Data_not_exists
=
数据不存在
Msg_Check_Key_Set
=
请检查{0}参数是否配置
Msg_LinkNo_exists
=
链接编号已存在
Msg_Save_Success
=
保存成功
Msg_Save_Error
=
保存失败
Msg_Update_Success
=
更新成功
Msg_Update_Error
=
更新失败
\ No newline at end of file
src/main/resources/messages_en.properties
0 → 100644
View file @
d6edff1a
Msg_Parameter_empty
=
Parameters can not be empty
Msg_Data_not_exists
=
Data does not exist
Msg_Check_Key_Set
=
Please check whether the {0} parameter is configured
Msg_LinkNo_exists
=
Link number has already existed
Msg_Save_Success
=
Save success
Msg_Save_Error
=
Save failure
Msg_Update_Success
=
Update success
Msg_Update_Error
=
Update failure
\ No newline at end of file
src/main/resources/messages_zh_CN.properties
0 → 100644
View file @
d6edff1a
Msg_Parameter_empty
=
\u
53C2
\u6570\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
Msg_Data_not_exists
=
\u6570\u
636E
\u
4E0D
\u
5B58
\u5728
Msg_Check_Key_Set=
\u
8BF7
\u
68C0
\u
67E5{0}
\u
53C2
\u6570\u
662F
\u5426\u
914D
\u
7F6E
Msg_LinkNo_exists
=
\u
94FE
\u
63A5
\u
7F16
\u
53F7
\u
5DF2
\u
5B58
\u5728
Msg_Save_Success=
\u
4FDD
\u
5B58
\u6210\u
529F
Msg_Save_Error
=
\u
4FDD
\u
5B58
\u5931\u
8D25
Msg_Update_Success
=
\u
66F4
\u
65B0
\u6210\u
529F
Msg_Update_Error
=
\u
66F4
\u
65B0
\u5931\u
8D25
\ No newline at end of file
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