toData('1', '参错错误'); } if (empty($param['limit']) || !is_numeric($param['limit'])) { return $this->toData('1', '参错错误'); } $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('100500', '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('1', '参错错误'); } $insert = VideoOnDemandModel::create([ 'title' => $param['title'], 'desc' => $param['desc'] ?? "", 'cover_id' => $param['cover_id'], 'video_id' => $param['video_id'], 'cover_url' => $param['cover_url'], 'video_url' => $param['video_url'], 'sort' => $param['sort'] ?? 0, 'state' => $param['state'], ]); return $this->toData('0', 'SUCCESS', ['insert_id' => $insert->id]); } catch (\Exception $exception) { return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } // 编辑点播信息 public function editVideoOnDemand($param) { try { if (empty($param['id'])) { return $this->toData('1', '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('1', '参错错误'); } $ckInfo = VideoOnDemandModel::where('id', $param['id'])->find(); if (empty($ckInfo)) { return $this->toData('1', '编辑的数据不存在'); } $ckInfo->title = $param['title']; $ckInfo->desc = $param['desc']; $ckInfo->cover_id = $param['cover_id']; $ckInfo->video_id = $param['video_id']; $ckInfo->cover_url = $param['cover_url']; $ckInfo->video_url = $param['video_url']; $ckInfo->sort = $param['sort']; $ckInfo->state = $param['state']; $ckInfo->save(); return $this->toData('1', 'Successful'); } catch (\Exception $exception) { return $this->toData('100500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); } } }