From 6619202a6de10c6467aa211e347853e262cecfe0 Mon Sep 17 00:00:00 2001 From: zhaoxiang Date: Sun, 11 Feb 2018 15:00:03 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=86=8D=E5=88=A0=E9=99=A4=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=B0=86=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BB=84=E5=86=85=E5=85=A8=E9=83=A8=E6=88=90?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Auth.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index ba0595e..b998e65 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -172,6 +172,9 @@ class Auth extends Base { /** * 删除组 * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException * @author zhaoxiang */ public function del() { @@ -179,6 +182,20 @@ class Auth extends Base { if (!$id) { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); } + + $listInfo = (new ApiAuthGroupAccess())->where(['groupId' => ['like', "%{$id}%"]])->select(); + if ($listInfo) { + foreach ($listInfo as $value) { + $valueArr = $value->toArray(); + $oldGroupArr = explode(',', $valueArr['groupId']); + $key = array_search($id, $oldGroupArr); + unset($oldGroupArr[$key]); + $newData = implode(',', $oldGroupArr); + $value->groupId = $newData; + $value->save(); + } + } + ApiAuthGroup::destroy($id); ApiAuthRule::destroy(['groupId' => $id]); @@ -205,7 +222,7 @@ class Auth extends Base { $newData = implode(',', $oldGroupArr); $res = ApiAuthGroupAccess::update([ 'groupId' => $newData - ],[ + ], [ 'uid' => $uid ]); if ($res === false) {