DictDataLists.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\setting\dict;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\model\dict\DictData;
  18. /**
  19. * 字典数据列表
  20. * Class DictDataLists
  21. * @package app\adminapi\lists\dict
  22. */
  23. class DictDataLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author 段誉
  29. * @date 2022/6/20 16:29
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '%like%' => ['name', 'type_value'],
  35. '=' => ['status', 'type_id']
  36. ];
  37. }
  38. /**
  39. * @notes 获取列表
  40. * @return array
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\DbException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @author 段誉
  45. * @date 2022/6/20 16:35
  46. */
  47. public function lists(): array
  48. {
  49. return DictData::where($this->searchWhere)
  50. ->append(['status_desc'])
  51. ->limit($this->limitOffset, $this->limitLength)
  52. ->order(['sort' => 'desc', 'id' => 'desc'])
  53. ->select()
  54. ->toArray();
  55. }
  56. /**
  57. * @notes 获取数量
  58. * @return int
  59. * @author 段誉
  60. * @date 2022/6/20 16:35
  61. */
  62. public function count(): int
  63. {
  64. return DictData::where($this->searchWhere)->count();
  65. }
  66. }