Commit 4354f368 authored by 刘文胜's avatar 刘文胜

111111111111

parent c7de1137
......@@ -5,6 +5,8 @@ import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Node;
import com.alibaba.fastjson.JSONObject;
import com.hdp.pi.wechat.dto.WechatMessageDTO;
import com.hdp.pi.wechat.handler.*;
import java.util.concurrent.ConcurrentHashMap;
......@@ -24,12 +26,12 @@ public class Subscriber {
handlers.put("location", new LocationHandler());
}
public boolean receiveMessage(String message) {
String type="";
boolean result=Boolean.TRUE;
try {
type = getMsgType(message);
WechatMessageDTO wm = JSONObject.parseObject(message,WechatMessageDTO.class);
String type = getMsgType(wm.content);
MessageHandler handler=handlers.get(type);
result = null!=handler && handler.onMessage(type,message);
result = null!=handler && handler.onMessage(type,wm.entCode,wm.appId,wm.content);
} catch (Exception e) {
e.printStackTrace();
}
......
/**
* @Title: WechatMessageDTO.java
* @Package com.hdp.pi.wechat
* @Description: TODO
* @author new12304508_163_com
* @date 2015年6月17日 下午4:45:22
* @version V1.0
*/
package com.hdp.pi.wechat.dto;
import com.alibaba.fastjson.annotation.JSONField;
public class WechatMessageDTO {
/**
* @Title: WechatMessageDTO.java
* @Package com.hdp.pi.wechat
* @Description: TODO
* @author new12304508_163_com
* @date 2015年6月17日 下午4:45:22
* @version V1.0
*/
@JSONField(name="ent_code")
public Integer entCode;
public String appId;
public String content;
}
......@@ -46,7 +46,7 @@ public abstract class MessageHandler {
*通用的消息处理
* @throws Exception
**/
public boolean onMessage(String msgType,String message) throws Exception{
public boolean onMessage(String msgType,Integer entCode,String appId,String message) throws Exception{
if("".equals(message)){
return false;
}
......
......@@ -7,7 +7,11 @@ import java.util.Date;
* Created by Veal on 2015/5/13.
*/
public abstract class BaseEntity implements Serializable{
public Integer entCode;
public String appId;
public String msgType;
public String openId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment