是否鉴权

This commit is contained in:
2025-12-01 10:41:41 +08:00
parent 7359cf2972
commit 9c28ca2744

View File

@@ -89,12 +89,18 @@ class BaseService
* @var string 时间字段
*/
protected string $timeField = 'created_at';
/**
* @var bool 是否鉴权
*/
private $auth = true;
public function __construct()
{
$this->userInfo = JWTService::getInstance()->getToken()->getUserInfo();
$this->userId = $this->userInfo['id'] ?? 0;
$this->roleId = $this->userInfo['role_id'] ?? 0;
if ($this->auth === true) {
$this->userInfo = JWTService::getInstance()->getToken()->getUserInfo();
$this->userId = $this->userInfo['id'] ?? 0;
$this->roleId = $this->userInfo['role_id'] ?? 0;
}
$this->utils = UtilsService::getInstance();
}