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
wwwanlingxiao
mall
Commits
215bc0e4
Commit
215bc0e4
authored
Apr 18, 2024
by
macro
Browse files
登出功能添加清空用户缓存逻辑
parent
03bcfa2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
mall-admin/src/main/java/com/macro/mall/controller/UmsAdminController.java
View file @
215bc0e4
...
@@ -108,7 +108,8 @@ public class UmsAdminController {
...
@@ -108,7 +108,8 @@ public class UmsAdminController {
@ApiOperation
(
value
=
"登出功能"
)
@ApiOperation
(
value
=
"登出功能"
)
@RequestMapping
(
value
=
"/logout"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/logout"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ResponseBody
public
CommonResult
logout
()
{
public
CommonResult
logout
(
Principal
principal
)
{
adminService
.
logout
(
principal
.
getName
());
return
CommonResult
.
success
(
null
);
return
CommonResult
.
success
(
null
);
}
}
...
...
mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
View file @
215bc0e4
...
@@ -89,4 +89,10 @@ public interface UmsAdminService {
...
@@ -89,4 +89,10 @@ public interface UmsAdminService {
* 获取缓存服务
* 获取缓存服务
*/
*/
UmsAdminCacheService
getCacheService
();
UmsAdminCacheService
getCacheService
();
/**
* 登出功能
* @param username 用户名
*/
void
logout
(
String
username
);
}
}
mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
View file @
215bc0e4
...
@@ -276,4 +276,12 @@ public class UmsAdminServiceImpl implements UmsAdminService {
...
@@ -276,4 +276,12 @@ public class UmsAdminServiceImpl implements UmsAdminService {
public
UmsAdminCacheService
getCacheService
()
{
public
UmsAdminCacheService
getCacheService
()
{
return
SpringUtil
.
getBean
(
UmsAdminCacheService
.
class
);
return
SpringUtil
.
getBean
(
UmsAdminCacheService
.
class
);
}
}
@Override
public
void
logout
(
String
username
)
{
//清空缓存中的用户相关数据
UmsAdmin
admin
=
getCacheService
().
getAdmin
(
username
);
getCacheService
().
delAdmin
(
admin
.
getId
());
getCacheService
().
delResourceList
(
admin
.
getId
());
}
}
}
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