StoreProductReply.php 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. $page = (int)$page;
  21. $pageSize = (int)$pageSize;
  22. $query = $this->alias('r')
  23. ->field('r.*,u.nickname,u.avatar')
  24. ->leftJoin('user u', 'u.uid = r.uid')
  25. ->where($where);
  26. $totalCount = $query->count();
  27. $list = $query
  28. ->order('r.id', 'desc')
  29. ->page($page, $pageSize)
  30. ->select()
  31. ->toArray();
  32. return [
  33. 'list' => $list,
  34. 'totalCount' => $totalCount,
  35. 'pageSize' => $pageSize,
  36. 'page' => $page
  37. ];
  38. }
  39. }