diff --git a/catch/user/controller/User.php b/catch/user/controller/User.php index e018315..631e550 100644 --- a/catch/user/controller/User.php +++ b/catch/user/controller/User.php @@ -9,9 +9,11 @@ use catchAdmin\user\request\CreateRequest; use catchAdmin\user\request\UpdateRequest; use catcher\base\CatchController; use catcher\CatchAuth; +use catcher\CatchCacheKeys; use catcher\CatchResponse; use catcher\Tree; use catcher\Utils; +use think\facade\Cache; class User extends CatchController { @@ -50,7 +52,11 @@ class User extends CatchController $roles = $user->getRoles(); - $user->permissions = Permissions::getCurrentUserPermissions(); + $permissionIds = $user->getPermissionsBy(); + // 缓存用户权限 + Cache::set(CatchCacheKeys::USER_PERMISSIONS . $user->id, $permissionIds); + + $user->permissions = Permissions::getCurrentUserPermissions($permissionIds); $user->roles = $roles; diff --git a/extend/catcher/CatchCacheKeys.php b/extend/catcher/CatchCacheKeys.php new file mode 100644 index 0000000..80dd1f1 --- /dev/null +++ b/extend/catcher/CatchCacheKeys.php @@ -0,0 +1,16 @@ + + * @copyright By CatchAdmin + * @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt + */ +namespace catcher; + +class CatchCacheKeys +{ + public const USER_PERMISSIONS = 'user_permissions_'; +}