toData('400', '参错错误'); } if (empty($param['limit']) || !is_numeric($param['limit'])) { return $this->toData('400', '参错错误'); } $where = []; if (isset($param['title'])) { $where['title'] = $param['title']; } $list = VideoOnDemandModel::where($where)->order('id', 'desc')->paginate([ 'list_rows' => $param['limit'], 'page' => $param['page'], ]); return $this->toData('0', 'SUCCESS', [ 'list' => $list->items(), // 当前页的数据 'page' => $list->currentPage(), // 当前页码 'total' => $list->total(), // 总记录数 'last_page' => $list->lastPage(), // 最后一页页码 ]); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 添加点播信息 public function addVideoOnDemand($param) { try { if (empty($param['title']) || empty($param['cover_id']) || empty($param['video_id']) || empty($param['cover_url']) || empty($param['video_url'] || empty($param['state'])) ) { return $this->toData('400', '参错错误'); } $insert = VideoOnDemandModel::create([ 'title' => $param['title'], 'desc' => $param['desc'] ?? "", 'cover_id' => $param['cover_id'], 'video_id' => $param['video_id'], 'banner_id' => $param['banner_id'], 'cover_url' => $param['cover_url'], 'video_url' => $param['video_url'], 'banner_url' => $param['banner_url'], 'sort' => $param['sort'] ?? 0, 'state' => $param['state'], ]); return $this->toData('0', 'SUCCESS', ['insert_id' => $insert->id]); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 编辑点播信息 public function editVideoOnDemand($param) { try { if (empty($param['id'])) { return $this->toData('400', 'Missing param id'); } if (empty($param['title']) || empty($param['cover_id']) || empty($param['video_id']) || empty($param['cover_url']) || empty($param['video_url'] || empty($param['state'])) ) { return $this->toData('400', '参错错误'); } $ckInfo = VideoOnDemandModel::where('id', $param['id'])->find(); if (empty($ckInfo)) { return $this->toData('500', '编辑的数据不存在'); } $ckInfo->title = $param['title']; $ckInfo->desc = $param['desc']; $ckInfo->cover_id = $param['cover_id']; $ckInfo->video_id = $param['video_id']; $ckInfo->banner_id = $param['banner_id']; $ckInfo->cover_url = $param['cover_url']; $ckInfo->video_url = $param['video_url']; $ckInfo->banner_url = $param['banner_url']; $ckInfo->sort = $param['sort']; $ckInfo->state = $param['state']; $ckInfo->save(); return $this->toData('0', 'success'); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 屏蔽词列表 public function blockedWordList($param) { try { if (empty($param['page']) || !is_numeric($param['page'])) { return $this->toData('400', '参错错误'); } if (empty($param['limit']) || !is_numeric($param['limit'])) { return $this->toData('400', '参错错误'); } $list = BlockedWordModel::order('id', 'desc')->paginate([ 'list_rows' => $param['limit'], 'page' => $param['page'], ]); return $this->toData('0', 'SUCCESS', [ 'list' => $list->items(), // 当前页的数据 'page' => $list->currentPage(), // 当前页码 'total' => $list->total(), // 总记录数 'last_page' => $list->lastPage(), // 最后一页页码 ]); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 新增屏蔽词 public function blockedWordAdd($param) { try { if (empty($param['word'])) { return $this->toData('400', '参错错误'); } $blockedWord = BlockedWordModel::where(['word'=>$param['word']])->find(); if (!empty($blockedWord)) { return $this->toData('400', '已存在相同屏蔽词'); } $insert = BlockedWordModel::create([ 'word' => $param['word'], ]); if (!$insert) { return $this->toData('500', '添加失败'); } return $this->toData('0', 'SUCCESS'); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 编辑屏蔽词 public function blockedWordEdit($param) { try { if (empty($param['id']) || empty($param['word'])) { return $this->toData('400', '参错错误'); } $blockedWord = BlockedWordModel::where(['id'=>$param['id']])->find(); if (empty($blockedWord)) { return $this->toData('400', '数据不存在'); } $blockedWord->word = $param['word']; $blockedWord->save(); return $this->toData('0', 'SUCCESS'); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 删除屏蔽词 public function blockedWordDelete($param) { try { if (empty($param['id'])) { return $this->toData('400', '参错错误'); } $blockedWord = BlockedWordModel::where(['id'=>$param['id']])->find(); if (empty($blockedWord)) { return $this->toData('400', '数据不存在'); } $blockedWord->state = 0; $blockedWord->save(); return $this->toData('0', 'SUCCESS'); } catch (\Exception $exception) { return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } }