Comment.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\shop\controller\product;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\product\Comment as CommentModel;
  5. /**
  6. * 商品评价控制器
  7. */
  8. class Comment extends Controller
  9. {
  10. /**
  11. * 评价列表
  12. */
  13. public function index()
  14. {
  15. $model = new CommentModel;
  16. //列表
  17. $list = $model->getList($this->postData());
  18. //重要数据
  19. $num = $model->getStatusNum(['status' => 0]);
  20. return $this->renderSuccess('', compact('list','num'));
  21. }
  22. /**
  23. * 评价详情
  24. */
  25. public function detail($comment_id)
  26. {
  27. // 评价详情
  28. $data = CommentModel::detail($comment_id);
  29. return $this->renderSuccess('', compact('data'));
  30. }
  31. /**
  32. * 更新商品评论
  33. */
  34. public function edit($comment_id)
  35. {
  36. $model = CommentModel::detail($comment_id);
  37. // 更新记录
  38. if ($model->edit($this->postData())) {
  39. return $this->renderSuccess('修改成功');
  40. }
  41. return $this->renderError('修改失败');
  42. }
  43. /**
  44. * 删除评价
  45. */
  46. public function delete($comment_id)
  47. {
  48. $model = new CommentModel();
  49. if (!$model->setDelete($comment_id)) {
  50. return $this->renderError('删除失败');
  51. }
  52. return $this->renderSuccess('删除成功');
  53. }
  54. }