data_center/app/adminapi/lists/user/UserLists.php

38 lines
1.2 KiB
PHP
Raw Normal View History

2023-09-18 09:11:13 +08:00
<?php
namespace app\adminapi\lists\user;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\user\User;
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
{
// 搜索条件
public function setSearch(): array
{
return [
'=' => ['user_status'],
'%like%' => ['user_account','user_nickname','user_phone'],
];
}
// 获取用户列表
public function lists(): array
{
$field = "id,user_avatar,user_account,user_nickname,user_phone,user_gender,user_status,create_time";
$lists = User::field($field)->where($this->searchWhere)->where('user_status','<>',2)
->limit($this->limitOffset, $this->limitLength)
->order('id desc')->select()->each(function($item){
$item['user_status_text'] = $item->user_status_text;
$item['user_gender_text'] = $item->user_gender_text;
})->toArray();
return $lists;
}
// 获取数量
public function count(): int
{
return User::field('id')->where($this->searchWhere)->where('user_status','<>',2)->count();
}
}