HomeSpecialLists.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\api\lists;
  3. use app\adminapi\lists\BaseAdminDataLists;
  4. use app\common\model\home_service\HomeSpecial;
  5. use app\common\lists\ListsSearchInterface;
  6. /**
  7. * HomeSpecial列表
  8. * Class HomeSpecialLists
  9. * @package app\api\listshome_service
  10. */
  11. class HomeSpecialLists extends BaseApiDataLists implements ListsSearchInterface
  12. {
  13. /**
  14. * @notes 设置搜索条件
  15. * @return \string[][]
  16. * @author likeadmin
  17. * @date 2024/11/18 10:05
  18. */
  19. public function setSearch(): array
  20. {
  21. return [
  22. '=' => ['special_type'],
  23. ];
  24. }
  25. /**
  26. * @notes 获取列表
  27. * @return array
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @author likeadmin
  32. * @date 2024/11/18 10:05
  33. */
  34. public function lists(): array
  35. {
  36. return HomeSpecial::where($this->searchWhere)
  37. ->where('status',1)
  38. ->field(['id', 'special_type', 'title', 'cover_type', 'cover', 'user_head', 'user_nickname', 'vue_web', 'vue_param', 'view_num', 'tags', 'status'])
  39. ->limit($this->limitOffset, $this->limitLength)
  40. ->order(['id' => 'desc'])
  41. ->select()
  42. ->toArray();
  43. }
  44. /**
  45. * @notes 获取数量
  46. * @return int
  47. * @author likeadmin
  48. * @date 2024/11/18 10:05
  49. */
  50. public function count(): int
  51. {
  52. return HomeSpecial::where($this->searchWhere)->count();
  53. }
  54. }