|
|
|
@ -1,7 +1,10 @@ |
|
|
|
|
package com.ynxbd.wx.wxfactory.utils; |
|
|
|
|
|
|
|
|
|
import com.ynxbd.common.helper.common.ErrorHelper; |
|
|
|
|
import com.ynxbd.wx.config.HospConfigEnum; |
|
|
|
|
import com.ynxbd.wx.config.WeChatConfig; |
|
|
|
|
import com.ynxbd.wx.config.WxEventEnum; |
|
|
|
|
import com.ynxbd.wx.wxfactory.bean.event.WxEvent; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
|
import weixin.popular.bean.xmlmessage.XMLImageMessage; |
|
|
|
@ -21,25 +24,10 @@ import java.util.List; |
|
|
|
|
*/ |
|
|
|
|
@Slf4j |
|
|
|
|
public class WxPassiveReplyHelper { |
|
|
|
|
public static final String MSG_TYPE_TEXT = "text"; |
|
|
|
|
public static final String MSG_TYPE_IMAGE = "image"; |
|
|
|
|
public static final String MSG_TYPE_VOICE = "voice"; |
|
|
|
|
public static final String MSG_TYPE_VIDEO = "video"; |
|
|
|
|
public static final String MSG_TYPE_LINK = "link"; |
|
|
|
|
public static final String MSG_TYPE_LOCATION = "location"; |
|
|
|
|
public static final String MSG_TYPE_EVENT = "event"; |
|
|
|
|
|
|
|
|
|
// 订阅
|
|
|
|
|
public static final String EVENT_SUBSCRIBE = "subscribe"; |
|
|
|
|
// 取消订阅
|
|
|
|
|
public static final String EVENT_UNSUB = "unsubscribe"; |
|
|
|
|
public static final String EVENT_CLICK = "CLICK"; |
|
|
|
|
public static final String EVENT_VIEW = "VIEW"; |
|
|
|
|
|
|
|
|
|
// 重复通知过滤
|
|
|
|
|
private static ExpireKey EXPIRE_KEY; |
|
|
|
|
|
|
|
|
|
final public static String SUCCESS = "success"; |
|
|
|
|
public static final String SUCCESS = "success"; |
|
|
|
|
|
|
|
|
|
private synchronized static void getExpireKey() { |
|
|
|
|
if (EXPIRE_KEY == null) { |
|
|
|
@ -62,10 +50,73 @@ public class WxPassiveReplyHelper { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 文字匹配 |
|
|
|
|
* 关注 |
|
|
|
|
* |
|
|
|
|
* @param response |
|
|
|
|
* @param content |
|
|
|
|
* @param msgType |
|
|
|
|
* @param fromUserName |
|
|
|
|
* @param toUserName |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static boolean subscribeCommon(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String event) { |
|
|
|
|
log.info("event={}", event); |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
String webUrl = WeChatConfig.getWebUrl(); |
|
|
|
|
return createLinkMsg(response, fromUserName, toUserName, "清廉承诺", msgType, content, |
|
|
|
|
(webUrl + "wx-subscribe.html"), |
|
|
|
|
(webUrl + "images/message/subscribe.png")); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static OutputStream getOutputStream(HttpServletResponse response) { |
|
|
|
|
try { |
|
|
|
|
return response.getOutputStream(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
ErrorHelper.println(e); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 信息回复 |
|
|
|
|
* |
|
|
|
|
* @param response |
|
|
|
|
* @param fromUserName |
|
|
|
|
* @param toUserName |
|
|
|
|
* @param title |
|
|
|
|
* @param msgType |
|
|
|
|
* @param userText |
|
|
|
|
* @param link |
|
|
|
|
* @param imageUrl |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static boolean createLinkMsg(HttpServletResponse response, String fromUserName, String toUserName, String title, String msgType, String userText, String link, String imageUrl) { |
|
|
|
|
if (!WxEventEnum.MSG_TYPE_TEXT.CODE.equals(msgType)) { // 消息类型不为文本
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(userText)) { // 不存在
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>(); |
|
|
|
|
XMLNewsMessage.Article article; |
|
|
|
|
|
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
|
article.setTitle(title); |
|
|
|
|
article.setUrl(link); |
|
|
|
|
article.setPicurl(imageUrl); |
|
|
|
|
articleList.add(article); |
|
|
|
|
XMLNewsMessage xmlNewsMessage = new XMLNewsMessage(fromUserName, toUserName, articleList); |
|
|
|
|
xmlNewsMessage.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 文字匹配 |
|
|
|
|
*/ |
|
|
|
|
public static boolean textCommon(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName) { |
|
|
|
|
String webUrl = WeChatConfig.getWebUrl(); |
|
|
|
|
|
|
|
|
@ -105,42 +156,80 @@ public class WxPassiveReplyHelper { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关注 |
|
|
|
|
* |
|
|
|
|
* @param response |
|
|
|
|
* @param content |
|
|
|
|
* @param msgType |
|
|
|
|
* @param fromUserName |
|
|
|
|
* @param toUserName |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static boolean subscribeCommon(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String event) { |
|
|
|
|
// 根据医院appId回复
|
|
|
|
|
public static Boolean hospReply(HttpServletResponse response, WxEvent wxEvent, String msgId, String fromUserName, String toUserName) { |
|
|
|
|
String event = wxEvent.getEvent(); |
|
|
|
|
String eventKey = wxEvent.getEventKey(); |
|
|
|
|
String msgType = wxEvent.getMsgType(); |
|
|
|
|
String reqContent = wxEvent.getContent(); |
|
|
|
|
if (reqContent != null) { |
|
|
|
|
reqContent = reqContent.trim().toUpperCase(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("event={}", event); |
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) { |
|
|
|
|
String webUrl = WeChatConfig.getWebUrl(); |
|
|
|
|
return createLinkMsg(response, fromUserName, toUserName, "清廉承诺", msgType, content, |
|
|
|
|
(webUrl + "wx-subscribe.html"), |
|
|
|
|
(webUrl + "images/message/subscribe.png")); |
|
|
|
|
WxPassiveReplyHelper.textCommon(response, reqContent, msgType, fromUserName, toUserName); |
|
|
|
|
|
|
|
|
|
HospConfigEnum hospConfigEnum = HospConfigEnum.findEnumByWxAppId(); |
|
|
|
|
if (hospConfigEnum == null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
switch (hospConfigEnum) { |
|
|
|
|
case 红河州第一人民医院: |
|
|
|
|
return WxPassiveReplyHelper.红河州第一人民医院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 蒙自市妇幼保健院: |
|
|
|
|
return WxPassiveReplyHelper.蒙自市妇幼保健院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 德宏州妇幼保健院: |
|
|
|
|
return WxPassiveReplyHelper.德宏州妇幼保健院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 武定忠爱医院: |
|
|
|
|
return WxPassiveReplyHelper.武定忠爱医院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 华坪县人民医院: |
|
|
|
|
return WxPassiveReplyHelper.华坪县人民医院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 巍山县人民医院: |
|
|
|
|
return WxPassiveReplyHelper.巍山县人民医院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 芒市人民医院: |
|
|
|
|
return WxPassiveReplyHelper.芒市人民医院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
case 玉龙县人民医院: |
|
|
|
|
return WxPassiveReplyHelper.玉龙县人民医院(response, reqContent, msgType, fromUserName, toUserName, eventKey, event); |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static Boolean 武定忠爱医院(HttpServletResponse response, String reqContent, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
if (WxEventEnum.MSG_TYPE_EVENT.CODE.equals(msgType)) { |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
String respInfo = "欢迎关注武定忠爱医院!" + |
|
|
|
|
"\n\uD83D\uDD17 <a href='" + WeChatConfig.getWebUrl() + "reg-today.html" + "'>今日挂号</a>" + |
|
|
|
|
"\n\uD83D\uDD17 <a href='" + WeChatConfig.getWebUrl() + "reg-reserve.html" + "'>预约挂号</a>"; |
|
|
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo); |
|
|
|
|
msg.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void 芒市人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
|
|
|
|
|
public static boolean 芒市人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>(); |
|
|
|
|
XMLNewsMessage.Article article; |
|
|
|
|
|
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) { |
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) { |
|
|
|
|
if (WxEventEnum.MSG_TYPE_EVENT.CODE.equals(msgType)) { |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
|
article.setTitle("微信预约挂号开通喽,大家快快用起来!"); |
|
|
|
|
article.setUrl("https://mp.weixin.qq.com/s/rJF1qBo1-mV5CUdRsi4Z5g"); |
|
|
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/RUm4m8SVypy7nVubUuo6KgdlibcduK8l4tWnXrz7VfTO5EYOeDc9hZxR70wTQgX1sYhRR7SeND6426uczdpf1BA/0?wx_fmt=jpeg"); |
|
|
|
|
articleList.add(article); |
|
|
|
|
XMLNewsMessage xmlNewsMessage = new XMLNewsMessage(fromUserName, toUserName, articleList); |
|
|
|
|
xmlNewsMessage.outputStreamWrite(getOut(response)); |
|
|
|
|
xmlNewsMessage.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -224,11 +313,12 @@ public class WxPassiveReplyHelper { |
|
|
|
|
"外一科(普外):2133720"; |
|
|
|
|
} |
|
|
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo); |
|
|
|
|
msg.outputStreamWrite(getOut(response)); |
|
|
|
|
msg.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void 华坪县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
public static boolean 华坪县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>(); |
|
|
|
|
XMLNewsMessage.Article article; |
|
|
|
|
|
|
|
|
@ -252,7 +342,7 @@ public class WxPassiveReplyHelper { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) { |
|
|
|
|
if (WxEventEnum.MSG_TYPE_EVENT.CODE.equals(msgType)) { |
|
|
|
|
if (eventKey.equals("MYDDC")) { |
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
|
article.setTitle("华坪县人民医院患者满意度调查"); |
|
|
|
@ -272,7 +362,7 @@ public class WxPassiveReplyHelper { |
|
|
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/0jg8QrIOHOzYGDMbzzyKicXD9QlRA5MdmpF19PW1oFibvCDj60twgfGC556fY3wThlAhIYJsHykiaDIU8h3Igh8Dw/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1"); |
|
|
|
|
articleList.add(article); |
|
|
|
|
|
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) { |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
|
article.setTitle("微信支付使用流程!"); |
|
|
|
|
article.setPicurl("http://mmbiz.qpic.cn/mmbiz/0jg8QrIOHOydg7liaUzXoa7otFCiavYozxARcpnrxt5ibQ7Y8BewUOtKJPWRUATkaskjvHeeqmicDbovRwZic7BTSng/0?wx_fmt=jpeg"); |
|
|
|
@ -284,15 +374,16 @@ public class WxPassiveReplyHelper { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
XMLNewsMessage msg = new XMLNewsMessage(fromUserName, toUserName, articleList); |
|
|
|
|
msg.outputStreamWrite(getOut(response)); |
|
|
|
|
msg.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void 巍山县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
public static boolean 巍山县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
|
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>(); |
|
|
|
|
XMLNewsMessage.Article article; |
|
|
|
|
|
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) { |
|
|
|
|
if (WxEventEnum.MSG_TYPE_EVENT.CODE.equals(msgType)) { |
|
|
|
|
// 满意度
|
|
|
|
|
if (eventKey.equals("MYDDC")) { |
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
@ -303,7 +394,7 @@ public class WxPassiveReplyHelper { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// 关注
|
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) { |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
|
article.setTitle("微信预约挂号开通喽,大家快快用起来!"); |
|
|
|
|
article.setUrl("http://mp.weixin.qq.com/s/gl_NitQTP6_ZzoV8pwxOcw"); |
|
|
|
@ -313,7 +404,8 @@ public class WxPassiveReplyHelper { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
XMLNewsMessage msg = new XMLNewsMessage(fromUserName, toUserName, articleList); |
|
|
|
|
msg.outputStreamWrite(getOut(response)); |
|
|
|
|
msg.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -339,7 +431,7 @@ public class WxPassiveReplyHelper { |
|
|
|
|
String respInfo; |
|
|
|
|
if (content.contains("核酸")) { |
|
|
|
|
respInfo = " 您好,玉龙县人民医院自助核酸检测需要点击微信挂号—自助核算检测进行具体操作。核酸检测报告电子版可在云南健康码查询," + |
|
|
|
|
"纸质版可到门诊楼一楼自助打印,如标本检测有异常的,报告出具时间将延迟,如到时间后未查询到结果或有其他疑问可拨打0888-5180762进行咨询。" ; |
|
|
|
|
"纸质版可到门诊楼一楼自助打印,如标本检测有异常的,报告出具时间将延迟,如到时间后未查询到结果或有其他疑问可拨打0888-5180762进行咨询。"; |
|
|
|
|
|
|
|
|
|
} else if (content.contains("投诉")) { |
|
|
|
|
respInfo = "您好,您可以拨打投诉电话:0888-5112778或行政值班电话:0888-5115602进行投诉"; |
|
|
|
@ -399,76 +491,36 @@ public class WxPassiveReplyHelper { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo); |
|
|
|
|
msg.outputStreamWrite(getOut(response)); |
|
|
|
|
msg.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void 德宏州妇幼保健院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) { |
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) { |
|
|
|
|
String respInfo ="您好!欢迎关注德宏州妇幼保健院!如有疑问请拨打 24小时值班电话:15368666599"; |
|
|
|
|
public static boolean 德宏州妇幼保健院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
if (WxEventEnum.MSG_TYPE_EVENT.CODE.equals(msgType)) { |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
String respInfo = "您好!欢迎关注德宏州妇幼保健院!如有疑问请拨打 24小时值班电话:15368666599"; |
|
|
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo); |
|
|
|
|
msg.outputStreamWrite(getOut(response)); |
|
|
|
|
msg.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void 蒙自市妇幼保健院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event){ |
|
|
|
|
public static boolean 蒙自市妇幼保健院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) { |
|
|
|
|
String mediaId = "iJoe834_vhMOnlrUUCQF5jyeRvOTJ0sF-ly_vZrsGzPqEFY0kvdzr_p410e-lG0K"; //医院科室对应电话列表图片
|
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) { |
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) { |
|
|
|
|
XMLImageMessage imageMessage = new XMLImageMessage(fromUserName,toUserName, mediaId); |
|
|
|
|
imageMessage.outputStreamWrite(getOut(response)); |
|
|
|
|
if (WxEventEnum.MSG_TYPE_EVENT.CODE.equals(msgType)) { |
|
|
|
|
if (WxEventEnum.EVENT_SUBSCRIBE.CODE.equals(event)) { |
|
|
|
|
XMLImageMessage imageMessage = new XMLImageMessage(fromUserName, toUserName, mediaId); |
|
|
|
|
imageMessage.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(content==null){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
XMLImageMessage imageMessage = new XMLImageMessage(fromUserName,toUserName,mediaId); |
|
|
|
|
imageMessage.outputStreamWrite(getOut(response)); |
|
|
|
|
} |
|
|
|
|
public static OutputStream getOut(HttpServletResponse response) { |
|
|
|
|
try { |
|
|
|
|
return response.getOutputStream(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
ErrorHelper.println(e); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 信息回复 |
|
|
|
|
* |
|
|
|
|
* @param response |
|
|
|
|
* @param fromUserName |
|
|
|
|
* @param toUserName |
|
|
|
|
* @param title |
|
|
|
|
* @param msgType |
|
|
|
|
* @param userText |
|
|
|
|
* @param link |
|
|
|
|
* @param imageUrl |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static boolean createLinkMsg(HttpServletResponse response, String fromUserName, String toUserName, String title, String msgType, String userText, String link, String imageUrl) { |
|
|
|
|
if (!MSG_TYPE_TEXT.equals(msgType)) { // 消息类型不为文本
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(userText)) { // 不存在
|
|
|
|
|
if (content == null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>(); |
|
|
|
|
XMLNewsMessage.Article article; |
|
|
|
|
|
|
|
|
|
article = new XMLNewsMessage.Article(); |
|
|
|
|
article.setTitle(title); |
|
|
|
|
article.setUrl(link); |
|
|
|
|
article.setPicurl(imageUrl); |
|
|
|
|
articleList.add(article); |
|
|
|
|
XMLNewsMessage xmlNewsMessage = new XMLNewsMessage(fromUserName, toUserName, articleList); |
|
|
|
|
xmlNewsMessage.outputStreamWrite(getOut(response)); |
|
|
|
|
XMLImageMessage imageMessage = new XMLImageMessage(fromUserName, toUserName, mediaId); |
|
|
|
|
imageMessage.outputStreamWrite(getOutputStream(response)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|