DetailController.class.php
1.69 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
<?php
/**
* 【业绩比拼-手机端】获取回帖详情
*
* @author: daijun
* @date: 2017-11-02
*/
namespace Api\Controller\Comment;
use Common\Service\ActivityService;
use Common\Service\CommentService;
class DetailController extends \Api\Controller\AbstractController
{
public function Index_get()
{
if (empty($this->uid)) {
// 判断是否外部人员
E('_EMPTY_USER_ID');
}
// 获取参数
$ac_id = I('get.ac_id', 0, 'intval');
$comment_id = I('get.comment_id', 0, 'intval');
if (empty($ac_id)) {
// 验证活动ID参数
E('_EMPTY_ACTIVITY_ID');
}
if (empty($comment_id)) {
// 验证回帖ID参数
E('_EMPTY_COMMENT_ID');
}
$activity_serv = new ActivityService();
// 获取活动详细内容
$activity = $activity_serv->get_by_conds(
[
'activity_status >?' => ActivityService::ACTIVITY_DRAFT,
'ac_id' => $ac_id,
'is_hide' => ActivityService::CLOSE_ACTIVITY_HIDE
]
);
if (empty($activity)) {
// 数据不存在时抛错
E('_ERR_DATA_NOT_EXIST');
}
$comment = new CommentService();
// 获取回帖详细内容(已审核通过的)
$info = $comment->get_by_conds(['comment_id' => $comment_id, 'check_status' => CommentService::CHECK_OK]);
if (empty($info)) {
// 数据不存在时抛错
E('_ERR_COMMENT_NOT_EXIST');
}
// 格式化详情数据
$this->_result = $comment->format_detail_data($info, $this->uid);
return true;
}
}