Commit b1734da7 authored by hj's avatar hj

更新

parent b2a759a6
<?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\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
class Requestlogs
{
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)
{
$start = $request->request->server('REQUEST_TIME_FLOAT');
//$end = microtime(true);
$request = $request->request->all();
if ($files = $request->request->allFiles()) {
foreach ($files as $key => $uploadedFile) {
$request[$key] = [
'originalName' => $uploadedFile->getClientOriginalName(),
'mimeType' => $uploadedFile->getClientMimeType(),
];
}
}
$context = [
'request' => $request,
'account' => auth()->user(),
'start' => $start,
//'end' => $end,
//'duration' => format_duration($end - $start),
];
return $next($request);
}
}
......@@ -108,6 +108,7 @@ $app->middleware([
]);
$app->routeMiddleware([
'requestlogs' => App\Http\Controllers\Middleware\Requestlogs::class,
'maintenance' => App\Http\Controllers\Middleware\SystemMaintenance::class,
'apiAuth' => App\Http\Controllers\Middleware\Authenticate::class,
'throttle' => App\Http\Controllers\Middleware\RateLimits::class
......
......@@ -3,11 +3,11 @@
$api->version('v1', function($api) {
//获取token
$api->group(['namespace'=>'App\Http\Controllers\V1\Auth','middleware' => ['maintenance','throttle:60,1']], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Auth','middleware' => ['maintenance','throttle:60,1','requestlogs']], function($api) {
$api->post('/openapi/auth/getToken', ['uses'=>'CustomerAuthController@getToken']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
// 获取订单列表
$api->post('/openapi/rhawn/orders/getRhawnOrders', ['permission' => 'orders.getCustomerOrders', 'uses'=>'OrdersController@getCustomerOrders']);
// 获取订单详情
......@@ -22,18 +22,18 @@ $api->version('v1', function($api) {
$api->post('/openapi/rhawn/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
$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/getProductByCas', ['permission' => 'orders.getProductByCas', 'uses'=>'ProductsController@getProductByCas']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/rhawn/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']);
});
// 百化接口
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
// 新建订单
$api->post('/openapi/bhua/orders/createBhuaOrders', ['permission' => 'orders.createBhuaOrders', 'uses'=>'OrdersController@createCustomerNewOrder']);
$api->post('/openapi/bhua/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']);
......@@ -42,21 +42,21 @@ $api->version('v1', function($api) {
$api->post('/openapi/bhua/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
$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->group(['namespace'=>'App\Http\Controllers\Internal\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\Internal\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/internal/bhua/getAllBrands', ['permission' => 'orders.getAllBrands', 'uses'=>'ProductsController@getAllBrands']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/bhua/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']);
});
// chemsite接口
$api->group(['namespace'=>'App\Http\Controllers\V1\Chemsite','middleware' => ['maintenance','throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->group(['namespace'=>'App\Http\Controllers\V1\Chemsite','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
$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