SupplyDemandLists.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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\agricultural_machinery;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\lists\ListsSortInterface;
  18. use app\common\model\agricultural_machinery\ServiceCategory as AgriculturalMachineryServiceCategory;
  19. use app\common\model\agricultural_machinery\UserService;
  20. use app\common\model\supply_demand\SupplyDemandInfo;
  21. /**
  22. * 供需列表
  23. * Class ArticleCateLists
  24. * @package app\adminapi\lists\article
  25. */
  26. class SupplyDemandLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
  27. {
  28. /**
  29. * @notes 设置搜索条件
  30. * @return array
  31. * @author heshihu
  32. * @date 2022/2/8 18:39
  33. */
  34. public function setSearch(): array
  35. {
  36. return [
  37. '%like%' => ['title','mobile'],
  38. '=' => ['type']
  39. ];
  40. }
  41. /**
  42. * @notes 自定查询条件
  43. * @return array
  44. * @author 段誉
  45. * @date 2022/10/25 16:53
  46. */
  47. public function queryWhere()
  48. {
  49. $where = [];
  50. if (isset($this->params['status']) && $this->params['status']) {
  51. $status = $this->params['status'];
  52. $where[] = ['status', '=',$status];
  53. }
  54. return $where;
  55. }
  56. /**
  57. * @notes 设置支持排序字段
  58. * @return array
  59. * @author heshihu
  60. * @date 2022/2/9 15:11
  61. */
  62. public function setSortFields(): array
  63. {
  64. return [ 'id' => 'id'];
  65. }
  66. /**
  67. * @notes 设置默认排序
  68. * @return array
  69. * @author heshihu
  70. * @date 2022/2/9 15:08
  71. */
  72. public function setDefaultOrder(): array
  73. {
  74. return ['id' => 'desc'];
  75. }
  76. /**
  77. * @notes 获取管理列表
  78. * @return array
  79. * @author heshihu
  80. * @date 2022/2/21 17:11
  81. */
  82. public function lists(): array
  83. {
  84. $supplyDemandLists = SupplyDemandInfo::where($this->searchWhere)
  85. ->where($this->queryWhere())
  86. ->limit($this->limitOffset, $this->limitLength)
  87. ->order($this->sortOrder)
  88. ->append(['status_desc','type_desc','user'])
  89. ->select()
  90. ->toArray();
  91. return $supplyDemandLists;
  92. }
  93. /**
  94. * @notes 获取数量
  95. * @return int
  96. * @author heshihu
  97. * @date 2022/2/9 15:12
  98. */
  99. public function count(): int
  100. {
  101. return SupplyDemandInfo::where($this->searchWhere)->where($this->queryWhere())->count();
  102. }
  103. public function extend()
  104. {
  105. return [];
  106. }
  107. }