Files
fdesk/app/common/service/UserService.php
T

40 lines
980 B
PHP
Raw Normal View History

2025-07-01 19:39:13 +08:00
<?php
namespace app\common\service;
2025-07-11 15:21:00 +08:00
use app\common\logic\UserLogic;
2025-07-01 19:39:13 +08:00
class UserService
{
2025-07-11 15:21:00 +08:00
protected $logic;
public function __construct()
{
$this->logic = (new UserLogic());
}
/**
* 获取用户信息(包括菜单和权限)
*/
public function getUserInfo(int $uid)
2025-07-01 19:39:13 +08:00
{
2025-07-11 15:21:00 +08:00
$user = $this->logic->userInfo($uid);
$permService = new PermService();
$menuTree = $permService->getMenuTree($uid);
$permissionCodes = $permService->getPermissionCodes($uid);
2025-07-01 19:39:13 +08:00
return [
2025-07-11 15:21:00 +08:00
'user' => [
'id' => $user->id,
'name' => $user->name,
'avatar' => $user->avatar,
'phone' => $user->phone,
'email' => $user->email,
'status' => $user->status,
'roles' => $user->roles->pluck('name')
],
'menu' => $menuTree,
'permissions' => $permissionCodes
2025-07-01 19:39:13 +08:00
];
}
2025-07-11 15:21:00 +08:00
}