/**
* 普通消息
*/
@RequestMapping(value = "wechat",method = RequestMethod.POST)
@ResponseBody
public Object handleMessage(@RequestBody InMsgEntity ime){
OutMsgEntity outMsg=new OutMsgEntity();
//发送方
outMsg.setFromUserName(ime.getToUserName());
//接收方
outMsg.setToUserName(ime.getFromUserName());
//消息创建时间
outMsg.setCreateTime(new Date().getTime());
//判断一下回复的图片还是文本
String msType= ime.getMsgType();
if(msType.equals("text")){
//设置消息类型
outMsg.setMsgType("text");
// 关键字回复
String content= ime.getContent();
//回复的信息
String outcontent=null;
if(content.contains("开班")){
outcontent="ddd";
}else if(content.contains("地址")){
outcontent="cccc";
}else {
//设置消息内容
outcontent=ime.getContent();
}
outMsg.setContent(outcontent);
} else if(msType.equals("image")){
outMsg.setMsgType("image");
outMsg.setMediaId(new String[]{ime.getMediaId()});
}
return outMsg;
}
11-11
887