DeleteController.class.php
931 Bytes
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
<?php
/**
* 【手机端】15-删除评价接口
* Created by PhpStorm.
* @author:houyingcai
* @date:2017-09-25
*/
namespace Api\Controller\Comment;
use Common\Service\CommentService;
class DeleteController extends \Api\Controller\AbstractController
{
public function Index_get()
{
$c_id = I('c_id', 0, 'rintval');
// 评论ID不能为空
if (!$c_id) {
E('_EMPTY_COMMENT_ID');
}
// 实例化评论表
$comment_s = new CommentService();
// 获取评论信息
$comment = $comment_s->get($c_id);
// 评论不存在
if (empty($comment)) {
E('_EMPTY_COMMENT');
}
// 不能删除别人的评论
if ($comment['c_uid'] != $this->uid) {
E('_ERR_COMMENT_NOT_SELF');
}
// 删除评论
$comment_s->delete_comment($c_id);
return true;
}
}