package cc.smtweb.system.bpm.web.sys.user.menuPlan;

import cc.smtweb.framework.core.annotation.SwCache;
import cc.smtweb.framework.core.cache.AbstractEntityCache;
import cc.smtweb.framework.core.cache.CacheManager;

import java.util.Set;

/**
 * Created by 1 at 2022-08-05 19:41:15
 * 实体【[菜单方案](SYS_MENU_PLAN)】的缓存类
 */
@SwCache(ident = "SYS_MENU_PLAN", title = "菜单方案")
public class MenuPlanCache extends AbstractEntityCache<MenuPlan> {
    //缓存key：按项目缓存
    public final static String mk_p = "p";
    public static MenuPlanCache getInstance() {
        return CacheManager.getIntance().getCache(MenuPlanCache.class);
    }

    public MenuPlanCache() {
        //缓存key：按项目缓存
        regList(mk_p, "smp_prj_id");
    }

    //缓存key：按项目缓存
    public final Set<MenuPlan> getByP(String key) {
        return getListByKey(mk_p, key);
    }

    public final MenuPlanItem getById(long mp_id, long key) {
        MenuPlan menuPlan = get(mp_id);
        if (menuPlan == null) return null;
        return new MenuPlanContent(menuPlan.getContent()).findById(key);
    }
}
