request->isPost()) { $ids = input('post.ids/a', []); if (empty($ids)) { $ids[] = input('post.id/d'); } $where[] = ['id', 'in', $ids]; OrderRepository::getInstance()->delExpress($where); Log::write('express del', 'del', '删除了快递,涉及到的ID为:'.implode(',', $ids)); return $this->json(); } return $this->json(4001, '非法请求!'); } /** * 添加 * * @return Json|View * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function edit() { $id = input('id/d', 0); if (!$info = OrderRepository::getInstance()->expressInfo($id)) { return $this->json(4001, '数据不存在'); } if ($this->request->isPost()) { $item = input('post.item/a'); try { unset($item['id']); OrderRepository::getInstance()->editExpress($item, ['id' => $id]); return $this->json(); } catch (ValidateException $e) { return $this->json(4001, $e->getError()); } } $this->data['item'] = $info; $this->data['id'] = $id; return $this->view(); } /** * 添加 * * @return Json|View */ public function add() { if ($this->request->isPost()) { $item = input('post.item/a'); try { OrderRepository::getInstance()->addExpress($item); return $this->json(); } catch (ValidateException $e) { return $this->json(4001, $e->getError()); } } return $this->view(); } /** * 快递列表 * * @return View * @throws DbException */ public function index(): View { $size = input('size/d', 20); $urlQuery = input('get.'); $where = []; $where['size'] = $size; $this->data['items'] = OrderRepository::getInstance()->express($where, $urlQuery); return $this->view(); } }