登出功能添加清空用户缓存逻辑
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,4 +89,10 @@ public interface UmsAdminService {
|
|||||||
* 获取缓存服务
|
* 获取缓存服务
|
||||||
*/
|
*/
|
||||||
UmsAdminCacheService getCacheService();
|
UmsAdminCacheService getCacheService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登出功能
|
||||||
|
* @param username 用户名
|
||||||
|
*/
|
||||||
|
void logout(String username);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user