<?php
|
|
namespace app\branch\controller\activity;
|
|
use app\branch\controller\Controller;
|
use app\branch\model\activity\Comment as CommentModel;
|
|
/**
|
* 活动评论控制器
|
*/
|
class Comment extends Controller
|
{
|
/**
|
* 评论列表
|
*/
|
public function index()
|
{
|
$model = new CommentModel;
|
$postData = $this->postData();
|
|
$where[] = ['is_delete', '=', 0];
|
|
// 列表
|
$list = $model->getList($postData, $this->getBranchId());
|
// 待审核数量
|
$num = $model->getStatusNum($where, $this->getBranchId());
|
return $this->renderSuccess('', compact('list', 'num'));
|
}
|
|
/**
|
* 评论详情
|
*/
|
public function detail($comment_id)
|
{
|
$data = CommentModel::detail($comment_id, ['user', 'activity', 'images.file']);
|
return $this->renderSuccess('', compact('data'));
|
}
|
|
/**
|
* 更新评论
|
*/
|
public function edit($comment_id)
|
{
|
$model = CommentModel::detail($comment_id);
|
if ($model->editComment($this->postData())) {
|
return $this->renderSuccess('修改成功');
|
}
|
return $this->renderError('修改失败');
|
}
|
|
/**
|
* 删除评论
|
*/
|
public function delete($comment_id)
|
{
|
$model = new CommentModel();
|
if (!$model->setDelete($comment_id)) {
|
return $this->renderError('删除失败');
|
}
|
return $this->renderSuccess('删除成功');
|
}
|
}
|