php管理和接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.1 KiB

<?php
namespace app\admin\model;
use app\common\model\TimeModel;
class User extends TimeModel
{
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = '0';
public $genderArr = [
1 => '男', 2 => '女', 3 => '未知'
];
public static function getPageList($param = [])
{
$page = $param['page'] ?? 1;
$limit = $param['limit'] ?? 10;
$where = [['status', '=', 1]];
if (isset($param['keyword'])) {
$where[] = ['nick_name', 'like', '%'.$param['keyword'].'%'];
}
$field = 'uid, nick_name';
$order = 'uid desc';
$count = self::where($where)->count();
$list = self::where($where)->field($field)->order($order)->page($page, $limit)->select();
return ['data' => $list, 'count' => $count];
}
/**
* 返回用户字段信息
* @param $uid
* @param string $field
* @return mixed|string
*/
public static function getUserValue($uid, string $field = 'nick_name') {
return (new self)->where('uid', $uid)->value($field) ?? '-';
}
}