Commit b2a759a6 authored by hj's avatar hj

更新

parent cf02e316
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Http\Controllers\Middleware;
use App\Exceptions\ServerRunTimeException;
use App\Services\CustomerService;
use App\Services\ThirdPlatform\ThirdPlatformService;
use App\Services\ThirdPlatform\ZhenKhService;
use Closure;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Http\Request;
use Jiannei\Response\Laravel\Support\Facades\Response;
use App\Support\Traits\Helpers;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
class SystemMaintenance
{
use Helpers;
/**
* The authentication guard factory instance.
*
* @var Auth
*/
protected $auth;
/**
* Create a new middleware instance.
*
* @param Auth $auth
*/
public function __construct(Auth $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param string|null $guard
* @return mixed
*
* @throws AuthorizationException
*/
public function handle($request, Closure $next, $guard = null)
{
if(env('MAINTENANCE') == true){
throw new ServerRunTimeException('系统维护中,暂时无法访问');
}
return $next($request);
}
}
...@@ -108,6 +108,7 @@ $app->middleware([ ...@@ -108,6 +108,7 @@ $app->middleware([
]); ]);
$app->routeMiddleware([ $app->routeMiddleware([
'maintenance' => App\Http\Controllers\Middleware\SystemMaintenance::class,
'apiAuth' => App\Http\Controllers\Middleware\Authenticate::class, 'apiAuth' => App\Http\Controllers\Middleware\Authenticate::class,
'throttle' => App\Http\Controllers\Middleware\RateLimits::class 'throttle' => App\Http\Controllers\Middleware\RateLimits::class
//'syslog' => App\Http\Controllers\Middleware\SysLog::class, //'syslog' => App\Http\Controllers\Middleware\SysLog::class,
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
$api->version('v1', function($api) { $api->version('v1', function($api) {
//获取token //获取token
$api->group(['namespace'=>'App\Http\Controllers\V1\Auth','middleware' => ['throttle:60,1']], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Auth','middleware' => ['maintenance','throttle:60,1']], function($api) {
$api->post('/openapi/auth/getToken', ['uses'=>'CustomerAuthController@getToken']); $api->post('/openapi/auth/getToken', ['uses'=>'CustomerAuthController@getToken']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
// 获取订单列表 // 获取订单列表
$api->post('/openapi/rhawn/orders/getRhawnOrders', ['permission' => 'orders.getCustomerOrders', 'uses'=>'OrdersController@getCustomerOrders']); $api->post('/openapi/rhawn/orders/getRhawnOrders', ['permission' => 'orders.getCustomerOrders', 'uses'=>'OrdersController@getCustomerOrders']);
// 获取订单详情 // 获取订单详情
...@@ -22,18 +22,18 @@ $api->version('v1', function($api) { ...@@ -22,18 +22,18 @@ $api->version('v1', function($api) {
$api->post('/openapi/rhawn/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']); $api->post('/openapi/rhawn/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/rhawn/products/getAllProducts', ['permission' => 'orders.getProductList', 'uses'=>'ProductsController@getAllProductsList']); $api->post('/openapi/rhawn/products/getAllProducts', ['permission' => 'orders.getProductList', 'uses'=>'ProductsController@getAllProductsList']);
$api->post('/openapi/rhawn/products/getProductDetail', ['permission' => 'orders.getProductDetail', 'uses'=>'ProductsController@getProductDetail']); $api->post('/openapi/rhawn/products/getProductDetail', ['permission' => 'orders.getProductDetail', 'uses'=>'ProductsController@getProductDetail']);
$api->post('/openapi/rhawn/products/getProductByCas', ['permission' => 'orders.getProductByCas', 'uses'=>'ProductsController@getProductByCas']); $api->post('/openapi/rhawn/products/getProductByCas', ['permission' => 'orders.getProductByCas', 'uses'=>'ProductsController@getProductByCas']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/rhawn/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']); $api->post('/openapi/rhawn/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']);
}); });
// 百化接口 // 百化接口
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
// 新建订单 // 新建订单
$api->post('/openapi/bhua/orders/createBhuaOrders', ['permission' => 'orders.createBhuaOrders', 'uses'=>'OrdersController@createCustomerNewOrder']); $api->post('/openapi/bhua/orders/createBhuaOrders', ['permission' => 'orders.createBhuaOrders', 'uses'=>'OrdersController@createCustomerNewOrder']);
$api->post('/openapi/bhua/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']); $api->post('/openapi/bhua/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']);
...@@ -42,21 +42,21 @@ $api->version('v1', function($api) { ...@@ -42,21 +42,21 @@ $api->version('v1', function($api) {
$api->post('/openapi/bhua/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']); $api->post('/openapi/bhua/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/bhua/products/getAllBrands', ['permission' => 'orders.getAllBrands', 'uses'=>'ProductsController@getAllBrands']); $api->post('/openapi/bhua/products/getAllBrands', ['permission' => 'orders.getAllBrands', 'uses'=>'ProductsController@getAllBrands']);
$api->post('/openapi/bhua/products/getProductsByBrandId', ['permission' => 'orders.getProductsByBrandId', 'uses'=>'ProductsController@getProductsByBrand']); $api->post('/openapi/bhua/products/getProductsByBrandId', ['permission' => 'orders.getProductsByBrandId', 'uses'=>'ProductsController@getProductsByBrand']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\Internal\V1\Bhua','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\Internal\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/internal/bhua/getAllBrands', ['permission' => 'orders.getAllBrands', 'uses'=>'ProductsController@getAllBrands']); $api->post('/openapi/internal/bhua/getAllBrands', ['permission' => 'orders.getAllBrands', 'uses'=>'ProductsController@getAllBrands']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/bhua/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']); $api->post('/openapi/bhua/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']);
}); });
// chemsite接口 // chemsite接口
$api->group(['namespace'=>'App\Http\Controllers\V1\Chemsite','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Chemsite','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/chemsite/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']); $api->post('/openapi/chemsite/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment