Files

50 lines
1.2 KiB
PHP

<?php
namespace app\admin\controller\live;
use app\common\controller\Backend;
/**
* 直播数据
*/
class Data extends Backend
{
/**
* AttachmentGroup模型对象
* @var \app\admin\model\attachment\AttachmentGroup
*/
protected $model = null;
//中控台数据接口无需权限节点校验,讲师角色无对应权限节点也可访问
protected $noNeedRight = ['watchtotal'];
public function _initialize()
{
parent::_initialize();
}
/**
* 观看统计
* @return void
*/
public function watchTotal(){
$liveId = input('live_id');
$liveUserModel = new \app\admin\model\live\User;
$data = [
'online_user_amount'=>0,//在线人数
'history_user_amount'=>0,//历史观看人数
'watch_amount'=>0//观看次数
];
$data['online_user_amount'] = $liveUserModel->getOnlineUserCount($liveId);
$data['history_user_amount'] = $liveUserModel->where(['live_id'=>$liveId])->count();
$data['watch_amount'] = (new \app\admin\model\data\Study)->where(['course_id'=>$liveId])->count();
$this->success("获取成功",$data);
}
}