TenantAdminLists.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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\tenant;
  15. use app\common\model\auth\TenantAdmin;
  16. use app\tenantapi\lists\BaseAdminDataLists;
  17. use app\common\enum\user\UserTerminalEnum;
  18. use app\common\lists\ListsExcelInterface;
  19. use app\common\model\tenant\Tenant;
  20. /**
  21. * 用户列表
  22. * Class TenantLists
  23. * @package app\tenantapi\lists\user
  24. */
  25. class TenantAdminLists extends BaseAdminDataLists implements ListsExcelInterface
  26. {
  27. /**
  28. * @notes 搜索条件
  29. * @return array
  30. * @author 段誉
  31. * @date 2022/9/22 15:50
  32. */
  33. public function setSearch(): array
  34. {
  35. $allowSearch = ['keyword', 'create_time_start', 'create_time_end','tenant_id'];
  36. return array_intersect(array_keys($this->params), $allowSearch);
  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/9/22 15:50
  46. */
  47. public function lists(): array
  48. {
  49. //进行参数校验 租户标识必填
  50. if(!isset($this->params['tenant_id'])){
  51. return [];
  52. }
  53. $field = "id,root,name,avatar,account,multipoint_login,disable,create_time";
  54. $lists = TenantAdmin::withSearch($this->setSearch(), $this->params)
  55. ->limit($this->limitOffset, $this->limitLength)
  56. ->field($field)
  57. ->order('create_time desc')
  58. ->select()->toArray();
  59. return $lists;
  60. }
  61. /**
  62. * @notes 获取数量
  63. * @return int
  64. * @author 段誉
  65. * @date 2022/9/22 15:51
  66. */
  67. public function count(): int
  68. {
  69. return TenantAdmin::withSearch($this->setSearch(), $this->params)->count();
  70. }
  71. /**
  72. * @notes 导出文件名
  73. * @return string
  74. * @author 段誉
  75. * @date 2022/11/24 16:17
  76. */
  77. public function setFileName(): string
  78. {
  79. return '租户用户列表';
  80. }
  81. /**
  82. * @notes 导出字段
  83. * @return string[]
  84. * @author 段誉
  85. * @date 2022/11/24 16:17
  86. */
  87. public function setExcelFields(): array
  88. {
  89. return [
  90. 'root' => '是否超级管理员',
  91. 'name' => '租户账户昵称',
  92. 'avatar' => '头像',
  93. 'account' => '账号',
  94. 'multipoint_login' => '是否允许多处登录',
  95. 'disable' => '是否禁用',
  96. 'create_time' => '注册时间',
  97. ];
  98. }
  99. }