request->isAjax()) { $get = $this->request->get(); $lists = LegalLogic::lists($get); return JsonServer::success("获取成功", $lists); } return view('', [ 'cates' => LegalCateLogic::getCate(), ]); } /** * @NOTES: 添加帮助类 * @author: 张无忌 */ public function add() { if ($this->request->isAjax()) { $post = $this->request->post(); $res = LegalLogic::add($post); if ($res === false) { $error = LegalLogic::getError() ?: '新增失败'; return JsonServer::error($error); } return JsonServer::success('新增成功'); } return view('', [ 'cates' => LegalCateLogic::getCate(), ]); } /** * @NOTES: 编辑帮助分类 * @author: 张无忌 */ public function edit() { if ($this->request->isAjax()) { $post = $this->request->post(); $res = LegalLogic::edit($post); if ($res === false) { $error = LegalLogic::getError() ?: '编辑失败'; return JsonServer::error($error); } return JsonServer::success('编辑成功'); } $id = $this->request->get('id'); $detail = LegalLogic::detail($id); $category2 = []; if($detail['cate_id']>0){ $category2 = LegalCateLogic::getCate($detail['cate_id']); } return view('', [ 'detail' => $detail, 'cates' => LegalCateLogic::getCate(), 'cate2' => $category2, ]); } /** * @NOTES: 删除帮助分类 * @author: 张无忌 */ public function del() { if ($this->request->isAjax()) { $id = $this->request->post('id'); $res = LegalLogic::del($id); if ($res === false) { $error = LegalLogic::getError() ?: '删除失败'; return JsonServer::error($error); } return JsonServer::success('删除成功'); } return JsonServer::error('异常'); } /** * @Notes: 隐藏帮助分类 * @Author: 张无忌 */ public function hide() { if ($this->request->isAjax()) { $id = $this->request->post('id'); $res = LegalLogic::hide($id); if ($res === false) { $error = LegalLogic::getError() ?: '操作失败'; return JsonServer::error($error); } return JsonServer::success('操作成功'); } return JsonServer::success('异常'); } /** * @notes 审核文章 * @return \think\response\Json|\think\response\View * @author 段誉 * @date 2022/5/10 17:45 */ public function handle() { if ($this->request->isAjax()) { $post = $this->request->post(); $result = LegalLogic::handle($post); if (false === $result) { return JsonServer::error(LegalLogic::getError() ?: '操作失败'); } return JsonServer::success('编辑成功'); } $id = $this->request->get('id'); return view('', [ 'detail' => LegalLogic::detail($id) ]); } }