mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-08-29 12:23:25 +08:00
modified 完成新接口路由的升级
This commit is contained in:
parent
9668106808
commit
4bf044fedc
@ -181,13 +181,15 @@ class InterfaceList extends Base {
|
|||||||
$tplPath = $rootPath . 'application/install/apiRoute.tpl';
|
$tplPath = $rootPath . 'application/install/apiRoute.tpl';
|
||||||
$methodArr = ['*', 'POST', 'GET'];
|
$methodArr = ['*', 'POST', 'GET'];
|
||||||
|
|
||||||
$tplStr = file_get_contents($tplPath);
|
$tplOriginStr = file_get_contents($tplPath);
|
||||||
$listInfo = AdminList::all(['status' => 1]);
|
$listInfo = AdminList::all(['status' => 1]);
|
||||||
|
$tplStr = '';
|
||||||
foreach ($listInfo as $value) {
|
foreach ($listInfo as $value) {
|
||||||
$tplStr .= 'Route::rule(\'api/' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\', [\'after_behavior\' => $afterBehavior]);';
|
$tplStr .= 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'ApiLog\']);';
|
||||||
}
|
}
|
||||||
|
$tplOriginStr = str_replace(['{$API_RULE}'], [$tplStr], $tplOriginStr);
|
||||||
|
|
||||||
file_put_contents($apiRoutePath, $tplStr);
|
file_put_contents($apiRoutePath, $tplOriginStr);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess([]);
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@ namespace app\api\controller;
|
|||||||
|
|
||||||
|
|
||||||
use app\util\StrRandom;
|
use app\util\StrRandom;
|
||||||
|
use think\facade\App;
|
||||||
|
|
||||||
class Miss extends Base {
|
class Miss extends Base {
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->debug([
|
$this->debug([
|
||||||
'TpVersion' => THINK_VERSION,
|
'TpVersion' => App::version(),
|
||||||
'Float' => StrRandom::randomPhone()
|
'Float' => StrRandom::randomPhone()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -6,5 +6,6 @@ class ApiAuth
|
|||||||
{
|
{
|
||||||
public function handle($request, \Closure $next)
|
public function handle($request, \Closure $next)
|
||||||
{
|
{
|
||||||
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@ class ApiLog
|
|||||||
{
|
{
|
||||||
public function handle($request, \Closure $next)
|
public function handle($request, \Closure $next)
|
||||||
{
|
{
|
||||||
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@ class ApiPermission
|
|||||||
{
|
{
|
||||||
public function handle($request, \Closure $next)
|
public function handle($request, \Closure $next)
|
||||||
{
|
{
|
||||||
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@ class ApiResponse
|
|||||||
{
|
{
|
||||||
public function handle($request, \Closure $next)
|
public function handle($request, \Closure $next)
|
||||||
{
|
{
|
||||||
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
* Api路由
|
* Api路由
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use think\Route;
|
use think\facade\Route;
|
||||||
|
|
||||||
Route::group('api', function () {
|
Route::group('api', function() {
|
||||||
|
{$API_RULE}
|
||||||
|
//MISS路由定义
|
||||||
Route::miss('api/Miss/index');
|
Route::miss('api/Miss/index');
|
||||||
});
|
})->middleware('ApiResponse');
|
||||||
$afterBehavior = [
|
|
||||||
'\app\api\behavior\ApiAuth',
|
|
||||||
'\app\api\behavior\ApiPermission',
|
|
||||||
'\app\api\behavior\RequestFilter'
|
|
||||||
];
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user