<?php

namespace app\observer;


use app\model\SysDictionary;
use app\model\SysDictionaryData;

class DictionaryObserver
{
    /**
     * 更新/创建数据事件l
     * @param SysDictionary|SysDictionaryData $model
     * @return void
     */
    public function onAfterWrite(SysDictionary|SysDictionaryData $model)
    {
        $this->clearCache();
    }

    /**
     * 删除数据事件
     * @param SysDictionary|SysDictionaryData $model
     * @return void
     */
    public function onAfterDelete(SysDictionary|SysDictionaryData $model)
    {
        $this->clearCache();
    }

    /**
     * 恢复数据事件
     * @param SysDictionary|SysDictionaryData $model
     * @return void
     */
    public function onAfterRestore(SysDictionary|SysDictionaryData $model)
    {
        $this->clearCache();
    }

    public function clearCache()
    {
        dict()->clearCache();
    }
}