Comment.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\supplier\controller\product;
  3. use app\supplier\controller\Controller;
  4. use app\supplier\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(array_merge(['shop_supplier_id' => $this->getSupplierId()], $this->postData()));
  18. //重要数据
  19. $num = $model->getStatusNum(['shop_supplier_id' => $this->getSupplierId(), 'status' => 0]);
  20. return $this->renderSuccess('', compact('list','num'));
  21. }
  22. /**
  23. * 评价详情
  24. */
  25. public function detail($comment_id)
  26. {
  27. // 评价详情
  28. $model = new CommentModel();
  29. $data = $model->detail($comment_id);
  30. return $this->renderSuccess('', compact('data'));
  31. }
  32. /**
  33. * 更新商品评论
  34. */
  35. public function edit()
  36. {
  37. $model = new CommentModel();
  38. // 更新记录
  39. if ($model->edit($this->postData())) {
  40. return $this->renderSuccess('修改成功');
  41. }
  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. }