作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

课程播放次数

<?php
return [
'Id' => 'ID',
'Course_id' => '课程ID',
'Pid' => '上级目录ID',
'Name' => '目录名称',
'Video' => '视频地址',
'Createtime' => '创建时间',
'Updatetime' => '修改时间',
'Weigh' => '权重'
'Id' => 'ID',
'Course_id' => '课程ID',
'Pid' => '上级目录ID',
'Name' => '目录名称',
'Video' => '视频地址',
'Play_num_virtual' => '虚拟播放次数',
'Play_num_real' => '真实播放次数',
'Createtime' => '创建时间',
'Updatetime' => '修改时间',
'Weigh' => '权重'
];
... ...
... ... @@ -31,6 +31,18 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Play_num_virtual')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-play_num_virtual" data-rule="required" class="form-control" name="row[play_num_virtual]" type="number" value="0">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Play_num_real')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-play_num_real" data-rule="required" class="form-control" name="row[play_num_real]" type="number" value="0" readonly>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0">
... ...
... ... @@ -31,6 +31,18 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Play_num_virtual')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-play_num_virtual" data-rule="required" class="form-control" name="row[play_num_virtual]" type="number" value="{$row.play_num_virtual|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Play_num_real')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-play_num_real" data-rule="required" class="form-control" name="row[play_num_real]" type="number" value="{$row.play_num_real|htmlentities}" readonly>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
... ...
... ... @@ -231,6 +231,32 @@ class Course extends Api
}
/**
* @ApiTitle (课程详情-目录-播放)
* @ApiSummary (课程详情-目录-播放)
* @ApiMethod (POST)
*
* @ApiParams (name="course_catalog_id", type="int", required=true, description="目录ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1600927297",
"data": null
})
*/
public function play()
{
$course_catalog_id = $this->request->param('course_catalog_id');
empty($course_catalog_id) && $this->error('缺少必要参数');
$info = CourseCatalog::get($course_catalog_id);
empty($info) && $this->error('目录信息不存在');
// 播放次数加1
$info->play_num_real = $info->play_num_real + 1;
$info->save();
$this->success('成功');
}
/**
* @ApiTitle (课程详情-老师)
* @ApiSummary (课程详情-老师)
* @ApiMethod (POST)
... ...
... ... @@ -27,6 +27,13 @@ class CourseCatalog extends Model
}
// 获取七牛云视频信息
$video = cdnurl($value,true);
try {
$client = new \GuzzleHttp\Client();
$client->request('GET', $video);
//成功不做任何操作
} catch (\GuzzleHttp\Exception\ClientException $e) {
return [];
}
$video_info = json_decode(file_get_contents($video.'?avinfo'),true);
return [
'cover' => $this->getCoverImagesQiniu($video,$video_info),
... ...
... ... @@ -34,6 +34,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
},
{field: 'video', title: __('Video'), formatter: Table.api.formatter.url},
{field: 'play_num_virtual', title: __('Play_num_virtual')},
{field: 'play_num_real', title: __('Play_num_real')},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'weigh', title: __('Weigh')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
... ...
此 diff 太大无法显示。