feat : menu list
This commit is contained in:
@@ -24,6 +24,17 @@ class MenuCache
|
||||
#[Inject]
|
||||
protected AdminMenu $adminMenuModel;
|
||||
|
||||
/**
|
||||
* 菜单
|
||||
* @var string
|
||||
*/
|
||||
protected string $menuKey;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuKey = AdminRedisKey::adminMenuList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
@@ -32,21 +43,30 @@ class MenuCache
|
||||
*/
|
||||
public function getMenu(): array
|
||||
{
|
||||
$key = AdminRedisKey::adminMenuList();
|
||||
|
||||
if ($this->redis->exists($key,'system')) {
|
||||
return json_decode($this->redis->get($key,'system'),true);
|
||||
if ($this->redis->exists($this->menuKey,'system')) {
|
||||
return json_decode($this->redis->get($this->menuKey,'system'),true);
|
||||
}
|
||||
|
||||
$allMenuList = $this->adminMenuModel->getAllMenu();
|
||||
|
||||
$data = $this->getDbMenu($allMenuList);
|
||||
|
||||
$this->redis->set($key,json_encode($data));
|
||||
$this->redis->set($this->menuKey,json_encode($data));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws RedisException
|
||||
*/
|
||||
public function delMenu(): void
|
||||
{
|
||||
$this->redis->delete($this->menuKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归生成合适的数据
|
||||
* @param array $allMenuList
|
||||
|
||||
Reference in New Issue
Block a user