From 6dd562df8cb3e9959de7a7716d304efd04d2c4fa Mon Sep 17 00:00:00 2001 From: root Date: Wed, 29 Jan 2020 16:08:50 +0800 Subject: [PATCH] update --- .../{ => Client}/AppController.php | 4 +- .../{ => Client}/ClientController.php | 4 +- .../Passport/RegisterController.php | 18 +- .../{ => User}/CouponController.php | 3 +- .../{ => User}/InviteController.php | 4 +- .../{ => User}/NoticeController.php | 4 +- .../{ => User}/OrderController.php | 6 +- .../Controllers/{ => User}/PlanController.php | 4 +- .../{ => User}/ServerController.php | 4 +- .../{ => User}/TicketController.php | 4 +- .../{ => User}/TutorialController.php | 4 +- .../Controllers/{ => User}/UserController.php | 4 +- install.sql | 3 +- pm2.yaml | 2 +- routes/api.php | 174 +++++++----------- update.sql | 5 +- 16 files changed, 107 insertions(+), 140 deletions(-) rename app/Http/Controllers/{ => Client}/AppController.php (99%) rename app/Http/Controllers/{ => Client}/ClientController.php (99%) rename app/Http/Controllers/{ => User}/CouponController.php (91%) rename app/Http/Controllers/{ => User}/InviteController.php (98%) rename app/Http/Controllers/{ => User}/NoticeController.php (89%) rename app/Http/Controllers/{ => User}/OrderController.php (99%) rename app/Http/Controllers/{ => User}/PlanController.php (94%) rename app/Http/Controllers/{ => User}/ServerController.php (98%) rename app/Http/Controllers/{ => User}/TicketController.php (99%) rename app/Http/Controllers/{ => User}/TutorialController.php (98%) rename app/Http/Controllers/{ => User}/UserController.php (99%) diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/Client/AppController.php similarity index 99% rename from app/Http/Controllers/AppController.php rename to app/Http/Controllers/Client/AppController.php index 99e97f51..eea8bf14 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/Client/AppController.php @@ -1,9 +1,9 @@ true ]); } + + public function pv(Request $request) + { + $inviteCode = InviteCode::where('code', $request->input('invite_code'))->first(); + if ($inviteCode) { + $inviteCode->pv = $inviteCode->pv + 1; + $inviteCode->save(); + } + + return response([ + 'data' => true + ]); + } } diff --git a/app/Http/Controllers/CouponController.php b/app/Http/Controllers/User/CouponController.php similarity index 91% rename from app/Http/Controllers/CouponController.php rename to app/Http/Controllers/User/CouponController.php index ae1796d1..f76ef46f 100644 --- a/app/Http/Controllers/CouponController.php +++ b/app/Http/Controllers/User/CouponController.php @@ -1,7 +1,8 @@ session()->get('id')) ->orderBy('created_at', 'DESC'); - if (!empty($request->input('status'))) { + if ($request->input('status') !== null) { $model->where('status', $request->input('status')); } $order = $model->get(); diff --git a/app/Http/Controllers/PlanController.php b/app/Http/Controllers/User/PlanController.php similarity index 94% rename from app/Http/Controllers/PlanController.php rename to app/Http/Controllers/User/PlanController.php index 69428ee1..e3c65c91 100755 --- a/app/Http/Controllers/PlanController.php +++ b/app/Http/Controllers/User/PlanController.php @@ -1,9 +1,9 @@ middleware('admin') ->group(function () { - // Config - Route::get('config/fetch', 'Admin\\ConfigController@fetch'); - Route::post('config/save', 'Admin\\ConfigController@save'); - // Plan - Route::get('plan/fetch', 'Admin\\PlanController@fetch'); - Route::post('plan/save', 'Admin\\PlanController@save'); - Route::post('plan/drop', 'Admin\\PlanController@drop'); - Route::post('plan/update', 'Admin\\PlanController@update'); - // Server - Route::get('server/fetch', 'Admin\\ServerController@fetch'); - Route::post('server/save', 'Admin\\ServerController@save'); - Route::get('server/group/fetch', 'Admin\\ServerController@groupFetch'); - Route::post('server/group/save', 'Admin\\ServerController@groupSave'); - Route::post('server/group/drop', 'Admin\\ServerController@groupDrop'); - Route::post('server/drop', 'Admin\\ServerController@drop'); - Route::post('server/update', 'Admin\\ServerController@update'); - // Order - Route::get('order/fetch', 'Admin\\OrderController@fetch'); - Route::post('order/repair', 'Admin\\OrderController@repair'); - Route::post('order/update', 'Admin\\OrderController@update'); - // User - Route::get('user/fetch', 'Admin\\UserController@fetch'); - Route::post('user/update', 'Admin\\UserController@update'); - Route::get('user/id2UserInfo/{id}', 'Admin\\UserController@id2UserInfo'); - // Stat - Route::get('stat/getOverride', 'Admin\\StatController@getOverride'); - // Notice - Route::get('notice/fetch', 'Admin\\NoticeController@fetch'); - Route::post('notice/save', 'Admin\\NoticeController@save'); - Route::post('notice/update', 'Admin\\NoticeController@update'); - Route::post('notice/drop', 'Admin\\NoticeController@drop'); - // Ticket - Route::get('ticket/fetch', 'Admin\\TicketController@fetch'); - Route::post('ticket/reply', 'Admin\\TicketController@reply'); - Route::post('ticket/close', 'Admin\\TicketController@close'); - // Mail - Route::post('mail/send', 'Admin\\MailController@send'); - // Coupon - Route::get('coupon/fetch', 'Admin\\CouponController@fetch'); - Route::post('coupon/save', 'Admin\\CouponController@save'); - Route::post('coupon/drop', 'Admin\\CouponController@drop'); - // Tutorial - Route::get('tutorial/fetch', 'Admin\\TutorialController@fetch'); - Route::post('tutorial/save', 'Admin\\TutorialController@save'); - Route::post('tutorial/show', 'Admin\\TutorialController@show'); - Route::post('tutorial/drop', 'Admin\\TutorialController@drop'); + Route::any('/{class}/{action}', function($class, $action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\User\\" . ucfirst($class) . "Controller"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); }); // User Route::prefix('user') ->middleware('user') ->group(function () { - // User - Route::get('resetSecurity', 'UserController@resetSecurity'); - Route::get('logout', 'UserController@logout'); - Route::get('info', 'UserController@info'); - Route::post('changePassword', 'UserController@changePassword'); - Route::post('update', 'UserController@update'); - Route::get('getSubscribe', 'UserController@getSubscribe'); - Route::get('getStat', 'UserController@getStat'); - // Order - Route::post('order/save', 'OrderController@save'); - Route::post('order/checkout', 'OrderController@checkout'); - Route::get('order/check', 'OrderController@check'); - Route::get('order/details', 'OrderController@details'); - Route::get('order/fetch', 'OrderController@fetch'); - Route::get('order/getPaymentMethod', 'OrderController@getPaymentMethod'); - Route::post('order/cancel', 'OrderController@cancel'); - // Plan - Route::get('plan/fetch', 'PlanController@fetch'); - // Invite - Route::get('invite/save', 'InviteController@save'); - Route::get('invite/fetch', 'InviteController@fetch'); - Route::get('invite/details', 'InviteController@details'); - // Tutorial - Route::get('tutorial/getSubscribeUrl', 'TutorialController@getSubscribeUrl'); - Route::get('tutorial/getAppleID', 'TutorialController@getAppleID'); - Route::get('tutorial/fetch', 'TutorialController@fetch'); - // Notice - Route::get('notice/fetch', 'NoticeController@fetch'); - // Ticket - Route::post('ticket/reply', 'TicketController@reply'); - Route::post('ticket/close', 'TicketController@close'); - Route::post('ticket/save', 'TicketController@save'); - Route::get('ticket/fetch', 'TicketController@fetch'); - // Server - Route::get('server/fetch', 'ServerController@fetch'); + Route::any('/{action}', function($action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\UserController"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); + Route::any('/{class}/{action}', function($class, $action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\User\\" . ucfirst($class) . "Controller"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); Route::get('server/log/fetch', 'ServerController@logFetch'); - // Coupon - Route::post('coupon/check', 'CouponController@check'); }); // Passport Route::prefix('passport') ->group(function () { - // Register - Route::post('register', 'Passport\\RegisterController@index'); - // Comm - Route::get('config', 'Passport\\CommController@config'); - Route::post('sendEmailVerify', 'Passport\\CommController@sendEmailVerify'); - // Login - Route::post('login', 'Passport\\LoginController@index'); - Route::get('token2Login', 'Passport\\LoginController@token2Login'); - Route::get('check', 'Passport\\LoginController@check'); - // Forget - Route::post('forget', 'Passport\\ForgetController@index'); + Route::any('/{class}/{action}', function($class, $action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\Passport\\" . ucfirst($class) . "Controller"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); }); // No Auth Route::prefix('guest') ->group(function () { - // Plan - Route::get('plan/fetch', 'Guest\\PlanController@fetch'); - // Order - Route::post('order/alipayNotify', 'Guest\\OrderController@alipayNotify'); - Route::post('order/stripeNotify', 'Guest\\OrderController@stripeNotify'); - Route::post('order/bitpayXNotify', 'Guest\\OrderController@bitpayXNotify'); - Route::post('order/payTaroNotify', 'Guest\\OrderController@payTaroNotify'); + Route::any('/{class}/{action}', function($class, $action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\Guest\\" . ucfirst($class) . "Controller"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); }); // Client Route::prefix('client') ->middleware('client') ->group(function () { - // Client - Route::get('subscribe', 'ClientController@subscribe'); - // App - Route::get('app/data', 'AppController@data'); - Route::get('app/config', 'AppController@config'); + Route::any('/{action}', function($action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\ClientController"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); + Route::any('/{class}/{action}', function($class, $action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\Client\\" . ucfirst($class) . "Controller"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); }); // Server Route::prefix('server') ->group(function () { - // Deepbwork - Route::get('deepbwork/user', 'Server\\DeepbworkController@user'); - Route::get('deepbwork/config', 'Server\\DeepbworkController@config'); - Route::post('deepbwork/submit', 'Server\\DeepbworkController@submit'); + Route::any('/{class}/{action}', function($class, $action) { + $ctrl = \App::make("\\App\\Http\\Controllers\\Server\\" . ucfirst($class) . "Controller"); + try { + return \App::call([$ctrl, $action]); + } catch (\Exception $e) { + abort(404, 'not found'); + } + }); }); }); diff --git a/update.sql b/update.sql index aaba2086..8dfae936 100644 --- a/update.sql +++ b/update.sql @@ -130,4 +130,7 @@ ALTER TABLE `v2_server_log` CHANGE `rate` `rate` decimal(10,2) NOT NULL AFTER `d`; ALTER TABLE `v2_order` -DROP `method`; \ No newline at end of file +DROP `method`; + +ALTER TABLE `v2_invite_code` +ADD `pv` int(11) NOT NULL DEFAULT '0' AFTER `status`; \ No newline at end of file