Files
cycle_api/app/Cache/Struct/StructUserCommonCacheUid.php
2024-02-26 00:41:25 +08:00

39 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Cache\Struct;
use App\Cache\Base\StructBaseCache;
use App\Models\Customer\CustomerUserExtendModel;
//用户缓存用户基础信息结构自己组装不完全等于数据表primary_key为主键
class StructUserCommonCacheUid extends StructBaseCache
{
public string $primary_prefix = 'StructUserCommonCacheUid:'; //后面跟primary_key
//缓存元素
const USER_UID = 'uid';
const USER_IS_ACTIVE = 'user_is_active'; //是否活跃用户
//生成函数,自动调用生成函数
public array $aCacheKey = [
self::USER_UID => 'genUserUid',
self::USER_IS_ACTIVE => 'genUserIsActive',
];
function genUserUid(): string
{
return $this->primary_key;
}
function genUserIsActive(): string
{
$oCustomerUserExtendModel = new CustomerUserExtendModel();
$oCustomerUserExtend = $oCustomerUserExtendModel->findItem($this->primary_key);
if(!$oCustomerUserExtend) return '';
return $oCustomerUserExtend->is_active;
}
}