林一峰
7 years ago
25 changed files with 331 additions and 46 deletions
-
3.gitignore
-
79app/Common/Helper.php
-
2app/Common/ReturnData.php
-
3app/Common/Token.php
-
52app/Http/Controllers/Api/RegionController.php
-
32app/Http/Controllers/Api/SlideController.php
-
3app/Http/Kernel.php
-
31app/Http/Middleware/Sign.php
-
2app/Http/Middleware/TokenAuth.php
-
1app/Http/Middleware/TrimStrings.php
-
13app/Http/Model/Region.php
-
72app/Http/Model/Slide.php
-
38app/Http/Model/UserAddress.php
-
8public/other/flueditor/ueditor.config.js
-
2resources/views/admin/article/add.blade.php
-
2resources/views/admin/article/edit.blade.php
-
2resources/views/admin/category/add.blade.php
-
2resources/views/admin/category/edit.blade.php
-
2resources/views/admin/goods/add.blade.php
-
2resources/views/admin/goods/edit.blade.php
-
2resources/views/admin/goodstype/add.blade.php
-
2resources/views/admin/goodstype/edit.blade.php
-
2resources/views/admin/tag/add.blade.php
-
2resources/views/admin/tag/edit.blade.php
-
18routes/web.php
@ -0,0 +1,52 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
|
|||
use App\Http\Model\Region; |
|||
|
|||
class RegionController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function regionList(Request $request) |
|||
{ |
|||
//参数
|
|||
$id = $request->input('id', null); |
|||
if ($id == null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = Region::getList($id); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
public function regionDetail(Request $request) |
|||
{ |
|||
//参数
|
|||
$id = $request->input('id', null); |
|||
if ($id == null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = Region::getOne($id); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
|
|||
use App\Http\Model\Slide; |
|||
|
|||
class SlideController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function slideList(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['limit'] = $request->input('limit', 10); |
|||
$data['offset'] = $request->input('offset', 0); |
|||
if($request->input('group_id', null) !== null){$data['group_id'] = $request->input('group_id');}; |
|||
|
|||
$res = Slide::getList($data); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
<?php |
|||
namespace App\Http\Middleware; |
|||
|
|||
use Closure; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Token; |
|||
|
|||
class Sign |
|||
{ |
|||
/** |
|||
* Sign验证 |
|||
*/ |
|||
public function handle($request, Closure $next) |
|||
{ |
|||
$app_key = $request->header('app_key') ?: $request->input('app_key'); |
|||
$app_time = $request->header('app_time') ?: $request->input('app_time'); |
|||
$sign = $request->header('sign') ?: $request->input('sign'); |
|||
|
|||
if (empty($app_key) || empty($app_time) || empty($sign)) |
|||
{ |
|||
return ReturnData::create(ReturnData::FORBIDDEN); |
|||
} |
|||
|
|||
if (!Token::checkSign($app_key, $app_time, $sign)) |
|||
{ |
|||
return ReturnData::create(ReturnData::SIGN_ERROR); |
|||
} |
|||
|
|||
return $next($request); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue