mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 统一数据库字段命名方式(驼峰命名法)
This commit is contained in:
parent
3afec99c92
commit
3c859b6d8b
@ -308,12 +308,12 @@ class Auth extends Base {
|
|||||||
public function del(){
|
public function del(){
|
||||||
if( $this->request->isDelete() ){
|
if( $this->request->isDelete() ){
|
||||||
$key = $this->request->delete($this->primaryKey);
|
$key = $this->request->delete($this->primaryKey);
|
||||||
$authAccessNum = AuthGroupAccess::where(['group_id' => $key])->count();
|
$authAccessNum = AuthGroupAccess::where(['groupId' => $key])->count();
|
||||||
if( $authAccessNum ){
|
if( $authAccessNum ){
|
||||||
$this->error('当前用户组存在用户不能删除!');
|
$this->error('当前用户组存在用户不能删除!');
|
||||||
}
|
}
|
||||||
AuthGroup::destroy([$this->primaryKey => $key]);
|
AuthGroup::destroy([$this->primaryKey => $key]);
|
||||||
AuthRule::destroy(['group_id' => $key]);
|
AuthRule::destroy(['groupId' => $key]);
|
||||||
$this->success('操作成功', url('Auth/index'));
|
$this->success('操作成功', url('Auth/index'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ class Auth extends Base {
|
|||||||
if( is_null($authAccessObj) ){
|
if( is_null($authAccessObj) ){
|
||||||
$authAccessObj = new AuthGroupAccess();
|
$authAccessObj = new AuthGroupAccess();
|
||||||
}
|
}
|
||||||
$authAccessObj->group_id = $this->request->put('group_id');
|
$authAccessObj->groupId = $this->request->put('groupId');
|
||||||
$authAccessObj->uid = $this->request->put('uid');
|
$authAccessObj->uid = $this->request->put('uid');
|
||||||
$authAccessObj->save();
|
$authAccessObj->save();
|
||||||
$this->success('操作成功', url('User/index'));
|
$this->success('操作成功', url('User/index'));
|
||||||
@ -336,7 +336,7 @@ class Auth extends Base {
|
|||||||
$authGroupArr = [];
|
$authGroupArr = [];
|
||||||
$authAccessObj = AuthGroupAccess::get(['uid' => $this->request->get($this->primaryKey)]);
|
$authAccessObj = AuthGroupAccess::get(['uid' => $this->request->get($this->primaryKey)]);
|
||||||
if( !is_null($authAccessObj) ){
|
if( !is_null($authAccessObj) ){
|
||||||
$authAccess = $authAccessObj->group_id;
|
$authAccess = $authAccessObj->groupId;
|
||||||
}
|
}
|
||||||
$authGroupObj = AuthGroup::all(['status' => 1]);
|
$authGroupObj = AuthGroup::all(['status' => 1]);
|
||||||
if( !empty($authGroupObj) ){
|
if( !empty($authGroupObj) ){
|
||||||
@ -370,7 +370,7 @@ class Auth extends Base {
|
|||||||
'description' => '',
|
'description' => '',
|
||||||
'info' => '请选择用户组:',
|
'info' => '请选择用户组:',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'name' => 'group_id',
|
'name' => 'groupId',
|
||||||
'value' => $authAccess,
|
'value' => $authAccess,
|
||||||
'options' => $authGroupArr
|
'options' => $authGroupArr
|
||||||
]
|
]
|
||||||
@ -391,7 +391,7 @@ class Auth extends Base {
|
|||||||
$this->success('操作成功', url('Auth/index'));
|
$this->success('操作成功', url('Auth/index'));
|
||||||
}else{
|
}else{
|
||||||
$data = [];
|
$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) ){
|
if( !empty($dataArrObj) ){
|
||||||
foreach ( $dataArrObj as $dataObj ){
|
foreach ( $dataArrObj as $dataObj ){
|
||||||
$userObj = User::get([$this->primaryKey => $dataObj->uid]);
|
$userObj = User::get([$this->primaryKey => $dataObj->uid]);
|
||||||
@ -476,14 +476,14 @@ class Auth extends Base {
|
|||||||
$deleteAuth = $this->request->put('delete');
|
$deleteAuth = $this->request->put('delete');
|
||||||
$postAuth = $this->request->put('post');
|
$postAuth = $this->request->put('post');
|
||||||
$auth = \Permission::AUTH_GET * $getAuth + \Permission::AUTH_DELETE * $deleteAuth + \Permission::AUTH_POST * $postAuth + \Permission::AUTH_PUT * $putAuth;
|
$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 ){
|
if( $authDetail ){
|
||||||
$authDetail->auth = $auth;
|
$authDetail->auth = $auth;
|
||||||
$authDetail->save();
|
$authDetail->save();
|
||||||
}else{
|
}else{
|
||||||
$newAuthDetail = new AuthRule();
|
$newAuthDetail = new AuthRule();
|
||||||
$newAuthDetail->url = $url;
|
$newAuthDetail->url = $url;
|
||||||
$newAuthDetail->group_id = $gid;
|
$newAuthDetail->groupId = $gid;
|
||||||
$newAuthDetail->auth = $auth;
|
$newAuthDetail->auth = $auth;
|
||||||
$newAuthDetail->save();
|
$newAuthDetail->save();
|
||||||
}
|
}
|
||||||
@ -495,7 +495,7 @@ class Auth extends Base {
|
|||||||
}else{
|
}else{
|
||||||
session('authGid', $gid);
|
session('authGid', $gid);
|
||||||
}
|
}
|
||||||
$authRuleArr = AuthRule::where(['group_id' => $gid])->select();
|
$authRuleArr = AuthRule::where(['groupId' => $gid])->select();
|
||||||
if( $authRuleArr ){
|
if( $authRuleArr ){
|
||||||
$authRule = [];
|
$authRule = [];
|
||||||
foreach ( $authRuleArr as $value ){
|
foreach ( $authRuleArr as $value ){
|
||||||
|
@ -42,7 +42,7 @@ DROP TABLE IF EXISTS `auth_group_access`;
|
|||||||
CREATE TABLE `auth_group_access` (
|
CREATE TABLE `auth_group_access` (
|
||||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`uid` mediumint(8) unsigned NOT NULL,
|
`uid` mediumint(8) unsigned NOT NULL,
|
||||||
`group_id` mediumint(8) unsigned NOT NULL,
|
`groupId` mediumint(8) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `uid` (`uid`)
|
KEY `uid` (`uid`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户和组的对应关系';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户和组的对应关系';
|
||||||
@ -55,7 +55,7 @@ DROP TABLE IF EXISTS `auth_rule`;
|
|||||||
CREATE TABLE `auth_rule` (
|
CREATE TABLE `auth_rule` (
|
||||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`url` char(80) NOT NULL DEFAULT '' COMMENT '规则唯一标识',
|
`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 '权限数值',
|
`auth` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限数值',
|
||||||
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用',
|
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
|
@ -105,12 +105,12 @@ class Permission {
|
|||||||
if( !empty($userGroups) ){
|
if( !empty($userGroups) ){
|
||||||
$groups[$uid] = [];
|
$groups[$uid] = [];
|
||||||
foreach( $userGroups as $value ){
|
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( !is_null($groupInfo) ){
|
||||||
if( $groupInfo['status'] != 1 ){
|
if( $groupInfo['status'] != 1 ){
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
$groups[$uid][] = $value['group_id'];
|
$groups[$uid][] = $value['groupId'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ class Permission {
|
|||||||
|
|
||||||
$authList = [];
|
$authList = [];
|
||||||
foreach ($groups as $g) {
|
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) ){
|
if( !empty($groupRule) ){
|
||||||
foreach ( $groupRule as $groupValue ){
|
foreach ( $groupRule as $groupValue ){
|
||||||
if( isset($authList[$groupValue['url']]) ){
|
if( isset($authList[$groupValue['url']]) ){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user