package cn.hmsoft.weixin.processor.event;

import cn.hmsoft.application.SpringHelper;
import cn.hmsoft.jdbc.core.DatabaseDao;
import cn.hmsoft.log.LogHelper;
import cn.hmsoft.weixin.data.model.WxDefine;
import cn.hmsoft.weixin.data.model.WxUser;
import cn.hmsoft.weixin.data.model.WxUserLog;
import cn.hmsoft.weixin.entity.message.BasicMessage;
import cn.hmsoft.weixin.entity.message.EventMessage;
import cn.hmsoft.weixin.entity.reply.WeiXinReply;

public abstract class EvenBasicProcessor implements Runnable {
	protected BasicMessage msg;
	protected EventMessage jsonEntity;
	protected WxUser user;
	protected DatabaseDao daoWeiXin;
	protected WxUserLog log;
	protected WxDefine wxDefine;

	@Override
	public void run() {
		try {
			this.handleEvent();
		} catch (Exception e) {
			LogHelper.error(e);
		}
	}

	final public void setEntity(WxDefine wxDefine,BasicMessage msg, EventMessage jsonEntity, WxUser user, WxUserLog log) {

		this.msg = msg;
		this.jsonEntity = jsonEntity;
		this.user = user;
		this.log = log;
		this.daoWeiXin = SpringHelper.AppGobalDao;
		this.wxDefine = wxDefine;
	}

	public abstract WeiXinReply handleEvent() throws Exception;
}
