package cc.smtweb.system.bpm.web.sys.base.dict;

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

/**
 * Created by 1 at 2022-07-27 19:59:05
 * 实体【[数据字典](SYS_DICT)】的缓存类
 */
@SwCache(ident = "SYS_DICT", title = "数据字典")
public class DictCache extends AbstractEntityCache<Dict> {
    //缓存key：按编码
    public final static String mk_code = "code";

    public static DictCache getInstance() {
        return CacheManager.getIntance().getCache(DictCache.class);
    }

    public DictCache() {
        //缓存key：按编码
        regMap(mk_code, "sdc_type,sdc_code");
    }

    //缓存key：按编码
    public final Dict getByCode(String key) {
        return getByKey(mk_code, key);
    }

    public final String getName(long id) {
        Dict bean = get(id);
        return bean != null ? bean.getName(): String.valueOf(id);
    }
}
