public without sharing class ESignFormHandler extends Oly_TriggerHandler {
	private Map<Id, eSignForm__c> newMap;
	    private Map<Id, eSignForm__c> oldMap;
	    private List<eSignForm__c> newList;
	    private List<eSignForm__c> oldList;

    public ESignFormHandler() {

        this.newMap = (Map<Id, eSignForm__c>) Trigger.newMap;
        this.oldMap = (Map<Id, eSignForm__c>) Trigger.oldMap;
        this.newList = (List<eSignForm__c>) Trigger.new;
        this.oldList = (List<eSignForm__c>) Trigger.old;
    }

    protected override void beforeInsert() {
        beforeExecute();
    }

    protected override void beforeUpdate() {
        beforeExecute();
    }
    protected override void afterInsert() {
        afterExecute();
    }

     protected override void afterUpdate() {
        afterExecute();
    }

    private void beforeExecute() {
        Map<Id,eSignForm__c> accMap = new Map<Id,eSignForm__c>();
        for(eSignForm__c nObj : newList) {
            //DN号不为空
            if(String.isNotBlank(nObj.DNNameNo0__c)){
            	Blob bodyBlob=Blob.valueOf(nObj.DNNameNo0__c);
                nObj.DNName0_base64__c =String.valueOf(EncodingUtil.base64Encode(bodyBlob));
            }
            //经销商管理编码不为空
            if(String.isNotBlank(nObj.AgencyNum__c)){
                Blob bodyBlob=Blob.valueOf(nObj.AgencyNum__c);
                nObj.AgencyNum_base64__c = String.valueOf(EncodingUtil.base64Encode(bodyBlob));
            }
        }
    }

    private void afterExecute() {
        List<eSignFormEntry__c>  eSignFormEntryList = new List<eSignFormEntry__c>();

        for (eSignForm__c eSignForm : newList) {

                if(eSignForm.finalUpadteFrom__c != null){
                    eSignFormEntry__c es = new eSignFormEntry__c();
                    es.id = eSignForm.finalUpadteFrom__c;
                    es.IsHandled__c = true;
                    eSignFormEntryList.add(es);
                }

            
            }
        if(eSignFormEntryList.size() > 0){
            update eSignFormEntryList;
        }        
    }
}