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

import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.util.NumberUtil;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler;

/**
 * Created by Akmm at 2022/7/1 15:47
 * 区划保存
 */
public class DictHandler {

    static class DictSaveHandler extends DynPageSaveHandler {

        @Override
        protected void checkBean(DefaultEntity bean) {
            super.checkBean(bean);
            //字典 id用 类型id+编码
            if (bean instanceof Dict) {
                Dict dict = (Dict) bean;
                dict.setEntityId(NumberUtil.getLongIgnoreErr(dict.getType() + dict.getCode()));
                return;
            }
            //字典类型 id用编码
            if (bean instanceof DictType) {
                DictType dictType = (DictType) bean;
                dictType.setEntityId(NumberUtil.getLongIgnoreErr(dictType.getCode()));
                return;
            }
        }
    }
}
