getList($this->request->param()); return $this->renderSuccess(compact('list')); } /** * 刷新数据 */ public function refresh() { $date = date('Y-m-d'); PromotionMonitorStatisticsModel::addData($date); return $this->renderSuccess(); } /** * 详情 * @param int $id * @return array */ public function detail(int $id) { $model = new PromotionMonitorModel; $detail = $model->detail($id); return $this->renderSuccess(compact('detail')); } /** * 添加 * @return array|string */ public function add() { // 新增记录 $model = new PromotionMonitorModel; $post = $this->postForm(); if ($model->add($post)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 编辑 * @param int $id * @return mixed */ public function edit(int $id) { // 详情 $model = PromotionMonitorModel::detail($id); // 更新记录 if ($model->edit($this->postForm())) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } }