repository = $repository; } /** * Common: 信息列表 * Author: wu-hui * Time: 2024/06/12 13:46 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getList(){ [$page, $limit] = $this->getPage(); $params = $this->request->params(['title', 'merchant_type']); $data = $this->repository->getList((array)$params,(int)$page,(int)$limit); return app('json')->success($data); } /** * Common: 生成编辑表单 * Author: wu-hui * Time: 2024/06/12 13:31 * @return mixed * @throws \FormBuilder\Exception\FormBuilderException */ public function getEditForm(){ $id = (int)$this->request->param('id'); $merchantType = (int)$this->request->param('merchant_type'); $data = $this->repository->getEditFormData($id, $merchantType); return app('json')->success(formToData($data)); } /** * Common: 接收编辑表单提交信息并且处理 * Author: wu-hui * Time: 2024/06/12 13:41 * @return mixed * @throws \think\db\exception\DbException */ public function setEditForm(){ $params = $this->request->params([ ['id',0], ['merchant_type', 0], 'title', 'weight', 'mer_quota', 'price', 'quota', 'vegetable_quota', 'oil_quota', 'wine_quota', 'coupon_ids', 'merchant_type', 'integral_switch', 'integral_give_type', 'integral_give_num', 'integral_give_day', 'integral_overdue_day', 'integral_cycle_num' ]); $this->repository->submitEditFormData($params); return app('json')->success('编辑成功'); } /** * Common: 删除信息 * Author: wu-hui * Time: 2024/06/12 14:44 * @param $id * @return mixed */ public function delInfo($id){ $this->repository->update($id,['is_del' => 1]); return app('json')->success('删除成功'); } }