This commit is contained in:
70
app/Context/QueueContext.php
Normal file
70
app/Context/QueueContext.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/3
|
||||
* Time: 下午6:40
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Context;
|
||||
|
||||
use Hyperf\Context\Context;
|
||||
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/3
|
||||
* Time: 下午7:19
|
||||
* Description: 队列上下文
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
class QueueContext
|
||||
{
|
||||
private const string USER_KEY = 'queue.user';
|
||||
|
||||
private const string COMPANY_KEY = 'company';
|
||||
|
||||
public static function setUser(array $user): void
|
||||
{
|
||||
Context::set(self::USER_KEY, $user);
|
||||
}
|
||||
|
||||
public static function getUser(): ?array
|
||||
{
|
||||
return Context::get(self::USER_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前公司信息
|
||||
* @param array $companyInfo
|
||||
* @return void
|
||||
*/
|
||||
public static function setCompanyInfo(array $companyInfo): void
|
||||
{
|
||||
Context::set(self::COMPANY_KEY, $companyInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前公司信息
|
||||
* @return array|null
|
||||
*/
|
||||
public static function getCompanyInfo(): ?array
|
||||
{
|
||||
return Context::get(self::COMPANY_KEY);
|
||||
}
|
||||
|
||||
public static function clear(): void
|
||||
{
|
||||
Context::destroy(self::USER_KEY);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user