getPathInfo())[0],"/api/")); //去除前缀 array_shift($routes); $routeStr = implode("/",$routes); $authorities = app("AuthorityService")->getUserAndroidAuthority(); foreach ($authorities as $authority){ if ($this->method() != Authority::METHOD[$authority->method])continue; if ($authority->route == $routeStr)return true; //相等 if (!str_contains($authority->route, "*"))continue;//无泛匹配符 $route = explode("/",$authority->route); $crLen = count($routes); $trLen = count($route); if ($crLen<$trLen)continue; if ($crLen>$trLen && $route[$trLen-1]=='*'){ $routes = array_slice($routes,0,$trLen); $crLen = $trLen; } if ($crLen!=$trLen)continue; foreach ($route as $index=>$item){ if ($item=='*')$route[$index] = $routes[$index]; } if (implode("/",$route)==$routeStr)return true; } return false; } public function failedAuthorization() { $this->response(false,403,"权限不足"); } public function rules():array { return []; } }