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.6 KiB
70 lines
2.6 KiB
<?php
|
|
namespace app\home\service;
|
|
|
|
use app\model\BlockedWordModel;
|
|
use app\model\VideoOnDemandModel;
|
|
|
|
class VideoService extends BaseHomeService
|
|
{
|
|
// 获取点播视频
|
|
public function getVideoOnDemandList($param): array
|
|
{
|
|
try {
|
|
if (empty($param['page']) || !is_numeric($param['page'])) {
|
|
return $this->toData('400', lang('parameter_error'));
|
|
}
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) {
|
|
return $this->toData('400', lang('parameter_error'));
|
|
}
|
|
|
|
$where = ['state'=>1];
|
|
if (isset($param['video_type']) && $param['video_type'] > 0) {
|
|
$where['video_type'] = $param['video_type'];
|
|
}
|
|
if (isset($param['sub_type']) && $param['sub_type'] > 0) {
|
|
$where['sub_type'] = $param['sub_type'];
|
|
}
|
|
|
|
$list = VideoOnDemandModel::where($where)->order('sort', 'desc')->paginate([
|
|
'list_rows' => $param['limit'],
|
|
'page' => $param['page'],
|
|
]);
|
|
|
|
return $this->toData('0', 'successful', [
|
|
'list' => $list->items(), // 当前页的数据
|
|
'page' => $list->currentPage(), // 当前页码
|
|
'total' => $list->total(), // 总记录数
|
|
'last_page' => $list->lastPage(), // 最后一页页码
|
|
]);
|
|
} catch (\Exception $exception) {
|
|
return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]);
|
|
}
|
|
}
|
|
|
|
public function getVideoOnDemandDetail($param): array
|
|
{
|
|
try {
|
|
if (empty($param['id']) || !is_numeric($param['id'])) {
|
|
return $this->toData('400', lang('parameter_error'));
|
|
}
|
|
$info = VideoOnDemandModel::where(['id'=>$param['id']])->find();
|
|
if (empty($info)) {
|
|
return $this->toData('500', 'successful', []);
|
|
}
|
|
return $this->toData('0', 'successful', $info->toArray());
|
|
} catch (\Exception $exception) {
|
|
return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]);
|
|
}
|
|
}
|
|
|
|
// 获取屏蔽词列表
|
|
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', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]);
|
|
}
|
|
}
|
|
}
|