ReplayListController.class.php
1.55 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
<?php
/**
*【活动中心-手机端】回复评论列表
* @author: 蔡建华
* @date : 2017-05-9
* @version $Id$
*/
namespace Api\Controller\Comment;
use Common\Service\CommentService;
class ReplayListController extends AbstractController
{
/**
* @var bool 不强制登录
*/
protected $_require_login = false;
/**
* @var CommentService 评论service
*/
protected $_comment_serv;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
$this->_comment_serv = new CommentService();
return true;
}
public function Index_get()
{
$params = I('get.');
$limit = empty($params['limit']) ? self::DEFAULT_LIMIT : intval($params['limit']);
$page = empty($params['page']) ? 1 : intval($params['page']);
$comment_id = intval($params['comment_id']);
// 参数验证
if (empty($comment_id)) {
E('_EMPTY_COMMENT_ID');
}
// 每页条数
list($start, $limit) = page_limit($page, $limit);
// 分页参数
$page_option = array(
$start,
$limit,
);
//查询评论信息数据
if (!$data = $this->_result = $this->_comment_serv->replay_list($params, $page_option, $this->uid)) {
E('_ERR_DATA_NOT_EXIST');
}
$data['page'] = $page;
$data['limit'] = $limit;
$data['comment_id'] = $comment_id;
$this->_result = $data;
return true;
}
}