StoreProductReply.php 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\api;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class StoreProductReply extends Model
  9. {
  10. protected $name = 'store_product_reply';
  11. /**
  12. * 获取评论列表
  13. * @param array $where
  14. * @param int $page
  15. * @param int $pageSize
  16. * @return array
  17. */
  18. public function getList($where = [], $page = 1, $pageSize = 20)
  19. {
  20. $query = $this->alias('r')
  21. ->field('r.*,u.nickname,u.avatar')
  22. ->leftJoin('user u', 'u.uid = r.uid')
  23. ->where($where);
  24. $totalCount = $query->count();
  25. $list = $query
  26. ->order('r.id', 'desc')
  27. ->page($page, $pageSize)
  28. ->select()
  29. ->toArray();
  30. return [
  31. 'list' => $list,
  32. 'totalCount' => $totalCount,
  33. 'pageSize' => $pageSize,
  34. 'page' => $page
  35. ];
  36. }
  37. }