提交修改
This commit is contained in:
parent
856cba0466
commit
2980a9dd34
@ -263,4 +263,30 @@ class Auth
|
||||
|
||||
return $user_info[$uid];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id获取Api用户组,返回值为数组
|
||||
* @param int $uid 用户id
|
||||
* @return array 用户所属的用户组 array(
|
||||
* array('uid'=>'用户id','group_id'=>'用户组id','name'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
|
||||
* ...)
|
||||
*/
|
||||
public function getApiGroups($uid)
|
||||
{
|
||||
static $groups = [];
|
||||
if (isset($groups[$uid])) {
|
||||
return $groups[$uid];
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
$user_groups = Db::name('api_auth_group_access')
|
||||
->alias('aga')
|
||||
->join('__' . strtoupper("api_auth_group") . '__ ag', 'aga.group_id = ag.id', 'LEFT')
|
||||
->field('aga.uid,aga.group_id,ag.id,ag.pid,ag.name,ag.rules')
|
||||
->where("aga.uid='{$uid}' and ag.status='normal'")
|
||||
->select();
|
||||
$groups[$uid] = $user_groups ?: [];
|
||||
return $groups[$uid];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user