request->isAjax()) { $get = $this->request->get(); $lists = ClosureLogic::lists($get); return JsonServer::success("获取成功", $lists); } return view('', [ 'category' => ClosureCategoryLogic::getCategory() ]); } public function add() { if ($this->request->isAjax()) { (new ClosureValidate())->goCheck('add'); $post = $this->request->post(); $res = ClosureLogic::add($post); if ($res === false) { $error = ClosureLogic::getError() ?: '新增失败'; return JsonServer::error($error); } return JsonServer::success('新增成功'); } return view('', [ 'category' => ClosureCategoryLogic::getCategory() ]); } /*** * @Notes: 编辑文章 * @Author: 张无忌 */ public function edit() { if ($this->request->isAjax()) { (new ClosureValidate())->goCheck('edit'); $post = $this->request->post(); $res = ClosureLogic::edit($post); if ($res === false) { $error = ClosureLogic::getError() ?: '编辑失败'; return JsonServer::error($error); } return JsonServer::success('编辑成功'); } $id = $this->request->get('id'); return view('', [ 'detail' => ClosureLogic::detail($id), 'category' => ClosureCategoryLogic::getCategory() ]); } /** * @Notes: 删除文章 * @Author: 张无忌 */ public function del() { if ($this->request->isAjax()) { (new ClosureValidate())->goCheck('id'); $id = $this->request->post('id'); $res = ClosureLogic::del($id); if ($res === false) { $error = ClosureLogic::getError() ?: '删除失败'; return JsonServer::error($error); } return JsonServer::success('删除成功'); } return JsonServer::success('异常'); } /** * @Notes: 隐藏文章 * @Author: 张无忌 */ public function hide() { if ($this->request->isAjax()) { (new ClosureValidate())->goCheck('id'); $id = $this->request->post('id'); $res = ClosureLogic::hide($id); if ($res === false) { $error = ClosureLogic::getError() ?: '操作失败'; return JsonServer::error($error); } return JsonServer::success('操作成功'); } return JsonServer::success('异常'); } }