Browse Source

获取商品标签

master
Lemon 5 years ago
parent
commit
818a8495d9
  1. 13
      app/Controller/v3/GoodsController.php
  2. 9
      app/Service/v3/Implementations/GoodsService.php
  3. 1
      app/Service/v3/Interfaces/GoodsServiceInterface.php
  4. 1
      config/routes.php

13
app/Controller/v3/GoodsController.php

@ -108,16 +108,13 @@ class GoodsController extends BaseController
$first = $this->categoryService->getByParentId(0); $first = $this->categoryService->getByParentId(0);
$secend = $this->categoryService->getByParentId($goods['category_id']); $secend = $this->categoryService->getByParentId($goods['category_id']);
$third = $this->categoryService->getThird($goods['category_id']); $third = $this->categoryService->getThird($goods['category_id']);
$tags = $this->goodsService->getTags();
return $this->success([ return $this->success([
'goods' => $goods, 'goods' => $goods,
'first' => $first, 'first' => $first,
'secend' => $secend, 'secend' => $secend,
'third' => $third, 'third' => $third,
'tags' => [
'新品',
'热销',
'新鲜'
]
'tags' => $tags
]); ]);
} }
@ -126,4 +123,10 @@ class GoodsController extends BaseController
$res = $this->goodsService->create($this->request->all()); $res = $this->goodsService->create($this->request->all());
return $this->success($res); return $this->success($res);
} }
public function getTags()
{
$tags = $this->goodsService->getTags();
return $this->success(['tags' => $tags]);
}
} }

9
app/Service/v3/Implementations/GoodsService.php

@ -133,4 +133,13 @@ class GoodsService implements GoodsServiceInterface
$res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->first(); $res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->first();
return $res; return $res;
} }
public function getTags()
{
return [
'新品',
'热销',
'新鲜'
];
}
} }

1
app/Service/v3/Interfaces/GoodsServiceInterface.php

@ -14,4 +14,5 @@ interface GoodsServiceInterface
public function getByType($storeId,$typeId); public function getByType($storeId,$typeId);
public function update($params); public function update($params);
public function info($goodsId); public function info($goodsId);
public function getTags();
} }

1
config/routes.php

@ -96,6 +96,7 @@ Router::addGroup('/v3/', function () {
Router::post('orderOffline/review', 'App\Controller\v3\OrderOfflineController@review'); Router::post('orderOffline/review', 'App\Controller\v3\OrderOfflineController@review');
Router::post('paramsToken/generate', 'App\Controller\v3\ParamsTokenController@generate'); Router::post('paramsToken/generate', 'App\Controller\v3\ParamsTokenController@generate');
Router::post('paramsToken/analyze', 'App\Controller\v3\ParamsTokenController@analyze'); Router::post('paramsToken/analyze', 'App\Controller\v3\ParamsTokenController@analyze');
Router::post('goods/getTags', 'App\Controller\v3\GoodsController@getTags');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]);
// 需要登录的路由 // 需要登录的路由

Loading…
Cancel
Save