Files
hyperf_service/app/Model/AdminUser.php
2024-10-29 18:00:12 +08:00

77 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Admin\UserCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property string $username
* @property string $password
* @property string $salt
* @property int $avatar
* @property string $chinese_name
* @property string $mobile
* @property int $status
* @property string $last_login_ip
* @property string $last_login_time
* @property int $is_del
* @property int $role_id
* @property string $create_time
* @property string $update_time
*/
class AdminUser extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'admin_user';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
protected array $guarded = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'avatar' => 'integer', 'status' => 'integer', 'is_del' => 'integer', 'role_id' => 'integer'];
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
/**
* @param string $account
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getAdminInfoByAccount(string $account): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('username', $account)->where('is_del',UserCode::ENABLE)->first();
}
/**
* @param string $name
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getAdminInfoByName(string $name): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('chinese_name', $name)->where('is_del',UserCode::ENABLE)->first();
}
/**
* @param int $id
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getAdminInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id', $id)->where('is_del',UserCode::ENABLE)->first();
}
}