From 5d10d7ac78388893725b21856995c0940a98dc9f Mon Sep 17 00:00:00 2001 From: zhaoxiang Date: Sun, 11 Feb 2018 10:44:19 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E5=96=84=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=EF=BC=8C=E6=9D=83=E9=99=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Auth.php | 31 +++++++++++++++++++++++++++ application/adminRoute.php | 4 ++++ 2 files changed, 35 insertions(+) diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index 64bd80e..ba0595e 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -9,6 +9,7 @@ namespace app\admin\controller; use app\model\ApiAuthGroup; +use app\model\ApiAuthGroupAccess; use app\model\ApiAuthRule; use app\model\ApiMenu; use app\util\ReturnCode; @@ -184,6 +185,36 @@ class Auth extends Base { return $this->buildSuccess([]); } + /** + * 从指定组中删除指定用户 + * @return array + * @throws \think\Exception + * @throws \think\exception\DbException + * @author zhaoxiang + */ + public function delMember() { + $gid = $this->request->get('gid', 0); + $uid = $this->request->get('uid', 0); + if (!$gid || !$uid) { + return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); + } + $oldInfo = ApiAuthGroupAccess::get(['uid' => $uid])->toArray(); + $oldGroupArr = explode(',', $oldInfo['groupId']); + $key = array_search($gid, $oldGroupArr); + unset($oldGroupArr[$key]); + $newData = implode(',', $oldGroupArr); + $res = ApiAuthGroupAccess::update([ + 'groupId' => $newData + ],[ + 'uid' => $uid + ]); + if ($res === false) { + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + } else { + return $this->buildSuccess([]); + } + } + /** * 构建适用前端的权限数据 * @param $list diff --git a/application/adminRoute.php b/application/adminRoute.php index 5921819..ad4a9b2 100644 --- a/application/adminRoute.php +++ b/application/adminRoute.php @@ -63,6 +63,10 @@ return [ 'admin/Auth/changeStatus', ['method' => 'get', 'after_behavior' => $afterBehavior] ], + 'Auth/delMember' => [ + 'admin/Auth/delMember', + ['method' => 'get', 'after_behavior' => $afterBehavior] + ], 'Auth/add' => [ 'admin/Auth/add', ['method' => 'post', 'after_behavior' => $afterBehavior]