From 3c859b6d8b8ca2373409f8daaa0ad055322eee15 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Tue, 22 Nov 2016 16:01:56 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E7=BB=9F=E4=B8=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=AD=97=E6=AE=B5=E5=91=BD=E5=90=8D=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=88=E9=A9=BC=E5=B3=B0=E5=91=BD=E5=90=8D=E6=B3=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Auth.php | 18 +++++++++--------- application/install/data/install.sql | 4 ++-- extend/Permission.php | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index c825b9e..91d3278 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -308,12 +308,12 @@ class Auth extends Base { public function del(){ if( $this->request->isDelete() ){ $key = $this->request->delete($this->primaryKey); - $authAccessNum = AuthGroupAccess::where(['group_id' => $key])->count(); + $authAccessNum = AuthGroupAccess::where(['groupId' => $key])->count(); if( $authAccessNum ){ $this->error('当前用户组存在用户不能删除!'); } AuthGroup::destroy([$this->primaryKey => $key]); - AuthRule::destroy(['group_id' => $key]); + AuthRule::destroy(['groupId' => $key]); $this->success('操作成功', url('Auth/index')); } } @@ -327,7 +327,7 @@ class Auth extends Base { if( is_null($authAccessObj) ){ $authAccessObj = new AuthGroupAccess(); } - $authAccessObj->group_id = $this->request->put('group_id'); + $authAccessObj->groupId = $this->request->put('groupId'); $authAccessObj->uid = $this->request->put('uid'); $authAccessObj->save(); $this->success('操作成功', url('User/index')); @@ -336,7 +336,7 @@ class Auth extends Base { $authGroupArr = []; $authAccessObj = AuthGroupAccess::get(['uid' => $this->request->get($this->primaryKey)]); if( !is_null($authAccessObj) ){ - $authAccess = $authAccessObj->group_id; + $authAccess = $authAccessObj->groupId; } $authGroupObj = AuthGroup::all(['status' => 1]); if( !empty($authGroupObj) ){ @@ -370,7 +370,7 @@ class Auth extends Base { 'description' => '', 'info' => '请选择用户组:', 'attr' => [ - 'name' => 'group_id', + 'name' => 'groupId', 'value' => $authAccess, 'options' => $authGroupArr ] @@ -391,7 +391,7 @@ class Auth extends Base { $this->success('操作成功', url('Auth/index')); }else{ $data = []; - $dataArrObj = AuthGroupAccess::where(['group_id' => $this->request->get($this->primaryKey)])->select(); + $dataArrObj = AuthGroupAccess::where(['groupId' => $this->request->get($this->primaryKey)])->select(); if( !empty($dataArrObj) ){ foreach ( $dataArrObj as $dataObj ){ $userObj = User::get([$this->primaryKey => $dataObj->uid]); @@ -476,14 +476,14 @@ class Auth extends Base { $deleteAuth = $this->request->put('delete'); $postAuth = $this->request->put('post'); $auth = \Permission::AUTH_GET * $getAuth + \Permission::AUTH_DELETE * $deleteAuth + \Permission::AUTH_POST * $postAuth + \Permission::AUTH_PUT * $putAuth; - $authDetail = AuthRule::get( ['group_id' => $gid, 'url' => $url] ); + $authDetail = AuthRule::get( ['groupId' => $gid, 'url' => $url] ); if( $authDetail ){ $authDetail->auth = $auth; $authDetail->save(); }else{ $newAuthDetail = new AuthRule(); $newAuthDetail->url = $url; - $newAuthDetail->group_id = $gid; + $newAuthDetail->groupId = $gid; $newAuthDetail->auth = $auth; $newAuthDetail->save(); } @@ -495,7 +495,7 @@ class Auth extends Base { }else{ session('authGid', $gid); } - $authRuleArr = AuthRule::where(['group_id' => $gid])->select(); + $authRuleArr = AuthRule::where(['groupId' => $gid])->select(); if( $authRuleArr ){ $authRule = []; foreach ( $authRuleArr as $value ){ diff --git a/application/install/data/install.sql b/application/install/data/install.sql index 552c996..658fb4f 100644 --- a/application/install/data/install.sql +++ b/application/install/data/install.sql @@ -42,7 +42,7 @@ DROP TABLE IF EXISTS `auth_group_access`; CREATE TABLE `auth_group_access` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `uid` mediumint(8) unsigned NOT NULL, - `group_id` mediumint(8) unsigned NOT NULL, + `groupId` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `uid` (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户和组的对应关系'; @@ -55,7 +55,7 @@ DROP TABLE IF EXISTS `auth_rule`; CREATE TABLE `auth_rule` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `url` char(80) NOT NULL DEFAULT '' COMMENT '规则唯一标识', - `group_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限所属组的ID', + `groupId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限所属组的ID', `auth` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限数值', `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用', PRIMARY KEY (`id`), diff --git a/extend/Permission.php b/extend/Permission.php index ea6b33e..5e40e7f 100644 --- a/extend/Permission.php +++ b/extend/Permission.php @@ -105,12 +105,12 @@ class Permission { if( !empty($userGroups) ){ $groups[$uid] = []; foreach( $userGroups as $value ){ - $groupInfo = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_GROUP'])->where(['id' => $value['group_id']])->find(); + $groupInfo = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_GROUP'])->where(['id' => $value['groupId']])->find(); if( !is_null($groupInfo) ){ if( $groupInfo['status'] != 1 ){ continue; }else{ - $groups[$uid][] = $value['group_id']; + $groups[$uid][] = $value['groupId']; } } } @@ -148,7 +148,7 @@ class Permission { $authList = []; foreach ($groups as $g) { - $groupRule = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_RULE'])->where(['group_id' => $g])->select(); + $groupRule = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_RULE'])->where(['groupId' => $g])->select(); if( !empty($groupRule) ){ foreach ( $groupRule as $groupValue ){ if( isset($authList[$groupValue['url']]) ){