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\api\lists;
  15. use app\common\model\goods\Goods;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\model\goods_category\GoodsCategory;
  18. use app\common\model\home_service\HomeService;
  19. use app\common\service\FileService;
  20. /**
  21. * Goods列表
  22. * Class GoodsLists
  23. * @package app\adminapi\listsgoods
  24. */
  25. class HomeServiceLists extends BaseApiDataLists implements ListsSearchInterface
  26. {
  27. /**
  28. * @notes 设置搜索条件
  29. * @return \string[][]
  30. * @author likeadmin
  31. * @date 2024/07/07 16:44
  32. */
  33. public function setSearch(): array
  34. {
  35. return [
  36. '=' => ['name',],
  37. ];
  38. }
  39. public function queryWhere(){
  40. $where = [];
  41. // 用户余额
  42. if (isset($this->params['goods_id']) && is_array($this->params['goods_id'])) {
  43. $where[] = ['goods_id', 'in',$this->params['goods_id']];
  44. }
  45. return $where;
  46. }
  47. /**
  48. * @notes 获取列表
  49. * @return array
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\DbException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @author likeadmin
  54. * @date 2024/07/07 16:44
  55. */
  56. public function lists(): array
  57. {
  58. return HomeService::where($this->searchWhere)
  59. ->where($this->queryWhere())
  60. ->field(['id', 'name', 'goods_id', 'picture', 'sort'])
  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)->count();
  74. }
  75. }