where(['node' => $node, 'is_auth' => 1])->find(); if (empty($is_auth)) return true; //获取当前用户角色组信息 ,拆表 $user = new \app\admin\model\User; $auth_id_list = json_decode($user->where(['id' => session('user.id'), 'status' => 1, 'is_deleted' => 0])->value('auth_id'), true); //去除失效的角色组信息 foreach ($auth_id_list as $k => $val) { if (empty(model('SysAuth')->where(['id' => $val, 'status' => 1])->find())) unset($auth_id_list[$k]); } //判断是否有权限访问 foreach ($auth_id_list as $vo) { if ($vo == 0) return true; //超级管理员组权限 $is_auth_node = model('SysAuthNode')->where(['auth' => $vo, 'node' => $is_auth['id']])->find(); if (!empty($is_auth_node)) return true; } return false; } /** * 获取当前节点 * @return string 节点信息 */ public static function getNode() { $node = app('request')->module() . '/' . app('request')->controller() . '/' . app('request')->action(); return self::parseNodeStr($node); } /** * 驼峰转下划线规则 * @param string $node * @return string */ public static function parseNodeStr($node) { $tmp = []; foreach (explode('/', $node) as $name) { $tmp[] = strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_")); } return str_replace('._', '.', trim(join('/', $tmp), '/')); } }