TopController.class.php 819 Bytes
<?php
/**
 * 【活动中心-管理端】评论置顶接口
 * User: yingcai
 * Date: 2017/11/28
 * Time: 下午4:41
 */

namespace Apicp\Controller\Comment;

use Common\Service\CommentService;

class TopController extends AbstractController
{
    public function Index_post()
    {
        $comment_id = I('post.comment_id', 0, 'intval');
        // 评论ID不能为空
        if (empty($comment_id)) {

            E('_ERR_COMMENT_ID_EMPTY');
        }

        $comment_service = new CommentService();

        $comment = $comment_service->get($comment_id);
        // 评论的回复不能被置顶
        if ($comment['parent_id']) {

            E('_ERR_REPLY_NOT_TOP');
        }

        // 置顶操作
        $comment_service->update($comment_id, ['top_time' => MILLI_TIME]);

        return true;
    }
}