39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?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;
|
||
}
|
||
|
||
|
||
|
||
}
|