InfoController.class.php
3.81 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
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017/4/27
* Time: 11:41
*/
namespace Apicp\Controller\Course;
use Com\PackageValidate;
use Common\Common\Constant;
use Common\Common\Teacher;
use Common\Service\CourseArticleService;
use Common\Service\CourseItemService;
class InfoController extends \Apicp\Controller\AbstractController
{
/**
* Info
* @author tangxingguo
* @desc 课程详情
* @param int article_id:true 课程ID
* @return array 课程详情
array(
'article_id' => 123, // 课程ID
'article_title' => '好好学', // 课程标题
'ed_id' => 1, // 培训ID
'plan_id' => 2, // 培训安排ID
'cover_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 封面图片ID
'cover_url' => 'http://qy.vchangyi.org', // 封面图片地址
'start_time' => 12367890567, // 授课开始时间
'end_time' => 12367890567, // 授课结束时间
'credit' => 12, // 学分
'address' => '上海徐汇', // 授课地址
'content' => '介绍介绍课程', // 课程介绍
'is_notice' => 1, // 消息通知讲师(1=不开启,2=开启)
'tags' => '哈哈 啊啊', // 课程标签
'teacher_id' => 1, // 讲师ID
'teacher_name' => '李四', // 讲师姓名
'teacher_task_id' => 0, // 讲师授课任务ID(未设置任务时为0)
'task_name' => '第二季度任务', // 讲师授课任务名称
'class_hour' => 88.88, // 讲师授课课时
'is_reward' => 1, // 是否启用赞赏(1=不启用;2=启用)
'is_score' => 1, // 是否启用评分(1=不启用;2=启用)
'is_sign' => 1, // 是否启用签到(1=不启用;2=启用)
'score_item' => array( // 评分设置
array(
'item_id' => 1, // 评分项ID
'content' => '课程内容清晰合理、层次分明', // 评分内容
'score_type' => 1, // 评分类型(1=课程内容;2=课程讲师)
'score_order' => 1, // 排序
),
),
);
*/
public function Index_post()
{
// 验证规则
$rules = [
'article_id' => 'require|integer',
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$articleId = $validate->postData['article_id'];
// 取课程
$articleServ = new CourseArticleService();
$article = $articleServ->get($articleId);
if (empty($article)) {
E('_ERR_ARTICLE_DATA_NOT_FOUND');
}
// 讲师姓名
$teacherServ = &Teacher::instance();
$teacher = $teacherServ->getTeacherInfo($article['teacher_id']);
$article['teacher_name'] = isset($teacher['teacher_name']) ? $teacher['teacher_name'] : '';
// 授课任务名称
$task = $teacherServ->getTeackerTask($article['teacher_task_id']);
$article['task_name'] = isset($task['task_name']) ? $task['task_name'] : '';
// 评分设置项
$itemServ = new CourseItemService();
$article['score_item'] = $itemServ->list_by_conds(
['article_id' => $article['article_id']],
null,
['score_order' => 'asc', 'created' => 'desc']
);
$this->_result = $article;
}
}