Comment.php 747 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\api\controller;
  10. use app\api\model\Comment as CommentModel;
  11. /**
  12. * 商品评价控制器
  13. * Class Comment
  14. * @package app\api\controller
  15. */
  16. class Comment extends Controller
  17. {
  18. /**
  19. * 商品评价列表
  20. * @param $goods_id
  21. * @param int $scoreType
  22. * @return array
  23. * @throws \think\exception\DbException
  24. */
  25. public function lists($goods_id, $scoreType = -1)
  26. {
  27. $model = new CommentModel;
  28. $list = $model->getGoodsCommentList($goods_id, $scoreType);
  29. $total = $model->getTotal($goods_id);
  30. return $this->renderSuccess(compact('list', 'total'));
  31. }
  32. }