diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index c46b361..5cbc08b 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -108,16 +108,13 @@ class GoodsController extends BaseController $first = $this->categoryService->getByParentId(0); $secend = $this->categoryService->getByParentId($goods['category_id']); $third = $this->categoryService->getThird($goods['category_id']); + $tags = $this->goodsService->getTags(); return $this->success([ 'goods' => $goods, 'first' => $first, 'secend' => $secend, 'third' => $third, - 'tags' => [ - '新品', - '热销', - '新鲜' - ] + 'tags' => $tags ]); } @@ -126,4 +123,10 @@ class GoodsController extends BaseController $res = $this->goodsService->create($this->request->all()); return $this->success($res); } + + public function getTags() + { + $tags = $this->goodsService->getTags(); + return $this->success(['tags' => $tags]); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 9552111..65c9885 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -133,4 +133,13 @@ class GoodsService implements GoodsServiceInterface $res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->first(); return $res; } + + public function getTags() + { + return [ + '新品', + '热销', + '新鲜' + ]; + } } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/GoodsServiceInterface.php b/app/Service/v3/Interfaces/GoodsServiceInterface.php index 0ea31b3..efb6f77 100644 --- a/app/Service/v3/Interfaces/GoodsServiceInterface.php +++ b/app/Service/v3/Interfaces/GoodsServiceInterface.php @@ -14,4 +14,5 @@ interface GoodsServiceInterface public function getByType($storeId,$typeId); public function update($params); public function info($goodsId); + public function getTags(); } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index b2c28d4..76fd698 100644 --- a/config/routes.php +++ b/config/routes.php @@ -96,6 +96,7 @@ Router::addGroup('/v3/', function () { Router::post('orderOffline/review', 'App\Controller\v3\OrderOfflineController@review'); Router::post('paramsToken/generate', 'App\Controller\v3\ParamsTokenController@generate'); Router::post('paramsToken/analyze', 'App\Controller\v3\ParamsTokenController@analyze'); + Router::post('goods/getTags', 'App\Controller\v3\GoodsController@getTags'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); // 需要登录的路由