菜单绑定系统

This commit is contained in:
2025-07-25 18:10:11 +08:00
parent 32c6e8d425
commit cf6fc7033a
6 changed files with 63 additions and 17 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ class AuthService
return match ($loginType) {
'feishu' => $logic->feishuLogin($data),
'qrcode' => $logic->qrCodeLogin($data),
// 'qrcode' => $logic->qrCodeLogin($data),
default => $logic->uPwdLogin($data),
};
}
+6 -6
View File
@@ -23,7 +23,7 @@ class PermService
/**
* 获取用户所有资源(合并角色+直接分配),结果缓存
*/
public function getUserResources(int $userId)
public function getUserResources(int $userId, string $systemCode)
{
$cacheKey = self::cacheKey($userId);
$cached = Cache::get($cacheKey);
@@ -31,7 +31,7 @@ class PermService
return $cached;
}
// 调用 Logic 层获取资源
$resources = $this->logic->getUserResources($userId);
$resources = $this->logic->getUserResources($userId, $systemCode);
// 缓存结果
Cache::set($cacheKey, $resources, 3600);
return $resources;
@@ -40,19 +40,19 @@ class PermService
/**
* 构建目录/菜单树,节点包含权限与打开方式
*/
public function getMenuTree(int $userId): array
public function getMenuTree(int $userId, string $systemCode): array
{
// 调用 Logic 层处理菜单构建
$resources = $this->getUserResources($userId);
$resources = $this->getUserResources($userId, $systemCode);
return $this->logic->buildTree($resources);
}
/**
* 获取用户所有权限code
*/
public function getPermissionCodes(int $userId): array
public function getPermissionCodes(int $userId, string $systemCode): array
{
return $this->logic->getPermissionCodes($userId);
return $this->logic->getPermissionCodes($userId, $systemCode);
}
/**
+3 -3
View File
@@ -22,12 +22,12 @@ class UserService
/**
* 获取用户信息(包括菜单和权限)
*/
public function getUserInfo(int $uid)
public function getUserInfo(int $uid, string $systemCode)
{
$user = $this->logic->userInfo($uid);
$permService = new PermService();
$menuTree = $permService->getMenuTree($uid);
$permissionCodes = $permService->getPermissionCodes($uid);
$menuTree = $permService->getMenuTree($uid, $systemCode);
$permissionCodes = $permService->getPermissionCodes($uid, $systemCode);
return [
'user' => [
'id' => $user->id,