From 2fc82f7acf18c281d95d3920385ea82b44b6b1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Tue, 1 Oct 2019 17:24:45 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8Dwiki=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wiki/controller/Api.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/wiki/controller/Api.php b/application/wiki/controller/Api.php index 0837d2c..95ba5c7 100644 --- a/application/wiki/controller/Api.php +++ b/application/wiki/controller/Api.php @@ -114,7 +114,9 @@ class Api extends Base { foreach ($item as $apiItem) { $_listInfo['api_info'][] = $apiInfo[$apiItem]; } - $listInfo[] = $_listInfo; + if (isset($_listInfo['api_info'])) { + $listInfo[] = $_listInfo; + } } } From 5c494bc01f4c06fdc79d08e5948b273721bec70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Wed, 2 Oct 2019 23:06:04 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20=E4=B8=BA=20json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Base.php | 4 ++-- application/wiki/controller/Base.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index fad6eaa..fdf8593 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -30,7 +30,7 @@ class Base extends Controller { $return['debug'] = $this->debug; } - return json($return); + return $return; } public function buildFailed($code, $msg, $data = []) { @@ -43,7 +43,7 @@ class Base extends Controller { $return['debug'] = $this->debug; } - return json($return); + return $return; } protected function debug($data) { diff --git a/application/wiki/controller/Base.php b/application/wiki/controller/Base.php index a18656e..2b9c8f3 100644 --- a/application/wiki/controller/Base.php +++ b/application/wiki/controller/Base.php @@ -27,7 +27,7 @@ class Base extends Controller { 'data' => $data ]; - return json($return); + return $return; } public function buildFailed($code, $msg, $data = []) { @@ -37,7 +37,7 @@ class Base extends Controller { 'data' => $data ]; - return json($return); + return $return; } } From 5247f32e270cece959e8857075b0624277559a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Wed, 2 Oct 2019 23:25:29 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=88=90=E5=8A=9F/?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=20=E5=87=BD=E6=95=B0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/App.php | 16 ++++++++-------- application/admin/controller/AppGroup.php | 14 +++++++------- application/admin/controller/Auth.php | 18 +++++++++--------- application/admin/controller/Base.php | 4 ++-- application/admin/controller/Fields.php | 12 ++++++------ .../admin/controller/InterfaceGroup.php | 14 +++++++------- application/admin/controller/InterfaceList.php | 16 ++++++++-------- application/admin/controller/Log.php | 2 +- application/admin/controller/Menu.php | 16 ++++++++-------- application/admin/controller/Miss.php | 4 ++-- application/admin/controller/User.php | 18 +++++++++--------- application/api/controller/Base.php | 4 ++-- application/wiki/controller/Base.php | 4 ++-- 13 files changed, 71 insertions(+), 71 deletions(-) diff --git a/application/admin/controller/App.php b/application/admin/controller/App.php index 10e8bef..9f98cd4 100644 --- a/application/admin/controller/App.php +++ b/application/admin/controller/App.php @@ -90,7 +90,7 @@ class App extends Base { if ($id) { $res = AdminApp::update($data, ['id' => $id]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } } @@ -124,9 +124,9 @@ class App extends Base { } $res = AdminApp::create($data); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -144,11 +144,11 @@ class App extends Base { 'id' => $id ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { $appInfo = AdminApp::get($id); cache('AccessToken:' . $appInfo['app_secret'], null); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -176,11 +176,11 @@ class App extends Base { } $res = AdminApp::update($data, ['id' => $postData['id']]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { $appInfo = AdminApp::get($postData['id']); cache('AccessToken:' . $appInfo['app_secret'], null); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -199,6 +199,6 @@ class App extends Base { AdminApp::destroy($id); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } diff --git a/application/admin/controller/AppGroup.php b/application/admin/controller/AppGroup.php index 3f39382..c8f6a7e 100644 --- a/application/admin/controller/AppGroup.php +++ b/application/admin/controller/AppGroup.php @@ -80,9 +80,9 @@ class AppGroup extends Base { 'id' => $id ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -95,9 +95,9 @@ class AppGroup extends Base { $postData = $this->request->post(); $res = AdminAppGroup::create($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -110,9 +110,9 @@ class AppGroup extends Base { $postData = $this->request->post(); $res = AdminAppGroup::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -134,6 +134,6 @@ class AppGroup extends Base { AdminAppGroup::destroy(['hash' => $hash]); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index 708802f..cce7462 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -109,7 +109,7 @@ class Auth extends Base { unset($postData['rules']); $res = AdminAuthGroup::create($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { if ($rules) { $insertData = []; @@ -124,7 +124,7 @@ class Auth extends Base { (new AdminAuthRule())->saveAll($insertData); } - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -141,9 +141,9 @@ class Auth extends Base { 'status' => $status ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -164,9 +164,9 @@ class Auth extends Base { unset($postData['rules']); $res = AdminAuthGroup::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -199,7 +199,7 @@ class Auth extends Base { AdminAuthGroup::destroy($id); AdminAuthRule::destroy(['group_id' => $id]); - return $this->buildSuccess([]); + return $this->buildSuccess(); } /** @@ -226,9 +226,9 @@ class Auth extends Base { 'uid' => $uid ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } diff --git a/application/admin/controller/Base.php b/application/admin/controller/Base.php index ea9d552..5aa5a80 100644 --- a/application/admin/controller/Base.php +++ b/application/admin/controller/Base.php @@ -22,7 +22,7 @@ class Base extends Controller { $this->userInfo = $this->request->API_ADMIN_USER_INFO; } - public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) { + public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) { $return = [ 'code' => $code, 'msg' => $msg, @@ -56,7 +56,7 @@ class Base extends Controller { cache('Login:' . $apiAuth, json_encode($this->userInfo), config('apiadmin.ONLINE_TIME')); } - public function buildFailed($code, $msg, $data = []) { + public function buildFailed($code, $msg = '操作失败', $data = []) { $return = [ 'code' => $code, 'msg' => $msg, diff --git a/application/admin/controller/Fields.php b/application/admin/controller/Fields.php index 70c22cb..fe51246 100644 --- a/application/admin/controller/Fields.php +++ b/application/admin/controller/Fields.php @@ -104,9 +104,9 @@ class Fields extends Base { cache('ResponseFieldsRule:' . $postData['hash'], null); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess('操作成功'); + return $this->buildSuccess(); } } @@ -127,9 +127,9 @@ class Fields extends Base { cache('ResponseFieldsRule:' . $postData['hash'], null); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -152,7 +152,7 @@ class Fields extends Base { AdminFields::destroy($id); - return $this->buildSuccess([]); + return $this->buildSuccess(); } /** @@ -200,7 +200,7 @@ class Fields extends Base { cache('RequestFields:Rule:' . $hash, null); cache('ResponseFieldsRule:' . $hash, null); - return $this->buildSuccess([]); + return $this->buildSuccess(); } private function handle($data, &$dataArr, $prefix = 'data', $index = 'data') { diff --git a/application/admin/controller/InterfaceGroup.php b/application/admin/controller/InterfaceGroup.php index bc14a08..9bbf797 100644 --- a/application/admin/controller/InterfaceGroup.php +++ b/application/admin/controller/InterfaceGroup.php @@ -79,9 +79,9 @@ class InterfaceGroup extends Base { 'id' => $id ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -94,9 +94,9 @@ class InterfaceGroup extends Base { $postData = $this->request->post(); $res = AdminGroup::create($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -109,9 +109,9 @@ class InterfaceGroup extends Base { $postData = $this->request->post(); $res = AdminGroup::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -153,6 +153,6 @@ class InterfaceGroup extends Base { AdminGroup::destroy(['hash' => $hash]); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 29901ba..36418cf 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -78,9 +78,9 @@ class InterfaceList extends Base { $res = AdminList::create($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -98,11 +98,11 @@ class InterfaceList extends Base { 'hash' => $hash ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { cache('ApiInfo:' . $hash, null); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -119,11 +119,11 @@ class InterfaceList extends Base { $res = AdminList::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { cache('ApiInfo:' . $postData['hash'], null); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -166,7 +166,7 @@ class InterfaceList extends Base { cache('ApiInfo:' . $hash, null); - return $this->buildSuccess([]); + return $this->buildSuccess(); } /** @@ -191,6 +191,6 @@ class InterfaceList extends Base { file_put_contents($apiRoutePath, $tplOriginStr); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } diff --git a/application/admin/controller/Log.php b/application/admin/controller/Log.php index df9d32f..be8e98f 100644 --- a/application/admin/controller/Log.php +++ b/application/admin/controller/Log.php @@ -64,7 +64,7 @@ class Log extends Base { } AdminUserAction::destroy($id); - return $this->buildSuccess([]); + return $this->buildSuccess(); } diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index c94f496..784f73a 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -27,7 +27,7 @@ class Menu extends Base { return $this->buildSuccess([ 'list' => $list - ], '登录成功'); + ]); } /** @@ -42,9 +42,9 @@ class Menu extends Base { } $res = AdminMenu::create($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -61,9 +61,9 @@ class Menu extends Base { 'hide' => $status ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -79,9 +79,9 @@ class Menu extends Base { } $res = AdminMenu::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -101,7 +101,7 @@ class Menu extends Base { } else { AdminMenu::destroy($id); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } diff --git a/application/admin/controller/Miss.php b/application/admin/controller/Miss.php index 4f7a164..dd32528 100644 --- a/application/admin/controller/Miss.php +++ b/application/admin/controller/Miss.php @@ -6,9 +6,9 @@ use app\util\ReturnCode; class Miss extends Base { public function index() { if ($this->request->isOptions()) { - return $this->buildSuccess([]); + return $this->buildSuccess(); } else { - return $this->buildFailed(ReturnCode::INVALID, '接口地址异常', []); + return $this->buildFailed(ReturnCode::INVALID, '接口地址异常'); } } } diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index b78017d..4a1c225 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -95,14 +95,14 @@ class User extends Base { } $res = AdminUser::create($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { AdminAuthGroupAccess::create([ 'uid' => $res->id, 'group_id' => $groups ]); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -160,9 +160,9 @@ class User extends Base { 'status' => $status ]); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -186,7 +186,7 @@ class User extends Base { } $res = AdminUser::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { $has = AdminAuthGroupAccess::get(['uid' => $postData['id']]); if ($has) { @@ -202,7 +202,7 @@ class User extends Base { ]); } - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -232,13 +232,13 @@ class User extends Base { unset($postData['head_img']); $res = AdminUser::update($postData); if ($res === false) { - return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { $userData = AdminUserData::get(['uid' => $postData['id']]); $userData->head_img = $headImg; $userData->save(); - return $this->buildSuccess([]); + return $this->buildSuccess(); } } @@ -260,7 +260,7 @@ class User extends Base { AdminUser::destroy($id); AdminAuthGroupAccess::destroy(['uid' => $id]); - return $this->buildSuccess([]); + return $this->buildSuccess(); } diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index fdf8593..a6477c2 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -20,7 +20,7 @@ class Base extends Controller { // $this->userInfo = ''; 这部分初始化用户信息可以参考admin模块下的Base去自行处理 } - public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) { + public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) { $return = [ 'code' => $code, 'msg' => $msg, @@ -33,7 +33,7 @@ class Base extends Controller { return $return; } - public function buildFailed($code, $msg, $data = []) { + public function buildFailed($code, $msg = '操作失败', $data = []) { $return = [ 'code' => $code, 'msg' => $msg, diff --git a/application/wiki/controller/Base.php b/application/wiki/controller/Base.php index 2b9c8f3..6a4e5b7 100644 --- a/application/wiki/controller/Base.php +++ b/application/wiki/controller/Base.php @@ -20,7 +20,7 @@ class Base extends Controller { $this->appInfo = $this->request->API_WIKI_USER_INFO; } - public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) { + public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) { $return = [ 'code' => $code, 'msg' => $msg, @@ -30,7 +30,7 @@ class Base extends Controller { return $return; } - public function buildFailed($code, $msg, $data = []) { + public function buildFailed($code, $msg = '操作失败', $data = []) { $return = [ 'code' => $code, 'msg' => $msg, From b4cb6c2cd1d598dd0bd75aa4d7f883cda7669e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Wed, 2 Oct 2019 23:28:46 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=BA=94=E7=94=A8=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=B1=95=E7=A4=BAdebug=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Base.php | 4 ++-- application/api/controller/Base.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/admin/controller/Base.php b/application/admin/controller/Base.php index 5aa5a80..ee8996d 100644 --- a/application/admin/controller/Base.php +++ b/application/admin/controller/Base.php @@ -28,7 +28,7 @@ class Base extends Controller { 'msg' => $msg, 'data' => $data ]; - if ($this->debug) { + if (config('app.app_debug') && $this->debug) { $return['debug'] = $this->debug; } @@ -62,7 +62,7 @@ class Base extends Controller { 'msg' => $msg, 'data' => $data ]; - if ($this->debug) { + if (config('app.app_debug') && $this->debug) { $return['debug'] = $this->debug; } diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index a6477c2..3cf4c5d 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -26,7 +26,7 @@ class Base extends Controller { 'msg' => $msg, 'data' => $data ]; - if ($this->debug) { + if (config('app.app_debug') && $this->debug) { $return['debug'] = $this->debug; } @@ -39,7 +39,7 @@ class Base extends Controller { 'msg' => $msg, 'data' => $data ]; - if ($this->debug) { + if (config('app.app_debug') && $this->debug) { $return['debug'] = $this->debug; } From 69352158bfd4de9bf95c66eefdf67a558a3a0e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Wed, 2 Oct 2019 23:42:54 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E6=9C=89=E5=8A=A9=E4=BA=8E=E5=BC=80=E5=8F=91=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/util/ExceptionHandle.php | 24 ++++++++++++++++++++++++ config/app.php | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 application/util/ExceptionHandle.php diff --git a/application/util/ExceptionHandle.php b/application/util/ExceptionHandle.php new file mode 100644 index 0000000..c137683 --- /dev/null +++ b/application/util/ExceptionHandle.php @@ -0,0 +1,24 @@ + + */ + +namespace app\util; + +use Exception; +use think\exception\Handle; + +/** + * Class ExceptionHandle + * @package app\util + * 异常处理handle类 + * Detail see: https://www.kancloud.cn/manual/thinkphp5_1/354092 + */ +class ExceptionHandle extends Handle { + + public function render(Exception $e) { + return parent::render($e)->header(config('apiadmin.CROSS_DOMAIN')); + } +} diff --git a/config/app.php b/config/app.php index bde326a..d599a21 100644 --- a/config/app.php +++ b/config/app.php @@ -141,6 +141,6 @@ return [ // 显示错误信息 'show_error_msg' => false, // 异常处理handle类 留空使用 \think\exception\Handle - 'exception_handle' => '', + 'exception_handle' => '\\app\\util\\ExceptionHandle', ]; From b621ed09a9e79fa9020b45d96fe5704902df8d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Sun, 6 Oct 2019 16:48:40 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/InterfaceList.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 36418cf..64b39cf 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -183,11 +183,11 @@ class InterfaceList extends Base { $tplOriginStr = file_get_contents($tplPath); $listInfo = AdminList::all(['status' => 1]); - $tplStr = ''; + $tplStr = []; foreach ($listInfo as $value) { - $tplStr .= 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);'; + 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}'], [$tplStr], $tplOriginStr); + $tplOriginStr = str_replace(['{$API_RULE}'], [implode($tplStr, "\n ")], $tplOriginStr); file_put_contents($apiRoutePath, $tplOriginStr); From 00d8d2d8f5e32fd942ac0af021581c1b2f776fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Sun, 6 Oct 2019 17:36:54 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=94=A8=E6=88=B7/?= =?UTF-8?q?=E5=BA=94=E7=94=A8=20=E6=93=8D=E4=BD=9C=E6=97=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/App.php | 11 +++++++++++ application/admin/controller/User.php | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/application/admin/controller/App.php b/application/admin/controller/App.php index 9f98cd4..ff148d0 100644 --- a/application/admin/controller/App.php +++ b/application/admin/controller/App.php @@ -148,6 +148,10 @@ class App extends Base { } else { $appInfo = AdminApp::get($id); cache('AccessToken:' . $appInfo['app_secret'], null); + if($oldWiki = cache('WikiLogin:' . $id)) { + cache('WikiLogin:' . $oldWiki, null); + } + return $this->buildSuccess(); } } @@ -180,6 +184,10 @@ class App extends Base { } else { $appInfo = AdminApp::get($postData['id']); cache('AccessToken:' . $appInfo['app_secret'], null); + if($oldWiki = cache('WikiLogin:' . $postData['id'])) { + cache('WikiLogin:' . $oldWiki, null); + } + return $this->buildSuccess(); } } @@ -198,6 +206,9 @@ class App extends Base { cache('AccessToken:' . $appInfo['app_secret'], null); AdminApp::destroy($id); + if($oldWiki = cache('WikiLogin:' . $id)) { + cache('WikiLogin:' . $oldWiki, null); + } return $this->buildSuccess(); } diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index 4a1c225..97e1401 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -162,6 +162,10 @@ class User extends Base { if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); } else { + if($oldAdmin = cache('Login:' . $id)) { + cache('Login:' . $oldAdmin, null); + } + return $this->buildSuccess(); } } @@ -201,6 +205,9 @@ class User extends Base { 'group_id' => $groups ]); } + if($oldAdmin = cache('Login:' . $postData['id'])) { + cache('Login:' . $oldAdmin, null); + } return $this->buildSuccess(); } @@ -237,6 +244,9 @@ class User extends Base { $userData = AdminUserData::get(['uid' => $postData['id']]); $userData->head_img = $headImg; $userData->save(); + if($oldWiki = cache('WikiLogin:' . $postData['id'])) { + cache('WikiLogin:' . $oldWiki, null); + } return $this->buildSuccess(); } @@ -259,6 +269,9 @@ class User extends Base { } AdminUser::destroy($id); AdminAuthGroupAccess::destroy(['uid' => $id]); + if($oldAdmin = cache('Login:' . $id)) { + cache('Login:' . $oldAdmin, null); + } return $this->buildSuccess();