modified 完善全部用户,权限数据配置

This commit is contained in:
zhaoxiang 2018-02-11 10:44:19 +08:00
parent 4ada83083b
commit 5d10d7ac78
2 changed files with 35 additions and 0 deletions

View File

@ -9,6 +9,7 @@ namespace app\admin\controller;
use app\model\ApiAuthGroup; use app\model\ApiAuthGroup;
use app\model\ApiAuthGroupAccess;
use app\model\ApiAuthRule; use app\model\ApiAuthRule;
use app\model\ApiMenu; use app\model\ApiMenu;
use app\util\ReturnCode; use app\util\ReturnCode;
@ -184,6 +185,36 @@ class Auth extends Base {
return $this->buildSuccess([]); return $this->buildSuccess([]);
} }
/**
* 从指定组中删除指定用户
* @return array
* @throws \think\Exception
* @throws \think\exception\DbException
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
public function delMember() {
$gid = $this->request->get('gid', 0);
$uid = $this->request->get('uid', 0);
if (!$gid || !$uid) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
}
$oldInfo = ApiAuthGroupAccess::get(['uid' => $uid])->toArray();
$oldGroupArr = explode(',', $oldInfo['groupId']);
$key = array_search($gid, $oldGroupArr);
unset($oldGroupArr[$key]);
$newData = implode(',', $oldGroupArr);
$res = ApiAuthGroupAccess::update([
'groupId' => $newData
],[
'uid' => $uid
]);
if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else {
return $this->buildSuccess([]);
}
}
/** /**
* 构建适用前端的权限数据 * 构建适用前端的权限数据
* @param $list * @param $list

View File

@ -63,6 +63,10 @@ return [
'admin/Auth/changeStatus', 'admin/Auth/changeStatus',
['method' => 'get', 'after_behavior' => $afterBehavior] ['method' => 'get', 'after_behavior' => $afterBehavior]
], ],
'Auth/delMember' => [
'admin/Auth/delMember',
['method' => 'get', 'after_behavior' => $afterBehavior]
],
'Auth/add' => [ 'Auth/add' => [
'admin/Auth/add', 'admin/Auth/add',
['method' => 'post', 'after_behavior' => $afterBehavior] ['method' => 'post', 'after_behavior' => $afterBehavior]