From 62f362e19980aafd56f5566ec410c9a0230230dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Tue, 11 Jun 2019 16:32:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/http/middleware/YanZheng.php | 2 +- application/index/controller/Index.php | 30 ++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/application/http/middleware/YanZheng.php b/application/http/middleware/YanZheng.php index 1ae696bf..65576092 100644 --- a/application/http/middleware/YanZheng.php +++ b/application/http/middleware/YanZheng.php @@ -50,7 +50,7 @@ class YanZheng extends Controller // 排除方法 $uneed_a = array( 'welcome','upload','myinfo', - 'index','mybanji','banjilist', + 'mybanji','banjilist', 'editpassword','updatepassword', // 教师信息查询 'srcteacher','srcry','srckt', diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 84c0c3f2..804e3516 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -38,6 +38,25 @@ class Index extends Base // 获取用户名 $list->username = session('username'); + // 查询拥有的权限 + $admin = new \app\admin\model\Admin; + $admininfo = $admin->where('id',session('userid')) + ->field('id') + ->with([ + 'glGroup'=>function($query){ + $query->where('status',1)->field('title,rules,miaoshu'); + } + ]) + ->find(); + $rules = ''; + foreach ($admininfo->gl_group as $key => $value) { + if($key == 0){ + $rules = $value->rules; + }else{ + $rules = $rules.','.$value->rules; + } + } + // 实例化权限数据模型 $authrule = new \app\admin\model\AuthRule; @@ -45,15 +64,22 @@ class Index extends Base $list['menu'] = $authrule ->where('pid',0) ->where('status&ismenu',1) + ->when(session('userid')>2,function($query) use($rules){ + $query->where('id','in',$rules); + }) ->field('id,title,font,name,pid') ->with([ - 'authCid'=>function($query){ - $query->where('status&ismenu',1)->field('id,title,name,pid,url'); + 'authCid'=>function($query) use($rules){ + $query->where('status&ismenu',1) + ->where('id','in',$rules) + ->field('id,title,name,pid,url'); }, ]) ->order(['paixu']) ->select(); + + // 模版赋值 $this->assign('list',$list);