tapi/app/http/HttpAuth.php
2025-08-22 10:11:22 +08:00

43 lines
689 B
PHP

<?php
namespace app\http;
use app\entity\SysUser;
use app\enum\UserTypeEnum;
use think\helper\Macroable;
/**
* @method SysUser getUser()
*/
class HttpAuth
{
use Macroable;
/**
* 用户ID
* >0 已登录用户
* =0 未登录
* <0 访客
* @var int
*/
public int $userId;
/**
* 用户类型
* @var UserTypeEnum
* USER 标准用户
* VISITOR 未登录访客
*/
public UserTypeEnum $userType;
public function __construct($userId, $userType)
{
$this->userId = $userId;
$this->userType = $userType;
}
public function isLogin(): bool
{
return $this->userId > 0;
}
}