list([]); dd($data); } public function search() { $keyword = $this->request->param('keyword'); $page = $this->request->param('page', 1); $limit = $this->request->param('limit', 10); if (!$keyword) { $this->renderError('请输入搜索关键字'); } $params = ['goods_name' => $keyword]; $goodsService = new GoodsEs(); $list = $goodsService->list($params, $page, $limit); $data['list'] = $list; $data['total'] = $goodsService->count(); return $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); } }