This commit is contained in:
gr
2026-11-11 13:53:14 +08:00
parent 85ffda8fd0
commit fc347bf9a6
490 changed files with 70862 additions and 386 deletions
+5 -26
View File
@@ -15,6 +15,7 @@
namespace app\common\cache;
use app\adminapi\logic\auth\AuthLogic;
use app\common\model\auth\SystemMenu;
/**
@@ -66,22 +67,8 @@ class AdminAuthCache extends BaseCache
*/
public function getAdminUri()
{
//从缓存获取,直接返回
$urisAuth = $this->get($this->cacheUrlKey);
if ($urisAuth) {
return $urisAuth;
}
//获取角色关联的菜单id(菜单或权限)
$urisAuth = AuthLogic::getAuthByAdminId($this->adminId);
if (empty($urisAuth)) {
return [];
}
$this->set($this->cacheUrlKey, $urisAuth, 3600);
//保存到缓存并读取返回
return $urisAuth;
// 授权必须读取已提交的原关联;缓存删除后仍可能被并发旧请求回填,不能再信任小时快照。
return AuthLogic::getAuthByAdminId($this->adminId);
}
@@ -93,16 +80,8 @@ class AdminAuthCache extends BaseCache
*/
public function getAllUri()
{
$cacheAuth = $this->get($this->cacheAllKey);
if ($cacheAuth) {
return $cacheAuth;
}
// 获取全部权限
$authList = AuthLogic::getAllAuth();
//保存到缓存并读取返回
$this->set($this->cacheMd5Key, $this->authMd5);
$this->set($this->cacheAllKey, $authList);
return $authList;
// 停用的菜单仍是受控URI,否则旧中间件会把它误判为“未登记接口”直接放行。
return SystemMenu::distinct(true)->where('perms', '<>', '')->column('perms');
}