package com.palmnest.application.bean;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * 微信公众平台——接收消息实体
 *
 * @author yb
 * @date 2014-04-10
 */
public class InMessage {
	private String              ToUserName;
	private String              FromUserName;
	private Long                CreateTime;
	private String              MsgType = "text";
	private Long                MsgId;
	// 文本消息
	private String              Content;
	// 图片消息
	private String              PicUrl;
	// 发送位置消息
	private String              Location_X;
	private String              Location_Y;
	private int                 Scale;
	private String              Label;
	//上报地理位置
	private Double              Latitude;
	private Double              Longitude;
	private Double              Precision;
	// 链接消息
	private String              Title;
	private String              Description;
	private String              Url;
	// 语音信息
	private String              MediaId;
	private String              Format;
	private String              Recognition;
	//视频信息
	private String              ThumbMediaId;
	// 事件
	private String              Event;
	private String              EventKey;
	private String              Ticket;
	//业务判断-系统
	private boolean             bindFlag;
	private Map<String, String> preBusinessMap;

	public String getToUserName() {
		return ToUserName;
	}

	public void setToUserName(String toUserName) {
		ToUserName = toUserName;
	}

	public String getFromUserName() {
		return FromUserName;
	}

	public void setFromUserName(String fromUserName) {
		FromUserName = fromUserName;
	}

	public Long getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Long createTime) {
		CreateTime = createTime;
	}

	public String getMsgType() {
		return MsgType;
	}

	public void setMsgType(String msgType) {
		MsgType = msgType;
	}

	public Long getMsgId() {
		return MsgId;
	}

	public void setMsgId(Long msgId) {
		MsgId = msgId;
	}

	public String getContent() {
		return Content;
	}

	public void setContent(String content) {
		Content = content;
	}

	public String getPicUrl() {
		return PicUrl;
	}

	public void setPicUrl(String picUrl) {
		PicUrl = picUrl;
	}

	public String getLocation_X() {
		return Location_X;
	}

	public void setLocation_X(String location_X) {
		Location_X = location_X;
	}

	public String getLocation_Y() {
		return Location_Y;
	}

	public void setLocation_Y(String location_Y) {
		Location_Y = location_Y;
	}

	public int getScale() {
		return Scale;
	}

	public void setScale(int scale) {
		Scale = scale;
	}

	public String getLabel() {
		return Label;
	}

	public void setLabel(String label) {
		Label = label;
	}

	public String getThumbMediaId() {
		return ThumbMediaId;
	}

	public void setThumbMediaId(String thumbMediaId) {
		ThumbMediaId = thumbMediaId;
	}

	public String getTitle() {
		return Title;
	}

	public void setTitle(String title) {
		Title = title;
	}

	public String getDescription() {
		return Description;
	}

	public void setDescription(String description) {
		Description = description;
	}

	public String getUrl() {
		return Url;
	}

	public void setUrl(String url) {
		Url = url;
	}

	public String getEvent() {
		return Event;
	}

	public void setEvent(String event) {
		Event = event;
	}

	public String getEventKey() {
		return EventKey;
	}

	public void setEventKey(String eventKey) {
		EventKey = eventKey;
	}

	public String getMediaId() {
		return MediaId;
	}

	public void setMediaId(String mediaId) {
		MediaId = mediaId;
	}

	public String getFormat() {
		return Format;
	}

	public void setFormat(String format) {
		Format = format;
	}

	public String getRecognition() {
		return Recognition;
	}

	public void setRecognition(String recognition) {
		Recognition = recognition;
	}

	public String getTicket() {
		return Ticket;
	}

	public void setTicket(String ticket) {
		Ticket = ticket;
	}

	public Double getLatitude() {
		return Latitude;
	}

	public void setLatitude(Double latitude) {
		Latitude = latitude;
	}

	public Double getLongitude() {
		return Longitude;
	}

	public void setLongitude(Double longitude) {
		Longitude = longitude;
	}

	public Double getPrecision() {
		return Precision;
	}

	public void setPrecision(Double precision) {
		Precision = precision;
	}

	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		Field[] fields = InMessage.class.getDeclaredFields();
		for (Field field : fields) {
			Object obj;
			try {
				obj = field.get(this);
				if (obj != null) {
					map.put(field.getName(), obj);
				}
				map.remove("ToUserName");
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return map;
	}

	public Boolean isEvent() {
		return this.MsgType.equals(MsgTypes.EVENT.getType());
	}

	public Boolean isText() {
		return this.MsgType.equals(MsgTypes.TEXT.getType());
	}

	public Boolean isImage() {
		return this.MsgType.equals(MsgTypes.IMAGE.getType());
	}

	public Boolean isVoice() {
		return this.MsgType.equals(MsgTypes.VOICE.getType());
	}

	public Boolean isVideo() {
		return this.MsgType.equals(MsgTypes.VIDEO.getType());
	}

	public Boolean isLocation() {
		return this.MsgType.equals(MsgTypes.LOCATION.getType());
	}

	public Boolean isLink() {
		return this.MsgType.equals(MsgTypes.LINK.getType());
	}

	public boolean isBindFlag() {
		return bindFlag;
	}

	public void setBindFlag(boolean bindFlag) {
		this.bindFlag = bindFlag;
	}

	public Map<String, String> getPreBusinessMap() {
		return preBusinessMap;
	}

	public void setPreBusinessMap(Map<String, String> preBusinessMap) {
		this.preBusinessMap = preBusinessMap;
	}

}
