feat: 新增登录接口

This commit is contained in:
2024-12-31 18:05:36 +08:00
parent 741c2d6f85
commit b5e83a998c
8 changed files with 219 additions and 2 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use think\Model;
/**
* @mixin \think\Model
*/
class UserModel extends Model
{
// 表名
protected $name = 'sys_user';
// 主键
protected $pk = 'id';
// 隐藏字段
protected $hidden = ['password', 'salt'];
// 字段信息
protected $schema = [
'id' => 'int',
'username' => 'string',
'password' => 'string',
'salt' => 'string',
'role_id' => 'int',
'nickname' => 'string',
'avatar' => 'string',
'mobile' => 'string',
'email' => 'string',
'status' => 'int',
'created_at' => 'datetime',
'updated_at' => 'datetime',
] ;
// 用户名查询范围
public function scopeUsernameOrMobile($query, $username)
{
return $query->where('username', '=', $username)->whereOr('mobile', '=', $username);
}
}