From a4f6a29c09dfc04a7e05c6f00bed134b7c1c9542 Mon Sep 17 00:00:00 2001 From: cxb <1151671293@qq.com> Date: Fri, 22 Nov 2019 16:25:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=BB=84=E7=BC=96=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E5=8F=96=E6=B6=88=E6=9F=90=E4=B8=AA=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=BB=84=E6=9D=83=E9=99=90=E8=8A=82=E7=82=B9=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=8A=8A=E8=AF=A5=E6=9D=83=E9=99=90=E7=BB=84=E7=9A=84?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=AD=90=E6=9D=83=E9=99=90=E7=BB=84=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E7=9B=B8=E5=BA=94=E6=9D=83=E9=99=90=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E4=B9=9F=E5=8F=96=E6=B6=88=EF=BC=8C=E9=81=BF=E5=85=8D=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=88=B6=E8=8A=82=E7=82=B9=E8=8A=82=E7=82=B9=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=90=8E=E5=AD=90=E8=8A=82=E7=82=B9=E4=BB=8D=E5=8F=AF?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/auth/Group.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index b3a9026f8..8fa5d1c8d 100644 --- a/application/admin/controller/auth/Group.php +++ b/application/admin/controller/auth/Group.php @@ -5,6 +5,8 @@ namespace app\admin\controller\auth; use app\admin\model\AuthGroup; use app\common\controller\Backend; use fast\Tree; +use think\Db; +use think\Exception; /** * 角色组 @@ -151,8 +153,22 @@ class Group extends Backend $rules = in_array('*', $currentrules) ? $rules : array_intersect($currentrules, $rules); $params['rules'] = implode(',', $rules); if ($params) { - $row->save($params); - $this->success(); + Db::startTrans(); + try { + $row->save($params); + $children_auth_groups = model("AuthGroup")->all(['id'=>['in',implode(',',(Tree::instance()->getChildrenIds($row->id)))]]); + $childparams = []; + foreach ($children_auth_groups as $key=>$children_auth_group) { + $childparams[$key]['id'] = $children_auth_group->id; + $childparams[$key]['rules'] = implode(',', array_intersect(explode(',', $children_auth_group->rules), $rules)); + } + model("AuthGroup")->saveAll($childparams); + Db::commit(); + $this->success(); + }catch (Exception $e){ + Db::rollback(); + $this->error($e->getMessage()); + } } $this->error(); return; -- Gitee