<?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; } }