CommentController.class.php
1.13 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
<?php
namespace Apicp\Controller\News;
use Common\Common\Comment;
use Common\Service\ArticleService;
class CommentController extends \Apicp\Controller\AbstractController
{
/**
* DeleteComment
*
* @author tangxingguo
* @desc 删除新闻
* @param int data_id:true 数据标识
* @return null
*/
public function Index_post()
{
$data_id = I('post.data_id', 0, 'trim');
// 数据标识不能为空
if (empty($data_id)) {
E('_ERR_ARTICLE_DATA_ID_NOT_FOUND');
}
$articleServ = new ArticleService();
$article = $articleServ->get_by_conds(['data_id' => $data_id]);
if (empty($article)) {
E('_ERR_ARTICLE_NOT_FOUND');
}
// UC获取当前评论总数
$commentServ = &Comment::instance();
$commentList = $commentServ->listAll(['cmtObjid' => $data_id]);
// 修改课程主表数据
if (isset($commentList['cmttlNums'])) {
$total = $commentList['cmttlNums'];
$articleServ->update_by_conds(['data_id' => $data_id], ['comment_total' => $total]);
}
}
}