p2 project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.5 KiB

5 months ago
<?php
namespace app\home\service;
4 months ago
use app\model\BlockedWordModel;
5 months ago
use app\model\VideoOnDemandModel;
class VideoService extends BaseHomeService
{
2 months ago
// 获取点播视频
5 months ago
public function getVideoOnDemandList($param): array
{
try {
if (empty($param['page']) || !is_numeric($param['page'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
if (empty($param['limit']) || !is_numeric($param['limit'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
2 months ago
// 根据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'],
]);
}
5 months ago
return $this->toData('0', 'Successful', [
'list' => $list->items(), // 当前页的数据
'page' => $list->currentPage(), // 当前页码
'total' => $list->total(), // 总记录数
'last_page' => $list->lastPage(), // 最后一页页码
]);
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', 'The system is busy.', []);
5 months ago
}
}
public function getVideoOnDemandDetail($param): array
{
try {
if (empty($param['id']) || !is_numeric($param['id'])) {
4 months ago
return $this->toData('400', '参错错误');
5 months ago
}
$info = VideoOnDemandModel::where(['id'=>$param['id']])->find();
if (empty($info)) {
4 months ago
return $this->toData('500', 'Successful', []);
5 months ago
}
return $this->toData('0', 'Successful', $info->toArray());
} catch (\Exception $exception) {
4 months ago
return $this->toData('500', 'The system is busy.', []);
}
}
// 获取屏蔽词列表
public function blockedWordList($param)
{
try {
$list = BlockedWordModel::where(['state'=>1])->column(['word']);
return $this->toData('0', 'Successful', $list);
} catch (\Exception $exception) {
return $this->toData('500', 'The system is busy.');
5 months ago
}
}
}