Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
cad0c08c
Commit
cad0c08c
authored
Oct 27, 2019
by
dqjdda
Browse files
代码优化
parent
bb5cc6f6
Changes
4
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/RedisServiceImpl.java
View file @
cad0c08c
...
...
@@ -30,6 +30,9 @@ public class RedisServiceImpl implements RedisService {
@Value
(
"${jwt.online}"
)
private
String
onlineKey
;
@Value
(
"${jwt.codeKey}"
)
private
String
codeKey
;
public
RedisServiceImpl
(
RedisTemplate
redisTemplate
)
{
this
.
redisTemplate
=
redisTemplate
;
}
...
...
@@ -43,7 +46,7 @@ public class RedisServiceImpl implements RedisService {
Set
<
String
>
keys
=
redisTemplate
.
keys
(
key
);
for
(
String
s
:
keys
)
{
// 过滤掉权限的缓存
if
(
s
.
contains
(
"role::loadPermissionByUser"
)
||
s
.
contains
(
"user::loadUserByUsername"
)
||
s
.
contains
(
onlineKey
))
{
if
(
s
.
contains
(
"role::loadPermissionByUser"
)
||
s
.
contains
(
"user::loadUserByUsername"
)
||
s
.
contains
(
onlineKey
)
||
s
.
contains
(
codeKey
)
)
{
continue
;
}
RedisVo
redisVo
=
new
RedisVo
(
s
,
Objects
.
requireNonNull
(
redisTemplate
.
opsForValue
().
get
(
s
)).
toString
());
...
...
@@ -63,7 +66,7 @@ public class RedisServiceImpl implements RedisService {
@Override
public
void
deleteAll
()
{
Set
<
String
>
keys
=
redisTemplate
.
keys
(
"*"
);
redisTemplate
.
delete
(
keys
.
stream
().
filter
(
s
->
!
s
.
contains
(
onlineKey
)).
collect
(
Collectors
.
toList
()));
redisTemplate
.
delete
(
keys
.
stream
().
filter
(
s
->
!
s
.
contains
(
onlineKey
)).
filter
(
s
->
!
s
.
contains
(
codeKey
)).
collect
(
Collectors
.
toList
()));
}
@Override
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java
View file @
cad0c08c
...
...
@@ -38,8 +38,8 @@ import javax.servlet.http.HttpServletRequest;
@Api
(
tags
=
"系统:系统授权接口"
)
public
class
AuthenticationController
{
@Value
(
"${jwt.
online
}"
)
private
String
onlin
eKey
;
@Value
(
"${jwt.
codeKey
}"
)
private
String
cod
eKey
;
private
final
JwtTokenUtil
jwtTokenUtil
;
...
...
@@ -104,7 +104,7 @@ public class AuthenticationController {
captcha
.
setLen
(
2
);
// 获取运算的结果:5
String
result
=
captcha
.
text
();
String
uuid
=
onlin
eKey
+
IdUtil
.
simpleUUID
();
String
uuid
=
cod
eKey
+
IdUtil
.
simpleUUID
();
redisService
.
saveCode
(
uuid
,
result
);
return
new
ImgResult
(
captcha
.
toBase64
(),
uuid
);
}
...
...
eladmin-system/src/main/resources/config/application-dev.yml
View file @
cad0c08c
...
...
@@ -49,6 +49,8 @@ jwt:
expiration
:
21600000
# 在线用户key
online
:
online-token
# 验证码
codeKey
:
code-key
#是否允许生成代码,生产环境设置为false
generator
:
...
...
eladmin-system/src/main/resources/config/application-prod.yml
View file @
cad0c08c
...
...
@@ -51,6 +51,8 @@ jwt:
expiration
:
7200000
# 在线用户key
online
:
online-token
# 验证码
codeKey
:
code-key
#是否允许生成代码,生产环境设置为false
generator
:
...
...
Write
Preview
Supports
Markdown
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