Merge branch 'develop'

This commit is contained in:
mzl
2025-07-11 18:01:23 +08:00
parent 642c25503d
commit 925c5501f7
83 changed files with 4869 additions and 1162 deletions
+29 -9
View File
@@ -2,19 +2,39 @@
namespace app\common\service;
use app\model\User;
use app\common\logic\UserLogic;
class UserService
{
public static function getInfo($userId)
protected $logic;
public function __construct()
{
$user = User::with('roles')->find($userId);
if (!$user) return null;
$this->logic = (new UserLogic());
}
/**
* 获取用户信息(包括菜单和权限)
*/
public function getUserInfo(int $uid)
{
$user = $this->logic->userInfo($uid);
$permService = new PermService();
$menuTree = $permService->getMenuTree($uid);
$permissionCodes = $permService->getPermissionCodes($uid);
return [
'id' => $user->id,
'username' => $user->username,
'roles' => $user->roles->pluck('name')->toArray(),
// 可扩展其他字段
'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
];
}
}
}