diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php new file mode 100644 index 0000000..30b344a --- /dev/null +++ b/app/Controller/v3/GoodsController.php @@ -0,0 +1,19 @@ +goods->detail(); + return $this->success($res); + } +} \ No newline at end of file diff --git a/app/Middleware/Auth/UserMiddleware.php b/app/Middleware/Auth/UserMiddleware.php new file mode 100644 index 0000000..d843008 --- /dev/null +++ b/app/Middleware/Auth/UserMiddleware.php @@ -0,0 +1,42 @@ +handle($request); + } + + // 校验 + if (!$this->checkLogin()) { + + $content = [ + "status" => 'ok', + "code" => 9002, + "result" => [], + "message" => '用户登录已失效' + ]; + + return $this->response->json($content); + } + + return $handler->handle($request); + } + + private function checkLogin() + { + return true; + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php new file mode 100644 index 0000000..46a9d47 --- /dev/null +++ b/app/Service/v3/Implementations/GoodsService.php @@ -0,0 +1,56 @@ +where('id',170)->get(); + $goods['banner'] = $this->getBanner(); + $goods['spec'] = $this->getSpec(); + return $goods; + } + + public function getBanner() + { + $banner = [ + [ + 'id' => 1, + 'type' => 1, + 'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_0.jpg' + ], + [ + 'id' => 2, + 'type' => 1, + 'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_1.jpg' + ] + ]; + return $banner; + } + + public function getSpec() + { + $spec = [ + [ + '净含量' => '约500G', + '保存条件' => '常温', + '保质期' => '10天' + ] + ]; + return $spec; + } +} \ No newline at end of file diff --git a/app/Service/v3/Interfaces/GoodsServiceInterface.php b/app/Service/v3/Interfaces/GoodsServiceInterface.php new file mode 100644 index 0000000..20638d5 --- /dev/null +++ b/app/Service/v3/Interfaces/GoodsServiceInterface.php @@ -0,0 +1,8 @@ + \App\Service\WxRefundService::class, \App\Service\SmsServiceInterface::class => \App\Service\SmsAliService::class, \App\Service\OrderListServiceInterface::class => \App\Service\OrderListService::class, + \App\Service\v3\Interfaces\GoodsServiceInterface::class => \App\Service\v3\Implementations\GoodsService::class, ]; diff --git a/config/routes.php b/config/routes.php index 659680f..cf42f1f 100644 --- a/config/routes.php +++ b/config/routes.php @@ -73,4 +73,16 @@ Router::addGroup('/wechat/',function () { Router::post('notify/wxminionline', 'App\Controller\NotifyController@wxminiOnline'); Router::post('notify/wxminioffline', 'App\Controller\NotifyController@wxminiOffline'); Router::post('notify/wxpayrefund', 'App\Controller\NotifyPayRefundController@wxPayRefund'); -}); \ No newline at end of file +}); + +// 不需要登录的路由 +Router::addGroup('/v3/', function () { + Router::post('location/getNearestMarket', 'App\Controller\v3\LocationController@getNearestMarket'); + Router::post('home/appletIndex', 'App\Controller\v3\HomeController@appletIndex'); + Router::post('Goods/detail', 'App\Controller\v3\GoodsController@detail'); +},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); + +// 需要登录的路由 +Router::addGroup('/v3/', function () { + +},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); \ No newline at end of file