From deb6a2db9778b528c3bc0aa2e5f93ca50252d111 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 18 Jul 2025 14:07:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/UserController.php | 14 ++++++++++++++ app/common/service/UserService.php | 24 ++++++++++++++++++++++++ config/route.php | 1 + 3 files changed, 39 insertions(+) diff --git a/app/common/controller/UserController.php b/app/common/controller/UserController.php index 2a55181..fc8413d 100644 --- a/app/common/controller/UserController.php +++ b/app/common/controller/UserController.php @@ -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()); + } + } + /** * 编辑用户 */ diff --git a/app/common/service/UserService.php b/app/common/service/UserService.php index b927c52..f5daf14 100644 --- a/app/common/service/UserService.php +++ b/app/common/service/UserService.php @@ -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') + ]; + } + /** * 获取用户信息(包括菜单和权限) */ diff --git a/config/route.php b/config/route.php index 3563589..737ce1b 100644 --- a/config/route.php +++ b/config/route.php @@ -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 () {