初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user