48 lines
850 B
PHP
48 lines
850 B
PHP
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\util;
|
|
|
|
use think\facade\Request;
|
|
|
|
/**
|
|
* @author canny
|
|
* @date 2023/12/19 11:18
|
|
**/
|
|
class FrontSessionUtil
|
|
{
|
|
const TOKEN_KEY = "token";
|
|
private static int $siteId = 1;
|
|
private static object $user;
|
|
|
|
public static function setUser($user)
|
|
{
|
|
self::$user = $user;
|
|
}
|
|
|
|
public static function getSiteId(): int
|
|
{
|
|
return self::$siteId;
|
|
}
|
|
|
|
public static function getUser(): object
|
|
{
|
|
return self::$user;
|
|
}
|
|
|
|
public static function getUserId(): int
|
|
{
|
|
return (int)self::$user->id;
|
|
}
|
|
|
|
|
|
public static function getToken()
|
|
{
|
|
return Request::cookie(self::TOKEN_KEY, Request::header(self::TOKEN_KEY));
|
|
}
|
|
|
|
public static function getPartnerId(): int
|
|
{
|
|
return (int)self::$user->partner_id;
|
|
}
|
|
} |