优化登录用户权限缓存

This commit is contained in:
不做码农
2022-04-10 16:52:10 +08:00
parent 3eafab8292
commit 846652c1af
6 changed files with 51 additions and 42 deletions

View File

@@ -86,7 +86,7 @@ namespace ZR.Admin.WebApi.Controllers.System
List<string> permissions = permissionService.GetMenuPermission(user);
LoginUser loginUser = new(user, roles, permissions);
CacheHelper.SetCache(GlobalConstant.UserPermKEY + user.UserId, permissions);
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + user.UserId, permissions);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), jwtSettings.JwtSettings));
}
@@ -106,7 +106,7 @@ namespace ZR.Admin.WebApi.Controllers.System
var userid = HttpContext.GetUId();
var name = HttpContext.GetName();
CacheHelper.Remove(GlobalConstant.UserPermKEY + userid);
CacheService.RemoveUserPerms(GlobalConstant.UserPermKEY + userid);
return SUCCESS(new { name , id = userid });
}