package p2.application.sysvars;

import baseclass.PaoCust;
import p2.pao.PaoSet;
import p2.util.P2Exception;
import com.cnd3b.utility.qywechat.base.Parameter;

public class sysvars extends PaoCust {

    public sysvars(PaoSet arg0) {
        super(arg0);
    }

    @Override
    public void init() throws P2Exception {
        super.init();
        if (!toBeAdded()) {
            if (!getBoolean("fisusewechat")) {
                setFieldFlag("fissendwechat", READONLY, true);
            }
        }

    }

    @Override
    protected void save() throws P2Exception {
        super.save();
        if (isModified("fwechat_token")) {
            Parameter.token = getString("fwechat_token");
        }
        if (isModified("fwechat_encodingaeskey")) {
            Parameter.EncodingAESKey = getString("fwechat_encodingaeskey");
        }
        if (isModified("fwechat_corpid")) {
            Parameter.CorpID = getString("fwechat_corpid");
        }
        if (isModified("fwechat_corpsecret")) {
            Parameter.corpsecret = getString("fwechat_corpsecret");
        }
        if (isModified("fwechat_drpappid")) {
            Parameter.appid_DRP = getString("fwechat_drpappid");
        }
    }

    @Override
    public void fieldAction(Object paoField, String fieldname)
            throws P2Exception {
        super.fieldAction(paoField, fieldname);
        if ("FISUSEWECHAT".equals(fieldname)) {
            if (!getBoolean("fisusewechat")) {
                setValue("fissendwechat", false);
            }
        }

    }
}
