diff --git a/app/api/controller/GoodsNew.php b/app/api/controller/GoodsNew.php index 80fd4f5c..2332a571 100644 --- a/app/api/controller/GoodsNew.php +++ b/app/api/controller/GoodsNew.php @@ -4,6 +4,7 @@ namespace app\api\controller; use app\common\service\GoodsEs; +use think\App; class GoodsNew extends Controller { @@ -13,4 +14,58 @@ class GoodsNew extends Controller $data = $goodsService->list([]); dd($data); } + + public function search() + { + $keyword = $this->request->param('keyword'); + $page = $this->request->param('page', 1); + $limit = $this->request->param('limit', 10); + $params = ['goods_name' => $keyword]; + $goodsService = new GoodsEs(); + $data = $goodsService->list($params, $page, $limit); + $this->renderSuccess($data); + } + + + /** + * 添加商品 + */ + public function add() + { + $goods_id = 1; + $goods_data = \app\common\model\Goods::where('goods_id', '=', $goods_id) + ->order('goods_id desc') + ->find() + ->toArray(); + $goodsService = new GoodsEs(); + $data = $goodsService->createData($goods_id, $goods_data); + $this->renderSuccess($data); + } + + /** + * 更新商品 + */ + public function update() + { + $goods_id = 1; + $update = [ + 'goods_name' => '测试商品', + 'selling_point' => '测试商品', + 'goods_price_min' => 100, + 'goods_price_max' => 100, + ]; + $goodsService = new GoodsEs(); + $data = $goodsService->updateData($goods_id, $update); + $this->renderSuccess($data); + } + /** + * 删除 + */ + public function delete() + { + $goods_id = 1; + $goodsService = new GoodsEs(); + $data = $goodsService->delete($goods_id); + $this->renderSuccess($data); + } } \ No newline at end of file diff --git a/app/common/service/GoodsEs.php b/app/common/service/GoodsEs.php index 79bf5803..7ea8e2c4 100644 --- a/app/common/service/GoodsEs.php +++ b/app/common/service/GoodsEs.php @@ -36,7 +36,7 @@ class GoodsEs /** * 更新商品 */ - public function update($goods_id, $data) + public function updateData($goods_id, $data) { return $this->esService->update($goods_id, $data); }