获取用户信息

This commit is contained in:
2025-07-18 14:07:04 +08:00
parent 4988129503
commit deb6a2db97
3 changed files with 39 additions and 0 deletions
+14
View File
@@ -22,6 +22,20 @@ class UserController extends BaseController
}
}
/**
* 用户信息
*/
public function getUser(Request $request)
{
try {
$uid = $request->user->uid;
$result = (new UserService())->getUser($uid);
return $this->success($result, '获取用户信息');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 编辑用户
*/
+24
View File
@@ -3,6 +3,7 @@
namespace app\common\service;
use app\common\logic\UserLogic;
use app\crm\model\Country;
class UserService
{
@@ -38,6 +39,29 @@ class UserService
];
}
/**
* 获取用户信息(包括菜单和权限)
*/
public function getUser(int $uid)
{
$user = $this->logic->userInfo($uid);
return [
'id' => $user->id,
'name' => $user->name,
'position' => $user->position,
'socialize' => $user->socialize,
'socialize_pic' => $user->socialize_pic,
'country_id' => $user->country_id,
'country_txt' => Country::where('id',$user->country_id)->value('cn_addr'),
'avatar' => $user->avatar,
'phone' => $user->phone,
'email' => $user->email,
'status' => $user->status,
'roles' => $user->roles->pluck('name')
];
}
/**
* 获取用户信息(包括菜单和权限)
*/
+1
View File
@@ -40,6 +40,7 @@ Route::group('/common', function () {
Route::group('/user', function () {
Route::any('/info', [app\common\controller\UserController::class, 'info']);
Route::any('/get', [app\common\controller\UserController::class, 'getUser']);
});
Route::group('/preset', function () {