GuideController.class.php
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* 讲师直播引导接口
* Created by PhpStorm.
* User: yingcai
* Date: 2018/1/9
* Time: 下午2:28
*/
namespace Api\Controller\Room;
use Common\Common\Constant;
use Common\Service\MainService;
use Common\Service\RoleService;
class GuideController extends AbstractController
{
/**
* Guide
* @author houyingcai
* @desc 讲师直播引导接口
* @param Int lm_id:true:1 直播活动ID
* @return array|bool 直播列表
array(
'start_time' => 1515407868910, // 直播开始时间
'name' => '产品培训讲解', // 直播名称
'estimated_duration' => 45, // 预计时长(单位:分钟)
'pic' => 'b3ddbc502e307665f346cbd6e52cc10d', // 封面图ID
'pic_url' => 'http://qy.vchangyi.org', // 封面图片URL
'live_password' => 'abc123', // 直播密令
)
*/
public function Index_post()
{
$lmId = I('post.lm_id', 0, 'rintval');
// 直播ID不能为空
if (!$lmId) {
E('_EMPTY_LIVE_ID');
}
// 获取直播信息
$mainService = new MainService();
$mainDetail = $mainService->get($lmId);
// 直播信息不存在
if (empty($mainDetail)) {
E('_ERR_LIVE_NOT_EXISTS');
}
// 获取直播讲师信息
$roleService = new RoleService();
$roleInfo = $roleService->get_by_conds([
'lm_id' => $lmId,
'type' => Constant::LIVE_ROLE_TYPE_LECTURER,
'obj_id' => $this->uid,
]);
// 讲师信息不存在
if (empty($roleInfo)) {
E('_ERR_LECTURER_NOT_EXISTS');
}
// 直播密令
$live_password = $roleInfo['password'];
// 返回数据
$this->_result = [
'start_time' => $mainDetail['start_time'],
'name' => $mainDetail['name'],
'estimated_duration' => $mainDetail['estimated_duration'],
'pic' => $mainDetail['pic'],
'pic_url' => $mainService->formatCover($mainDetail['pic']),
'live_password' => $live_password,
];
return true;
}
}