request->isAjax()) { $get = $this->request->get(); $lists = BusinessSchoolLogic::content($get); return JsonServer::success("获取成功", $lists); } return view('', [ 'category' => BusinessSchoolLogic::getCategory() ]); } // 添加内容 public function add_content() { if ($this->request->isAjax()) { (new BusinessSchoolValidate())->goCheck('add'); $post = $this->request->post(); $res = BusinessSchoolLogic::add_content($post); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '新增失败'; return JsonServer::error($error); } return JsonServer::success('新增成功'); } return view('', [ 'category' => BusinessSchoolLogic::getCategory() ]); } // 修改内容 public function edit_content() { if ($this->request->isAjax()) { (new BusinessSchoolValidate())->goCheck('edit'); $post = $this->request->post(); $res = BusinessSchoolLogic::edit_content($post); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '编辑失败'; return JsonServer::error($error); } return JsonServer::success('编辑成功'); } $id = $this->request->get('id'); return view('', [ 'detail' => BusinessSchoolLogic::detail_content($id), 'category' => BusinessSchoolLogic::getCategory() ]); } public function del_content() { if ($this->request->isAjax()) { (new BusinessSchoolValidate())->goCheck('id'); $id = $this->request->post('id'); $res = BusinessSchoolLogic::del_content($id); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '删除失败'; return JsonServer::error($error); } return JsonServer::success('删除成功'); } return JsonServer::success('异常'); } // 上传视频到OSS public function uploadVideo() { $result = UploadAliOSS::uploadFile(self::$UPLOAD_VIDEO_PATH); if ($result['code'] == 1) { return JsonServer::success('', $result['data']); } return JsonServer::error('上传失败'); } // 删除视频 public function delVideo() { if ($this->request->isAjax()) { $file = $this->request->post('videoFile'); UploadAliOSS::delFile(self::$UPLOAD_VIDEO_PATH . '/' . basename($file)); } } // 上传附件 public function uploadFile() { $result = UploadAliOSS::uploadFile(self::$UPLOAD_FILE_PATH); if ($result['code'] == 1) { $result['data']['src'] = $result['data']['file']; $result['data']['file'] = basename($result['data']['file']); return JsonServer::success('', $result['data']); } return JsonServer::error('上传失败'); } // 显示分类列表 public function category() { if ($this->request->isAjax()) { $get = $this->request->get(); $lists = BusinessSchoolLogic::category($get); return JsonServer::success("获取成功", $lists); } return view(); } // 添加分类 public function add_category() { if ($this->request->isAjax()) { (new BusinessSchoolCategoryValidate())->goCheck('add'); $post = $this->request->post(); $res = BusinessSchoolLogic::add_category($post); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '新增失败'; return JsonServer::error($error); } return JsonServer::success('新增成功'); } return view(); } // 修改分类 public function edit_category() { if ($this->request->isAjax()) { (new BusinessSchoolCategoryValidate())->goCheck('edit'); $post = $this->request->post(); $res = BusinessSchoolLogic::edit_category($post); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '编辑失败'; return JsonServer::error($error); } return JsonServer::success('编辑成功'); } $id = $this->request->get('id'); return view('', [ 'detail' => BusinessSchoolLogic::detail_category($id) ]); } // 删除分类 public function del_category() { if ($this->request->isAjax()) { (new BusinessSchoolCategoryValidate())->goCheck('id'); $id = $this->request->post('id'); $res = BusinessSchoolLogic::del_category($id); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '删除失败'; return JsonServer::error($error); } return JsonServer::success('删除成功'); } return JsonServer::error('异常'); } // 隐藏分类 public function hide_category() { if ($this->request->isAjax()) { (new BusinessSchoolCategoryValidate())->goCheck('id'); $id = $this->request->post('id'); $res = BusinessSchoolLogic::hide_category($id); if ($res === false) { $error = BusinessSchoolLogic::getError() ?: '操作失败'; return JsonServer::error($error); } return JsonServer::success('操作成功'); } return JsonServer::success('异常'); } }