diff --git a/app/admin/service/VideoService.php b/app/admin/service/VideoService.php index 88433581..26c23ef8 100644 --- a/app/admin/service/VideoService.php +++ b/app/admin/service/VideoService.php @@ -38,7 +38,7 @@ class VideoService extends AdminBaseService public function addVideoOnDemand($param) { try { - if (empty($param['title']) || empty($param['cover_url']) || empty($param['state']) || empty($param['video_collection'])) { + if (empty($param['title']) || empty($param['cover_url']) || empty($param['state']) || empty($param['video_collection']) || empty($param['video_type'])) { return $this->toData('400', '参错错误'); } $insert = VideoOnDemandModel::create([ @@ -48,7 +48,9 @@ class VideoService extends AdminBaseService 'banner_url' => $param['banner_url'], 'sort' => $param['sort'] ?? 0, 'state' => $param['state'], - 'video_collection' => $param['video_collection'] + 'video_collection' => $param['video_collection'], + 'video_type' => $param['video_type'], + 'sub_type' => $param['sub_type'] ?? 0, ]); return $this->toData('0', 'SUCCESS', ['insert_id' => $insert->id]); } catch (\Exception $exception) { @@ -63,7 +65,7 @@ class VideoService extends AdminBaseService if (empty($param['id'])) { return $this->toData('400', 'Missing param id'); } - if (empty($param['title']) || empty($param['cover_url']) || empty($param['state']) || empty($param['video_collection'])) { + if (empty($param['title']) || empty($param['cover_url']) || empty($param['state']) || empty($param['video_collection']) || empty($param['video_type'])) { return $this->toData('400', '参错错误'); } $ckInfo = VideoOnDemandModel::where('id', $param['id'])->find(); @@ -78,6 +80,8 @@ class VideoService extends AdminBaseService $ckInfo->sort = $param['sort']; $ckInfo->state = $param['state']; $ckInfo->video_collection = $param['video_collection']; + $ckInfo->video_type = $param['video_type']; + $ckInfo->sub_type = $param['sub_type']; $ckInfo->save(); return $this->toData('0', 'success'); } catch (\Exception $exception) { diff --git a/app/home/service/VideoService.php b/app/home/service/VideoService.php index 25753eec..1d9ed2f0 100644 --- a/app/home/service/VideoService.php +++ b/app/home/service/VideoService.php @@ -6,6 +6,7 @@ use app\model\VideoOnDemandModel; class VideoService extends BaseHomeService { + // 获取点播视频 public function getVideoOnDemandList($param): array { try { @@ -15,10 +16,20 @@ class VideoService extends BaseHomeService if (empty($param['limit']) || !is_numeric($param['limit'])) { return $this->toData('400', '参错错误'); } - $list = VideoOnDemandModel::where(['state'=>1])->order('sort', 'desc')->paginate([ - 'list_rows' => $param['limit'], - 'page' => $param['page'], - ]); + + // 根据video_type 过滤数据 + if (isset($param['video_type']) && $param['video_type'] > 0 ) { + $list = VideoOnDemandModel::where(['state'=>1,'video_type'=>$param['video_type']])->order('sort', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + } else { + $list = VideoOnDemandModel::where(['state'=>1])->order('sort', 'desc')->paginate([ + 'list_rows' => $param['limit'], + 'page' => $param['page'], + ]); + } + return $this->toData('0', 'Successful', [ 'list' => $list->items(), // 当前页的数据 'page' => $list->currentPage(), // 当前页码