62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
![]() |
<?php
|
|||
|
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | ThinkAdmin
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | 官方网站: https://thinkadmin.top
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | 开源协议 ( https://mit-license.org )
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
|||
|
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
|||
|
// +----------------------------------------------------------------------
|
|||
|
|
|||
|
use think\admin\service\SystemService;
|
|||
|
use think\exception\HttpResponseException;
|
|||
|
use think\Route;
|
|||
|
//use think\admin\support\Route;
|
|||
|
|
|||
|
app()->route->get('api/open/code1','gateway/api.card/add');
|
|||
|
$version = request()->post('version');
|
|||
|
//var_dump($version);die;
|
|||
|
if(!$version){
|
|||
|
$version = request()->param('version');
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//默认跳转到v1版本
|
|||
|
if ($version == null) $version = "api";#api.notify,url
|
|||
|
|
|||
|
$pathInfo = request()->pathinfo();
|
|||
|
if ($pathInfo == null) {
|
|||
|
$json = [
|
|||
|
'code' => -802,
|
|||
|
'data'=>'',
|
|||
|
'msg' =>'请求错误'
|
|||
|
];
|
|||
|
// var_dump($json);
|
|||
|
throw new HttpResponseException(json($json));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if($version!='api'){
|
|||
|
if(!strstr($pathInfo,'api.')){
|
|||
|
app()->route->rule(':controller/:function', $version . '.:controller/:function');
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}else{
|
|||
|
// var_dump(123);
|
|||
|
if(!strstr($pathInfo,'api.')){
|
|||
|
// var_dump($version);die;
|
|||
|
app()->route->rule(':controller/:function', 'api' . '.:controller/:function');
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|