mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 完成接口文档自动生成,修复细节
This commit is contained in:
parent
2762eb8484
commit
48879c41e4
@ -98,11 +98,12 @@ class App extends Base {
|
||||
'app_api_show' => '',
|
||||
];
|
||||
if (isset($postData['app_api']) && $postData['app_api']) {
|
||||
$appApi = [];
|
||||
$data['app_api_show'] = json_encode($postData['app_api']);
|
||||
foreach ($postData['app_api'] as $value) {
|
||||
$data['app_api'] .= implode(',', $value) . ',';
|
||||
$appApi = array_merge($appApi, $value);
|
||||
}
|
||||
$data['app_api'] = trim($data['app_api'], ',');
|
||||
$data['app_api'] = implode(',', $appApi);
|
||||
}
|
||||
$res = ApiApp::create($data);
|
||||
if ($res === false) {
|
||||
@ -149,11 +150,12 @@ class App extends Base {
|
||||
'app_api_show' => '',
|
||||
];
|
||||
if (isset($postData['app_api']) && $postData['app_api']) {
|
||||
$appApi = [];
|
||||
$data['app_api_show'] = json_encode($postData['app_api']);
|
||||
foreach ($postData['app_api'] as $value) {
|
||||
$data['app_api'] .= implode(',', $value) . ',';
|
||||
$appApi = array_merge($appApi, $value);
|
||||
}
|
||||
$data['app_api'] = trim($data['app_api'], ',');
|
||||
$data['app_api'] = implode(',', $appApi);
|
||||
}
|
||||
$res = ApiApp::update($data);
|
||||
if ($res === false) {
|
||||
|
@ -64,7 +64,7 @@ class ApiAuth {
|
||||
* Api接口合法性检测
|
||||
*/
|
||||
private function checkAccessToken() {
|
||||
$access_token = $this->request->header('');
|
||||
$access_token = $this->request->header('access-token');
|
||||
if (!isset($access_token) || !$access_token) {
|
||||
return json(['code' => ReturnCode::ACCESS_TOKEN_TIMEOUT, 'msg' => '缺少参数access-token', 'data' => []]);
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* 处理app_id接入接口权限
|
||||
* 处理app_id接入接口权限 需要重新签发AccessToken才能生效新的权限
|
||||
* @since 2017-07-25
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
@ -8,23 +8,37 @@
|
||||
namespace app\api\behavior;
|
||||
|
||||
|
||||
use app\model\ApiFields;
|
||||
use app\util\ApiLog;
|
||||
use app\util\ReturnCode;
|
||||
use app\util\DataType;
|
||||
use think\Request;
|
||||
use think\Validate;
|
||||
|
||||
class ApiPermission {
|
||||
|
||||
/**
|
||||
* 默认行为函数
|
||||
* @var Request
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* 接口鉴权
|
||||
* @return \think\response\Json
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @return \think\Request
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function run() {
|
||||
$this->request = Request::instance();
|
||||
$hash = $this->request->routeInfo();
|
||||
if (isset($hash['rule'][1])) {
|
||||
$hash = $hash['rule'][1];
|
||||
$access_token = $this->request->header('access-token');
|
||||
if ($access_token) {
|
||||
$appInfo = cache($access_token);
|
||||
$allRules = explode(',', $appInfo['app_api']);
|
||||
if (!in_array($hash, $allRules)) {
|
||||
$data = ['code' => ReturnCode::INVALID, 'msg' => '非常抱歉,您没有权限怎么做!', 'data' => []];
|
||||
|
||||
return json($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,11 +50,11 @@ class BuildToken extends Base {
|
||||
}
|
||||
|
||||
public function e1() {
|
||||
return $this->buildSuccess('e1');
|
||||
return $this->buildSuccess(['e1']);
|
||||
}
|
||||
|
||||
public function e2() {
|
||||
return $this->buildSuccess('e2');
|
||||
return $this->buildSuccess(['e2']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
\think\Route::miss('api/Index/index');
|
||||
|
||||
$afterBehavior = ['\app\api\behavior\ApiAuth', '\app\api\behavior\RequestFilter'];
|
||||
$afterBehavior = ['\app\api\behavior\ApiAuth', '\app\api\behavior\ApiPermission', '\app\api\behavior\RequestFilter'];
|
||||
|
||||
return [
|
||||
'[api]' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user