mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 优化接口
This commit is contained in:
parent
372a8109ec
commit
7c3ddddbd5
@ -108,29 +108,15 @@ class Api extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function detail() {
|
public function detail() {
|
||||||
$groupHash = $this->request->route('groupHash');
|
$hash = $this->request->get('hash');
|
||||||
$hash = $this->request->route('hash', '');
|
|
||||||
$this->appInfo['app_api_show'] = json_decode($this->appInfo['app_api_show'], true);
|
|
||||||
if (!isset($this->appInfo['app_api_show'][$groupHash]) || empty($this->appInfo['app_api_show'][$groupHash])) {
|
|
||||||
$this->error('请求非法', url('/wiki/index'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$hash) {
|
if (!$hash) {
|
||||||
$hash = $this->appInfo['app_api_show'][$groupHash][0];
|
return $this->buildFailed(ReturnCode::NOT_EXISTS, '缺少必要参数');
|
||||||
} else {
|
|
||||||
if (!in_array($hash, $this->appInfo['app_api_show'][$groupHash])) {
|
|
||||||
$this->error('请求非法', url('/wiki/index'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$apiList = (new AdminList())->whereIn('hash', $this->appInfo['app_api_show'][$groupHash])->where(['group_hash' => $groupHash])->select();
|
$apiList = (new AdminList())->whereIn('hash', $hash)->find();
|
||||||
$apiList = Tools::buildArrFromObj($apiList);
|
if (!$apiList) {
|
||||||
$apiList = Tools::buildArrByNewKey($apiList, 'hash');
|
return $this->buildFailed(ReturnCode::NOT_EXISTS, '接口hash非法');
|
||||||
|
|
||||||
if (!$hash) {
|
|
||||||
$hash = $this->appInfo['app_api_show'][$groupHash][0];
|
|
||||||
}
|
}
|
||||||
$detail = $apiList[$hash];
|
|
||||||
|
|
||||||
$request = AdminFields::all(['hash' => $hash, 'type' => 0]);
|
$request = AdminFields::all(['hash' => $hash, 'type' => 0]);
|
||||||
$response = AdminFields::all(['hash' => $hash, 'type' => 1]);
|
$response = AdminFields::all(['hash' => $hash, 'type' => 1]);
|
||||||
@ -146,19 +132,16 @@ class Api extends Base {
|
|||||||
DataType::TYPE_MOBILE => 'Mobile'
|
DataType::TYPE_MOBILE => 'Mobile'
|
||||||
);
|
);
|
||||||
|
|
||||||
$groupInfo = AdminGroup::get(['hash' => $groupHash]);
|
$groupInfo = AdminGroup::get(['hash' => $apiList['group_hash']]);
|
||||||
$groupInfo->hot = $groupInfo->hot + 1;
|
$groupInfo->hot = $groupInfo->hot + 1;
|
||||||
$groupInfo->save();
|
$groupInfo->save();
|
||||||
|
|
||||||
return view('', [
|
return $this->buildSuccess([
|
||||||
'groupInfo' => $groupInfo->toArray(),
|
'request' => $request,
|
||||||
'request' => $request,
|
'response' => $response,
|
||||||
'response' => $response,
|
'dataType' => $dataType,
|
||||||
'dataType' => $dataType,
|
'apiList' => $apiList,
|
||||||
'apiList' => $apiList,
|
'url' => $this->request->domain() . '/api/' . $hash
|
||||||
'detail' => $detail,
|
|
||||||
'hash' => $hash,
|
|
||||||
'groupHash' => $groupHash
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
use think\facade\Route;
|
use think\facade\Route;
|
||||||
|
|
||||||
Route::group('wiki', function() {
|
Route::group('wiki', function() {
|
||||||
|
Route::rule(
|
||||||
|
'Api/login', 'wiki/Api/login', 'post'
|
||||||
|
);
|
||||||
Route::group('Api', [
|
Route::group('Api', [
|
||||||
'errorCode' => [
|
'errorCode' => [
|
||||||
'wiki/Api/errorCode',
|
'wiki/Api/errorCode',
|
||||||
@ -17,10 +20,6 @@ Route::group('wiki', function() {
|
|||||||
'wiki/Api/groupList',
|
'wiki/Api/groupList',
|
||||||
['method' => 'get']
|
['method' => 'get']
|
||||||
],
|
],
|
||||||
'login' => [
|
|
||||||
'wiki/Api/login',
|
|
||||||
['method' => 'post']
|
|
||||||
],
|
|
||||||
'detail' => [
|
'detail' => [
|
||||||
'wiki/Api/detail',
|
'wiki/Api/detail',
|
||||||
['method' => 'get']
|
['method' => 'get']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user