mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 接口部分兼容普通模式和加密模式
This commit is contained in:
parent
5c926c57b8
commit
3d0cd21a76
@ -182,7 +182,11 @@ class InterfaceList extends Base {
|
|||||||
$listInfo = AdminList::all(['status' => 1]);
|
$listInfo = AdminList::all(['status' => 1]);
|
||||||
$tplStr = [];
|
$tplStr = [];
|
||||||
foreach ($listInfo as $value) {
|
foreach ($listInfo as $value) {
|
||||||
array_push($tplStr, 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);');
|
if($value['hash_type'] === 1) {
|
||||||
|
array_push($tplStr, 'Route::rule(\'' . addslashes($value->api_class) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);');
|
||||||
|
} else {
|
||||||
|
array_push($tplStr, 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$tplOriginStr = str_replace(['{$API_RULE}'], [implode($tplStr, "\n ")], $tplOriginStr);
|
$tplOriginStr = str_replace(['{$API_RULE}'], [implode($tplStr, "\n ")], $tplOriginStr);
|
||||||
|
|
||||||
|
@ -25,16 +25,24 @@ class ApiAuth {
|
|||||||
if ($cached) {
|
if ($cached) {
|
||||||
$apiInfo = Cache::get('ApiInfo:' . $apiHash);
|
$apiInfo = Cache::get('ApiInfo:' . $apiHash);
|
||||||
} else {
|
} else {
|
||||||
$apiInfo = AdminList::get(['hash' => $apiHash]);
|
$apiInfo = AdminList::get(['hash' => $apiHash, 'hash_type' => 2]);
|
||||||
if ($apiInfo) {
|
if ($apiInfo) {
|
||||||
$apiInfo = $apiInfo->toArray();
|
$apiInfo = $apiInfo->toArray();
|
||||||
|
Cache::rm('ApiInfo:' . $apiInfo['api_class']);
|
||||||
Cache::set('ApiInfo:' . $apiHash, $apiInfo);
|
Cache::set('ApiInfo:' . $apiHash, $apiInfo);
|
||||||
} else {
|
} else {
|
||||||
return json([
|
$apiInfo = AdminList::get(['api_class' => $apiHash, 'hash_type' => 1]);
|
||||||
'code' => ReturnCode::DB_READ_ERROR,
|
if ($apiInfo) {
|
||||||
'msg' => '获取接口配置数据失败',
|
$apiInfo = $apiInfo->toArray();
|
||||||
'data' => []
|
Cache::rm('ApiInfo:' . $apiInfo['hash']);
|
||||||
])->header($header);
|
Cache::set('ApiInfo:' . $apiHash, $apiInfo);
|
||||||
|
} else {
|
||||||
|
return json([
|
||||||
|
'code' => ReturnCode::DB_READ_ERROR,
|
||||||
|
'msg' => '获取接口配置数据失败',
|
||||||
|
'data' => []
|
||||||
|
])->header($header);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +81,7 @@ class ApiAuth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 简易鉴权,更具APP_SECRET获取应用信=/.
|
* 简易鉴权,更具APP_SECRET获取应用信息
|
||||||
* @param $accessToken
|
* @param $accessToken
|
||||||
* @return bool|mixed
|
* @return bool|mixed
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user