diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 26fe438..4e80d22 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -134,4 +134,25 @@ class InterfaceList extends Base { return $this->buildSuccess([]); } + + /** + * 刷新接口路由 + * @author zhaoxiang + * @return array + * @throws \think\exception\DbException + */ + public function refresh() { + $apiRoutePath = ROOT_PATH . 'application/apiRoute.php'; + $tplPath = ROOT_PATH . 'data/apiRoute.tpl'; + $methodArr = ['*','POST','GET']; + + $tplStr = file_get_contents($tplPath); + $listInfo = ApiList::all(['status' => 1]); + foreach ($listInfo as $value) { + $tplStr .= 'Route::rule(\'api/'.$value->hash.'\',\'api/'.$value->apiClass.'\', \''.$methodArr[$value->method].'\', [\'after_behavior\' => $afterBehavior]);'; + } + + file_put_contents($apiRoutePath, $tplStr); + return $this->buildSuccess([]); + } } diff --git a/application/adminRoute.php b/application/adminRoute.php index a6ca600..582d0cc 100644 --- a/application/adminRoute.php +++ b/application/adminRoute.php @@ -115,6 +115,10 @@ return [ 'admin/InterfaceList/index', ['method' => 'get', 'after_behavior' => $afterBehavior] ], + 'InterfaceList/refresh' => [ + 'admin/InterfaceList/refresh', + ['method' => 'get', 'after_behavior' => $afterBehavior] + ], 'InterfaceList/changeStatus' => [ 'admin/InterfaceList/changeStatus', ['method' => 'get', 'after_behavior' => $afterBehavior] diff --git a/application/api/controller/Miss.php b/application/api/controller/Miss.php index 1d55d92..26def17 100644 --- a/application/api/controller/Miss.php +++ b/application/api/controller/Miss.php @@ -7,6 +7,6 @@ use app\util\ReturnCode; class Miss extends Base { public function index() { - return $this->buildFailed(ReturnCode::NOT_EXISTS, '接口Hash异常:'.uniqid()); + return $this->buildFailed(ReturnCode::NOT_EXISTS, '接口Hash异常'); } } diff --git a/application/config.php b/application/config.php index ba55cb6..bab7925 100755 --- a/application/config.php +++ b/application/config.php @@ -93,7 +93,7 @@ return [ // 路由使用完整匹配 'route_complete_match' => false, // 路由配置文件(支持配置多个) - 'route_config_file' => ['adminRoute', 'apiRoute'], + 'route_config_file' => ['adminRoute', 'apiRoute', 'wikiRoute'], // 是否强制使用路由 'url_route_must' => true, // 域名部署 diff --git a/application/apiRoute.php b/application/wikiRoute.php similarity index 54% rename from application/apiRoute.php rename to application/wikiRoute.php index 98e6158..95db9ff 100644 --- a/application/apiRoute.php +++ b/application/wikiRoute.php @@ -1,28 +1,9 @@ [ - '5a9363c133719' => [ - 'api/BuildToken/getAccessToken', - ['method' => 'get', 'after_behavior' => $afterBehavior] - ], - '5a93646b40ab5' => [ - 'api/BuildToken/e1', - ['method' => 'get', 'after_behavior' => $afterBehavior] - ], - '5a93648c769f8' => [ - 'api/BuildToken/e2', - ['method' => 'get', 'after_behavior' => $afterBehavior] - ], - '__miss__' => ['api/Miss/index'], - ], '[wiki]' => [ 'login' => [ 'wiki/index/login', diff --git a/data/apiRoute.tpl b/data/apiRoute.tpl new file mode 100644 index 0000000..6f97d7f --- /dev/null +++ b/data/apiRoute.tpl @@ -0,0 +1,8 @@ +