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.
177 lines
7.0 KiB
177 lines
7.0 KiB
<?php
|
|
namespace app\admin\service;
|
|
use app\model\BlockedWordModel;
|
|
use app\model\VideoOnDemandModel;
|
|
|
|
class VideoService extends AdminBaseService
|
|
{
|
|
// 获取点播列表
|
|
public function videoOnDemandList($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', '参错错误');
|
|
}
|
|
$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_url']) || empty($param['state']) || empty($param['video_collection']) || empty($param['video_type'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
$insert = VideoOnDemandModel::create([
|
|
'title' => $param['title'],
|
|
'desc' => $param['desc'] ?? "",
|
|
'cover_url' => $param['cover_url'],
|
|
'banner_url' => $param['banner_url'],
|
|
'sort' => $param['sort'] ?? 0,
|
|
'state' => $param['state'],
|
|
'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) {
|
|
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_url']) || empty($param['state']) || empty($param['video_collection']) || empty($param['video_type'])) {
|
|
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_url = $param['cover_url'];
|
|
$ckInfo->banner_url = $param['banner_url'];
|
|
$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) {
|
|
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()]);
|
|
}
|
|
}
|
|
|
|
}
|
|
|