AddController.class.php
1.56 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
<?php
/**
* AddController.class.php
* 发布评论
* User: heyuelong
* Date:2017年4月26日18:07:37
*/
namespace Api\Controller\Comment;
use Common\Common\DataCenter;
use Common\Service\CircleService;
use Common\Common\TaskCenter;
class AddController extends \Api\Controller\AbstractController
{
/**
* 主方法
* @return boolean
*/
public function Index_post()
{
$params = I('post.');
// 实例化同事圈表
$service = new CircleService();
// 发布评论
$comment = $service->push_comment($params, $this->_login->user, $this->_setting['comment']);
// 抛出错误提示
if (!$comment) {
return false;
}
// 常规任务埋点:添加评论(如果没有开启审核直接触发埋点,开启审核则在审核通过后触发)
if (!$this->_setting['comment']) {
$params = [
'uid' => $this->uid,
'app_data_id' => $params['pid'],
'action_key' => 'workmate_send_comment',
'description' => '添加评论'
];
$taskCenter = &TaskCenter::instance();
$taskCenter->triggerDailytask($params);
// 数据中心:新增评论的埋点
$datacenter =& DataCenter::instance();
$datacenter->addComment($this->_login->user, $comment['id']);
}
$this->_result = [
'pid' => intval($params['pid']),
'id' => intval($comment['id']),
'data' => $comment['data']
];
}
}