Files
wh-api/app/Context/QueueContext.php
ykxiao 0b2299c427
Some checks failed
Build Docker / build (push) Has been cancelled
协程版仓库后端项目
2025-07-08 14:59:47 +08:00

70 lines
1.4 KiB
PHP

<?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);
}
}