split router

This commit is contained in:
Tokumeikoi 2020-02-01 20:51:45 +08:00
parent ab5aeb545e
commit 1d704a4424
9 changed files with 214 additions and 84 deletions

View File

@ -0,0 +1,62 @@
<?php
namespace App\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
class AdminRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'admin',
'middleware' => 'admin'
], function ($router) {
// Config
$router->get('config/fetch', 'Admin\\ConfigController@fetch');
$router->post('config/save', 'Admin\\ConfigController@save');
// Plan
$router->get('plan/fetch', 'Admin\\PlanController@fetch');
$router->post('plan/save', 'Admin\\PlanController@save');
$router->post('plan/drop', 'Admin\\PlanController@drop');
$router->post('plan/update', 'Admin\\PlanController@update');
// Server
$router->get('server/fetch', 'Admin\\ServerController@fetch');
$router->post('server/save', 'Admin\\ServerController@save');
$router->get('server/group/fetch', 'Admin\\ServerController@groupFetch');
$router->post('server/group/save', 'Admin\\ServerController@groupSave');
$router->post('server/group/drop', 'Admin\\ServerController@groupDrop');
$router->post('server/drop', 'Admin\\ServerController@drop');
$router->post('server/update', 'Admin\\ServerController@update');
// Order
$router->get('order/fetch', 'Admin\\OrderController@fetch');
$router->post('order/repair', 'Admin\\OrderController@repair');
$router->post('order/update', 'Admin\\OrderController@update');
// User
$router->get('user/fetch', 'Admin\\UserController@fetch');
$router->post('user/update', 'Admin\\UserController@update');
$router->get('user/id2UserInfo/{id}', 'Admin\\UserController@id2UserInfo');
// Stat
$router->get('stat/getOverride', 'Admin\\StatController@getOverride');
// Notice
$router->get('notice/fetch', 'Admin\\NoticeController@fetch');
$router->post('notice/save', 'Admin\\NoticeController@save');
$router->post('notice/update', 'Admin\\NoticeController@update');
$router->post('notice/drop', 'Admin\\NoticeController@drop');
// Ticket
$router->get('ticket/fetch', 'Admin\\TicketController@fetch');
$router->post('ticket/reply', 'Admin\\TicketController@reply');
$router->post('ticket/close', 'Admin\\TicketController@close');
// Mail
$router->post('mail/send', 'Admin\\MailController@send');
// Coupon
$router->get('coupon/fetch', 'Admin\\CouponController@fetch');
$router->post('coupon/save', 'Admin\\CouponController@save');
$router->post('coupon/drop', 'Admin\\CouponController@drop');
// Tutorial
$router->get('tutorial/fetch', 'Admin\\TutorialController@fetch');
$router->post('tutorial/save', 'Admin\\TutorialController@save');
$router->post('tutorial/show', 'Admin\\TutorialController@show');
$router->post('tutorial/drop', 'Admin\\TutorialController@drop');
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
class ClientRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'client',
'middleware' => 'client'
], function ($router) {
// Plan
$router->get('plan/fetch', 'Guest\\PlanController@fetch');
// Order
$router->post('order/alipayNotify', 'Guest\\OrderController@alipayNotify');
$router->post('order/stripeNotify', 'Guest\\OrderController@stripeNotify');
$router->post('order/bitpayXNotify', 'Guest\\OrderController@bitpayXNotify');
$router->post('order/payTaroNotify', 'Guest\\OrderController@payTaroNotify');
});
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
class GuestRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'guest'
], function ($router) {
// Plan
$router->get('plan/fetch', 'Guest\\PlanController@fetch');
// Order
$router->post('order/alipayNotify', 'Guest\\OrderController@alipayNotify');
$router->post('order/stripeNotify', 'Guest\\OrderController@stripeNotify');
$router->post('order/bitpayXNotify', 'Guest\\OrderController@bitpayXNotify');
$router->post('order/payTaroNotify', 'Guest\\OrderController@payTaroNotify');
});
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
class PassportRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'passport'
], function ($router) {
// Auth
$router->post('/auth/register', 'Passport\\AuthController@register');
$router->post('/auth/login', 'Passport\\AuthController@login');
$router->get('/auth/token2Login', 'Passport\\AuthController@token2Login');
$router->get('/auth/check', 'Passport\\AuthController@check');
$router->post('/auth/forget', 'Passport\\AuthController@index');
// Comm
$router->get('/comm/config', 'Passport\\CommController@config');
$router->post('/comm/sendEmailVerify', 'Passport\\CommController@sendEmailVerify');
});
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
class ServerRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'server'
], function ($router) {
$router->any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Server\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace App\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
class UserRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'user',
'middleware' => 'user'
], function ($router) {
// User
$router->get('resetSecurity', 'UserController@resetSecurity');
$router->get('logout', 'UserController@logout');
$router->get('info', 'UserController@info');
$router->post('changePassword', 'UserController@changePassword');
$router->post('update', 'UserController@update');
$router->get('getSubscribe', 'UserController@getSubscribe');
$router->get('getStat', 'UserController@getStat');
// Order
$router->post('order/save', 'OrderController@save');
$router->post('order/checkout', 'OrderController@checkout');
$router->get('order/check', 'OrderController@check');
$router->get('order/details', 'OrderController@details');
$router->get('order/fetch', 'OrderController@fetch');
$router->get('order/getPaymentMethod', 'OrderController@getPaymentMethod');
$router->post('order/cancel', 'OrderController@cancel');
// Plan
$router->get('plan/fetch', 'PlanController@fetch');
// Invite
$router->get('invite/save', 'InviteController@save');
$router->get('invite/fetch', 'InviteController@fetch');
$router->get('invite/details', 'InviteController@details');
// Tutorial
$router->get('tutorial/getSubscribeUrl', 'TutorialController@getSubscribeUrl');
$router->get('tutorial/getAppleID', 'TutorialController@getAppleID');
$router->get('tutorial/fetch', 'TutorialController@fetch');
// Notice
$router->get('notice/fetch', 'NoticeController@fetch');
// Ticket
$router->post('ticket/reply', 'TicketController@reply');
$router->post('ticket/close', 'TicketController@close');
$router->post('ticket/save', 'TicketController@save');
$router->get('ticket/fetch', 'TicketController@fetch');
// Server
$router->get('server/fetch', 'ServerController@fetch');
$router->get('server/log/fetch', 'ServerController@logFetch');
// Coupon
$router->post('coupon/check', 'CouponController@check');
});
}
}

