From b6b0b5170d54b5727de491521eb41cb1d93cff06 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Tue, 14 Jan 2020 08:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/user/controller/User.php | 7 +++---- catch/user/model/Users.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/catch/user/controller/User.php b/catch/user/controller/User.php index 68801b9..652f022 100644 --- a/catch/user/controller/User.php +++ b/catch/user/controller/User.php @@ -46,17 +46,16 @@ class User extends CatchController */ public function info(CatchAuth $auth) { - $user = $auth->user(); $roles = $user->getRoles(); - $user->permissions = Permissions::whereIn('id', $user->getPermissionsBy()) - ->field(['permission_name as title', 'route', 'icon']) - ->select(); + $user->permissions = Permissions::getCurrentUserPermissions(); $user->roles = $roles; + dd(Roles::getDepartmentUserIdsBy($roles)); + return CatchResponse::success($user); } diff --git a/catch/user/model/Users.php b/catch/user/model/Users.php index 9dd814c..b5124a3 100644 --- a/catch/user/model/Users.php +++ b/catch/user/model/Users.php @@ -82,4 +82,18 @@ class Users extends CatchModel return array_unique($permissionIds); } + + /** + * 获取部门下的用户 + * + * @time 2020年01月14日 + * @param $deptIds + * @return mixed + */ + public static function getUserIdsByDepartmentIds($deptIds) + { + $ids = parent::whereIn('id', $deptIds)->value('id'); + + return $ids ? $ids->toArray() : []; + } }