mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 完善全部用户,权限数据配置
This commit is contained in:
parent
4ada83083b
commit
5d10d7ac78
@ -9,6 +9,7 @@ namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\model\ApiAuthGroup;
|
||||
use app\model\ApiAuthGroupAccess;
|
||||
use app\model\ApiAuthRule;
|
||||
use app\model\ApiMenu;
|
||||
use app\util\ReturnCode;
|
||||
@ -184,6 +185,36 @@ class Auth extends Base {
|
||||
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
|
||||
|
@ -63,6 +63,10 @@ return [
|
||||
'admin/Auth/changeStatus',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Auth/delMember' => [
|
||||
'admin/Auth/delMember',
|
||||
['method' => 'get', 'after_behavior' => $afterBehavior]
|
||||
],
|
||||
'Auth/add' => [
|
||||
'admin/Auth/add',
|
||||
['method' => 'post', 'after_behavior' => $afterBehavior]
|
||||
|
Loading…
x
Reference in New Issue
Block a user