View File

@ -36,7 +36,6 @@ class RouteServiceProvider extends ServiceProvider
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
@ -65,9 +64,14 @@ class RouteServiceProvider extends ServiceProvider
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::group([
'prefix' => 'api/v1',
'middleware' => 'api',
'namespace' => $this->namespace
], function ($router) {
foreach (glob(app_path('Http//Routes') . '/*.php') as $file) {
$this->app->make('App\\Http\\Routes\\' . basename($file, '.php'))->map($router);
}
});
}
}

2
public/umi.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,78 +0,0 @@
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::prefix('v1')
->group(function () {
// Admin
Route::prefix('admin')
->middleware('admin')
->group(function () {
Route::any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Admin\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
// User
Route::prefix('user')
->middleware('user')
->group(function () {
Route::any('/{action}', function($action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\User\\UserController");
return \App::call([$ctrl, $action]);
});
Route::any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\User\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
// Passport
Route::prefix('passport')
->group(function () {
Route::any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Passport\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
// No Auth
Route::prefix('guest')
->group(function () {
Route::any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Guest\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
// Client
Route::prefix('client')
->middleware('client')
->group(function () {
Route::any('/{action}', function($action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Client\\ClientController");
return \App::call([$ctrl, $action]);
});
Route::any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Client\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
// Server
Route::prefix('server')
->group(function () {
Route::any('/{class}/{action}', function($class, $action) {
$ctrl = \App::make("\\App\\Http\\Controllers\\Server\\" . ucfirst($class) . "Controller");
return \App::call([$ctrl, $action]);
});
});
});