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(){
|
||||
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 ){
|
||||
|
@ -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`),
|
||||
|
@ -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']]) ){
|
||||
|
Loading…
x
Reference in New Issue
Block a user