Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
837c432c
Commit
837c432c
authored
Aug 25, 2022
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
销户和冻结时删除token的缓存
parent
bee82863
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
UserController.java
...oup/xyqb/controller/middleoffice/user/UserController.java
+9
-0
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+6
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/user/UserController.java
View file @
837c432c
...
@@ -3,9 +3,11 @@ package cn.quantgroup.xyqb.controller.middleoffice.user;
...
@@ -3,9 +3,11 @@ package cn.quantgroup.xyqb.controller.middleoffice.user;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.event.DisableActiveEvent
;
import
cn.quantgroup.xyqb.event.DisableActiveEvent
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.TenantUtil
;
import
cn.quantgroup.xyqb.util.TenantUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -27,6 +29,10 @@ public class UserController {
...
@@ -27,6 +29,10 @@ public class UserController {
@Resource
@Resource
private
ApplicationEventPublisher
applicationEventPublisher
;
private
ApplicationEventPublisher
applicationEventPublisher
;
@Autowired
private
ISessionService
sessionService
;
@PutMapping
(
"/enable/{userId}"
)
@PutMapping
(
"/enable/{userId}"
)
public
JsonResult
enable
(
@PathVariable
Long
userId
)
{
public
JsonResult
enable
(
@PathVariable
Long
userId
)
{
User
user
=
userService
.
findById
(
userId
);
User
user
=
userService
.
findById
(
userId
);
...
@@ -51,6 +57,9 @@ public class UserController {
...
@@ -51,6 +57,9 @@ public class UserController {
user
.
setEnable
(
false
);
user
.
setEnable
(
false
);
//清理缓存
//清理缓存
userService
.
saveUser
(
user
);
userService
.
saveUser
(
user
);
// 清除token缓存
/* 清空session */
sessionService
.
deleteByUserId
(
user
.
getId
());
//通知消息中心
//通知消息中心
applicationEventPublisher
.
publishEvent
(
new
DisableActiveEvent
(
this
,
user
));
applicationEventPublisher
.
publishEvent
(
new
DisableActiveEvent
(
this
,
user
));
...
...
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
837c432c
...
@@ -230,6 +230,8 @@ public class SessionServiceImpl implements ISessionService {
...
@@ -230,6 +230,8 @@ public class SessionServiceImpl implements ISessionService {
if
(!
CollectionUtils
.
isEmpty
(
useIdKeys
))
{
if
(!
CollectionUtils
.
isEmpty
(
useIdKeys
))
{
useIdKeys
.
forEach
(
key
->
{
useIdKeys
.
forEach
(
key
->
{
log
.
info
(
"删除用户userId={}的缓存信息"
,
userId
);
log
.
info
(
"删除用户userId={}的缓存信息"
,
userId
);
String
token
=
stringRedisTemplate
.
opsForValue
().
get
(
String
.
valueOf
(
key
));
stringRedisTemplate
.
delete
(
getUserTokenKey
(
token
));
stringRedisTemplate
.
delete
(
String
.
valueOf
(
key
));
stringRedisTemplate
.
delete
(
String
.
valueOf
(
key
));
});
});
//2.删除session缓存健
//2.删除session缓存健
...
@@ -237,6 +239,10 @@ public class SessionServiceImpl implements ISessionService {
...
@@ -237,6 +239,10 @@ public class SessionServiceImpl implements ISessionService {
}
}
}
}
private
String
getUserTokenKey
(
String
token
)
{
return
Constants
.
Session
.
USER_SESSION_CACHE
+
token
;
}
/**
/**
* 删除注销后缓存查询结果
* 删除注销后缓存查询结果
*
*
...
...
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