HomeServiceLists.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\home_service;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\home_service\HomeService;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * HomeService列表
  20. * Class HomeServiceLists
  21. * @package app\adminapi\listshome_service
  22. */
  23. class HomeServiceLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2024/07/07 16:44
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['name'],
  35. ];
  36. }
  37. public function queryWhere(){
  38. $where = [];
  39. // 用户余额
  40. if (isset($this->params['goods_id']) && is_array($this->params['goods_id'])) {
  41. $where[] = ['goods_id', 'in',$this->params['goods_id']];
  42. }
  43. return $where;
  44. }
  45. /**
  46. * @notes 获取列表
  47. * @return array
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\DbException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @author likeadmin
  52. * @date 2024/07/07 16:44
  53. */
  54. public function lists(): array
  55. {
  56. return HomeService::with('goods')
  57. ->where($this->searchWhere)
  58. ->where($this->queryWhere())
  59. ->field(['id', 'name', 'goods_id', 'picture', 'sort'])
  60. ->limit($this->limitOffset, $this->limitLength)
  61. ->order(['sort' => 'desc','id' => 'desc'])
  62. ->select()
  63. ->toArray();
  64. }
  65. /**
  66. * @notes 获取数量
  67. * @return int
  68. * @author likeadmin
  69. * @date 2024/07/07 16:44
  70. */
  71. public function count(): int
  72. {
  73. return HomeService::where($this->searchWhere)->where($this->queryWhere())->count();
  74. }
  75. }