@@ -3,187 +3,215 @@ package me.chanjar.weixin.common.api; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
/** | |||||
* 微信开发所使用到的常量类 | |||||
* | |||||
* @author chanjarster & binarywang | |||||
*/ | |||||
public class WxConsts { | public class WxConsts { | ||||
/////////////////////// | |||||
// 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 | |||||
/////////////////////// | |||||
public static final String XML_MSG_TEXT = "text"; | |||||
public static final String XML_MSG_IMAGE = "image"; | |||||
public static final String XML_MSG_VOICE = "voice"; | |||||
public static final String XML_MSG_SHORTVIDEO = "shortvideo"; | |||||
public static final String XML_MSG_VIDEO = "video"; | |||||
public static final String XML_MSG_NEWS = "news"; | |||||
public static final String XML_MSG_MUSIC = "music"; | |||||
public static final String XML_MSG_LOCATION = "location"; | |||||
public static final String XML_MSG_LINK = "link"; | |||||
public static final String XML_MSG_EVENT = "event"; | |||||
public static final String XML_MSG_DEVICE_TEXT = "device_text"; | |||||
public static final String XML_MSG_DEVICE_EVENT = "device_event"; | |||||
public static final String XML_MSG_DEVICE_STATUS = "device_status"; | |||||
public static final String XML_MSG_HARDWARE = "hardware"; | |||||
public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; | |||||
/////////////////////// | |||||
// 主动发送消息(即客服消息)的消息类型 | |||||
/////////////////////// | |||||
public static final String CUSTOM_MSG_TEXT = "text";//文本消息 | |||||
public static final String CUSTOM_MSG_IMAGE = "image";//图片消息 | |||||
public static final String CUSTOM_MSG_VOICE = "voice";//语音消息 | |||||
public static final String CUSTOM_MSG_VIDEO = "video";//视频消息 | |||||
public static final String CUSTOM_MSG_MUSIC = "music";//音乐消息 | |||||
public static final String CUSTOM_MSG_NEWS = "news";//图文消息(点击跳转到外链) | |||||
public static final String CUSTOM_MSG_MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) | |||||
public static final String CUSTOM_MSG_FILE = "file";//发送文件(CP专用) | |||||
public static final String CUSTOM_MSG_TEXTCARD = "textcard";//文本卡片消息(CP专用) | |||||
public static final String CUSTOM_MSG_WXCARD = "wxcard";//卡券消息 | |||||
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; | |||||
public static final String CUSTOM_MSG_SAFE_NO = "0"; | |||||
public static final String CUSTOM_MSG_SAFE_YES = "1"; | |||||
/////////////////////// | |||||
// 群发消息的消息类型 | |||||
/////////////////////// | |||||
public static final String MASS_MSG_NEWS = "mpnews"; | |||||
public static final String MASS_MSG_TEXT = "text"; | |||||
public static final String MASS_MSG_VOICE = "voice"; | |||||
public static final String MASS_MSG_IMAGE = "image"; | |||||
public static final String MASS_MSG_VIDEO = "mpvideo"; | |||||
/////////////////////// | |||||
// 群发消息后微信端推送给服务器的反馈消息 | |||||
/////////////////////// | |||||
public static final String MASS_ST_SUCCESS = "send success"; | |||||
public static final String MASS_ST_FAIL = "send fail"; | |||||
public static final String MASS_ST_10001 = "err(10001)"; | |||||
public static final String MASS_ST_20001 = "err(20001)"; | |||||
public static final String MASS_ST_20004 = "err(20004)"; | |||||
public static final String MASS_ST_20002 = "err(20002)"; | |||||
public static final String MASS_ST_20006 = "err(20006)"; | |||||
public static final String MASS_ST_20008 = "err(20008)"; | |||||
public static final String MASS_ST_20013 = "err(20013)"; | |||||
public static final String MASS_ST_22000 = "err(22000)"; | |||||
public static final String MASS_ST_21000 = "err(21000)"; | |||||
/** | /** | ||||
* 群发反馈消息代码所对应的文字描述 | |||||
* 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 | |||||
*/ | */ | ||||
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<>(); | |||||
/////////////////////// | |||||
// 微信端推送过来的事件类型 | |||||
/////////////////////// | |||||
public static final String EVT_SUBSCRIBE = "subscribe"; | |||||
public static final String EVT_UNSUBSCRIBE = "unsubscribe"; | |||||
public static final String EVT_SCAN = "SCAN"; | |||||
public static final String EVT_LOCATION = "LOCATION"; | |||||
public static final String EVT_CLICK = "CLICK"; | |||||
public static final String EVT_VIEW = "VIEW"; | |||||
public static final String EVT_MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; | |||||
public static final String EVT_SCANCODE_PUSH = "scancode_push"; | |||||
public static final String EVT_SCANCODE_WAITMSG = "scancode_waitmsg"; | |||||
public static final String EVT_PIC_SYSPHOTO = "pic_sysphoto"; | |||||
public static final String EVT_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; | |||||
public static final String EVT_PIC_WEIXIN = "pic_weixin"; | |||||
public static final String EVT_LOCATION_SELECT = "location_select"; | |||||
public static final String EVT_TEMPLATESENDJOBFINISH = "TEMPLATESENDJOBFINISH"; | |||||
public static final String EVT_ENTER_AGENT = "enter_agent"; | |||||
/////////////////////// | |||||
// 上传多媒体文件的类型 | |||||
/////////////////////// | |||||
public static final String MEDIA_IMAGE = "image"; | |||||
public static final String MEDIA_VOICE = "voice"; | |||||
public static final String MEDIA_VIDEO = "video"; | |||||
public static final String MEDIA_THUMB = "thumb"; | |||||
public static final String MEDIA_FILE = "file"; | |||||
public static class XmlMsgType { | |||||
public static final String TEXT = "text"; | |||||
public static final String IMAGE = "image"; | |||||
public static final String VOICE = "voice"; | |||||
public static final String SHORTVIDEO = "shortvideo"; | |||||
public static final String VIDEO = "video"; | |||||
public static final String NEWS = "news"; | |||||
public static final String MUSIC = "music"; | |||||
public static final String LOCATION = "location"; | |||||
public static final String LINK = "link"; | |||||
public static final String EVENT = "event"; | |||||
public static final String DEVICE_TEXT = "device_text"; | |||||
public static final String DEVICE_EVENT = "device_event"; | |||||
public static final String DEVICE_STATUS = "device_status"; | |||||
public static final String HARDWARE = "hardware"; | |||||
public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; | |||||
} | |||||
/////////////////////// | |||||
// 自定义菜单的按钮类型 | |||||
/////////////////////// | |||||
/** | |||||
* 点击推事件 | |||||
*/ | |||||
public static final String BUTTON_CLICK = "click"; | |||||
/** | |||||
* 跳转URL | |||||
*/ | |||||
public static final String BUTTON_VIEW = "view"; | |||||
/** | |||||
* 跳转到小程序 | |||||
*/ | |||||
public static final String BUTTON_MINIPROGRAM = "miniprogram"; | |||||
/** | |||||
* 扫码推事件 | |||||
*/ | |||||
public static final String BUTTON_SCANCODE_PUSH = "scancode_push"; | |||||
/** | /** | ||||
* 扫码推事件且弹出“消息接收中”提示框 | |||||
* 主动发送消息(即客服消息)的消息类型 | |||||
*/ | */ | ||||
public static final String BUTTON_SCANCODE_WAITMSG = "scancode_waitmsg"; | |||||
public static class KefuMsgType { | |||||
public static final String TEXT = "text";//文本消息 | |||||
public static final String IMAGE = "image";//图片消息 | |||||
public static final String VOICE = "voice";//语音消息 | |||||
public static final String VIDEO = "video";//视频消息 | |||||
public static final String MUSIC = "music";//音乐消息 | |||||
public static final String NEWS = "news";//图文消息(点击跳转到外链) | |||||
public static final String MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) | |||||
public static final String FILE = "file";//发送文件(CP专用) | |||||
public static final String TEXTCARD = "textcard";//文本卡片消息(CP专用) | |||||
public static final String WXCARD = "wxcard";//卡券消息 | |||||
public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; | |||||
} | |||||
/** | /** | ||||
* 弹出系统拍照发图 | |||||
* 表示是否是保密消息,0表示否,1表示是,默认0 | |||||
*/ | */ | ||||
public static final String BUTTON_PIC_SYSPHOTO = "pic_sysphoto"; | |||||
public static class KefuMsgSafe { | |||||
public static final String NO = "0"; | |||||
public static final String YES = "1"; | |||||
} | |||||
/** | /** | ||||
* 弹出拍照或者相册发图 | |||||
* 群发消息的消息类型 | |||||
*/ | */ | ||||
public static final String BUTTON_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; | |||||
public static class MassMsgType { | |||||
public static final String MPNEWS = "mpnews"; | |||||
public static final String TEXT = "text"; | |||||
public static final String VOICE = "voice"; | |||||
public static final String IMAGE = "image"; | |||||
public static final String MPVIDEO = "mpvideo"; | |||||
} | |||||
/** | /** | ||||
* 弹出微信相册发图器 | |||||
* 群发消息后微信端推送给服务器的反馈消息 | |||||
*/ | */ | ||||
public static final String BUTTON_PIC_WEIXIN = "pic_weixin"; | |||||
public static class MassMsgStatus { | |||||
public static final String SEND_SUCCESS = "send success"; | |||||
public static final String SEND_FAIL = "send fail"; | |||||
public static final String ERR_10001 = "err(10001)"; | |||||
public static final String ERR_20001 = "err(20001)"; | |||||
public static final String ERR_20004 = "err(20004)"; | |||||
public static final String ERR_20002 = "err(20002)"; | |||||
public static final String ERR_20006 = "err(20006)"; | |||||
public static final String ERR_20008 = "err(20008)"; | |||||
public static final String ERR_20013 = "err(20013)"; | |||||
public static final String ERR_22000 = "err(22000)"; | |||||
public static final String ERR_21000 = "err(21000)"; | |||||
/** | |||||
* 群发反馈消息代码所对应的文字描述 | |||||
*/ | |||||
public static final Map<String, String> STATUS_DESC = new HashMap<>(); | |||||
static { | |||||
STATUS_DESC.put(SEND_SUCCESS, "发送成功"); | |||||
STATUS_DESC.put(SEND_FAIL, "发送失败"); | |||||
STATUS_DESC.put(ERR_10001, "涉嫌广告"); | |||||
STATUS_DESC.put(ERR_20001, "涉嫌政治"); | |||||
STATUS_DESC.put(ERR_20004, "涉嫌社会"); | |||||
STATUS_DESC.put(ERR_20002, "涉嫌色情"); | |||||
STATUS_DESC.put(ERR_20006, "涉嫌违法犯罪"); | |||||
STATUS_DESC.put(ERR_20008, "涉嫌欺诈"); | |||||
STATUS_DESC.put(ERR_20013, "涉嫌版权"); | |||||
STATUS_DESC.put(ERR_22000, "涉嫌互推_互相宣传"); | |||||
STATUS_DESC.put(ERR_21000, "涉嫌其他"); | |||||
} | |||||
} | |||||
/** | /** | ||||
* 弹出地理位置选择器 | |||||
* 微信端推送过来的事件类型 | |||||
*/ | */ | ||||
public static final String BUTTON_LOCATION_SELECT = "location_select"; | |||||
public static class EventType { | |||||
public static final String SUBSCRIBE = "subscribe"; | |||||
public static final String UNSUBSCRIBE = "unsubscribe"; | |||||
public static final String SCAN = "SCAN"; | |||||
public static final String LOCATION = "LOCATION"; | |||||
public static final String CLICK = "CLICK"; | |||||
public static final String VIEW = "VIEW"; | |||||
public static final String MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; | |||||
public static final String SCANCODE_PUSH = "scancode_push"; | |||||
public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; | |||||
public static final String PIC_SYSPHOTO = "pic_sysphoto"; | |||||
public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; | |||||
public static final String PIC_WEIXIN = "pic_weixin"; | |||||
public static final String LOCATION_SELECT = "location_select"; | |||||
public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH"; | |||||
public static final String ENTER_AGENT = "enter_agent"; | |||||
} | |||||
/** | /** | ||||
* 下发消息(除文本消息) | |||||
* 上传多媒体(临时素材)文件的类型 | |||||
*/ | */ | ||||
public static final String BUTTON_MEDIA_ID = "media_id"; | |||||
public static class MediaFileType { | |||||
public static final String IMAGE = "image"; | |||||
public static final String VOICE = "voice"; | |||||
public static final String VIDEO = "video"; | |||||
public static final String THUMB = "thumb"; | |||||
public static final String FILE = "file"; | |||||
} | |||||
/** | /** | ||||
* 跳转图文消息URL | |||||
* 自定义菜单的按钮类型 | |||||
*/ | */ | ||||
public static final String BUTTON_VIEW_LIMITED = "view_limited"; | |||||
public static class MenuButtonType { | |||||
/** | |||||
* 点击推事件 | |||||
*/ | |||||
public static final String CLICK = "click"; | |||||
/** | |||||
* 跳转URL | |||||
*/ | |||||
public static final String VIEW = "view"; | |||||
/** | |||||
* 跳转到小程序 | |||||
*/ | |||||
public static final String MINIPROGRAM = "miniprogram"; | |||||
/** | |||||
* 扫码推事件 | |||||
*/ | |||||
public static final String SCANCODE_PUSH = "scancode_push"; | |||||
/** | |||||
* 扫码推事件且弹出“消息接收中”提示框 | |||||
*/ | |||||
public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; | |||||
/** | |||||
* 弹出系统拍照发图 | |||||
*/ | |||||
public static final String PIC_SYSPHOTO = "pic_sysphoto"; | |||||
/** | |||||
* 弹出拍照或者相册发图 | |||||
*/ | |||||
public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; | |||||
/** | |||||
* 弹出微信相册发图器 | |||||
*/ | |||||
public static final String PIC_WEIXIN = "pic_weixin"; | |||||
/** | |||||
* 弹出地理位置选择器 | |||||
*/ | |||||
public static final String LOCATION_SELECT = "location_select"; | |||||
/** | |||||
* 下发消息(除文本消息) | |||||
*/ | |||||
public static final String MEDIA_ID = "media_id"; | |||||
/** | |||||
* 跳转图文消息URL | |||||
*/ | |||||
public static final String VIEW_LIMITED = "view_limited"; | |||||
} | |||||
/** | /** | ||||
* 不弹出授权页面,直接跳转,只能获取用户openid | |||||
* oauth2网页授权的scope | |||||
*/ | */ | ||||
public static final String OAUTH2_SCOPE_BASE = "snsapi_base"; | |||||
public static class OAuth2Scope { | |||||
/** | |||||
* 不弹出授权页面,直接跳转,只能获取用户openid | |||||
*/ | |||||
public static final String SNSAPI_BASE = "snsapi_base"; | |||||
/** | |||||
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 | |||||
*/ | |||||
public static final String SNSAPI_USERINFO = "snsapi_userinfo"; | |||||
} | |||||
/////////////////////// | |||||
// oauth2网页授权的scope | |||||
/////////////////////// | |||||
/** | /** | ||||
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 | |||||
* 网页应用登录授权作用域 | |||||
*/ | */ | ||||
public static final String OAUTH2_SCOPE_USER_INFO = "snsapi_userinfo"; | |||||
public static class QrConnectScope { | |||||
public static final String SNSAPI_LOGIN = "snsapi_login"; | |||||
} | |||||
/** | /** | ||||
* 网页应用登录授权作用域 snsapi_login | |||||
* 永久素材类型 | |||||
*/ | */ | ||||
public static final String QRCONNECT_SCOPE_SNSAPI_LOGIN = "snsapi_login"; | |||||
/////////////////////// | |||||
// 永久素材类型 | |||||
/////////////////////// | |||||
public static final String MATERIAL_NEWS = "news"; | |||||
public static final String MATERIAL_VOICE = "voice"; | |||||
public static final String MATERIAL_IMAGE = "image"; | |||||
public static final String MATERIAL_VIDEO = "video"; | |||||
static { | |||||
MASS_ST_2_DESC.put(MASS_ST_SUCCESS, "发送成功"); | |||||
MASS_ST_2_DESC.put(MASS_ST_FAIL, "发送失败"); | |||||
MASS_ST_2_DESC.put(MASS_ST_10001, "涉嫌广告"); | |||||
MASS_ST_2_DESC.put(MASS_ST_20001, "涉嫌政治"); | |||||
MASS_ST_2_DESC.put(MASS_ST_20004, "涉嫌社会"); | |||||
MASS_ST_2_DESC.put(MASS_ST_20002, "涉嫌色情"); | |||||
MASS_ST_2_DESC.put(MASS_ST_20006, "涉嫌违法犯罪"); | |||||
MASS_ST_2_DESC.put(MASS_ST_20008, "涉嫌欺诈"); | |||||
MASS_ST_2_DESC.put(MASS_ST_20013, "涉嫌版权"); | |||||
MASS_ST_2_DESC.put(MASS_ST_22000, "涉嫌互推_互相宣传"); | |||||
MASS_ST_2_DESC.put(MASS_ST_21000, "涉嫌其他"); | |||||
public static class MaterialType { | |||||
public static final String NEWS = "news"; | |||||
public static final String VOICE = "voice"; | |||||
public static final String IMAGE = "image"; | |||||
public static final String VIDEO = "video"; | |||||
} | } | ||||
} | } |
@@ -1,5 +1,6 @@ | |||||
package me.chanjar.weixin.cp.bean; | package me.chanjar.weixin.cp.bean; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.cp.bean.article.MpnewsArticle; | import me.chanjar.weixin.cp.bean.article.MpnewsArticle; | ||||
import me.chanjar.weixin.cp.bean.article.NewArticle; | import me.chanjar.weixin.cp.bean.article.NewArticle; | ||||
import me.chanjar.weixin.cp.bean.messagebuilder.*; | import me.chanjar.weixin.cp.bean.messagebuilder.*; | ||||
@@ -137,13 +138,13 @@ public class WxCpMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 请使用 | * 请使用 | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MPNEWS} | |||||
* {@link WxConsts.KefuMsgType#TEXT} | |||||
* {@link WxConsts.KefuMsgType#IMAGE} | |||||
* {@link WxConsts.KefuMsgType#VOICE} | |||||
* {@link WxConsts.KefuMsgType#MUSIC} | |||||
* {@link WxConsts.KefuMsgType#VIDEO} | |||||
* {@link WxConsts.KefuMsgType#NEWS} | |||||
* {@link WxConsts.KefuMsgType#MPNEWS} | |||||
* </pre> | * </pre> | ||||
* | * | ||||
* @param msgType 消息类型 | * @param msgType 消息类型 | ||||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.bean; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import com.thoughtworks.xstream.annotations.XStreamConverter; | import com.thoughtworks.xstream.annotations.XStreamConverter; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.common.util.ToStringUtils; | import me.chanjar.weixin.common.util.ToStringUtils; | ||||
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; | import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; | ||||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||
@@ -224,13 +225,13 @@ public class WxCpXmlMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 当接受用户消息时,可能会获得以下值: | * 当接受用户消息时,可能会获得以下值: | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT} | |||||
* {@link WxConsts.XmlMsgType#TEXT} | |||||
* {@link WxConsts.XmlMsgType#IMAGE} | |||||
* {@link WxConsts.XmlMsgType#VOICE} | |||||
* {@link WxConsts.XmlMsgType#VIDEO} | |||||
* {@link WxConsts.XmlMsgType#LOCATION} | |||||
* {@link WxConsts.XmlMsgType#LINK} | |||||
* {@link WxConsts.XmlMsgType#EVENT} | |||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
public String getMsgType() { | public String getMsgType() { | ||||
@@ -240,11 +241,11 @@ public class WxCpXmlMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 当发送消息的时候使用: | * 当发送消息的时候使用: | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS} | |||||
* {@link WxConsts.XmlMsgType#TEXT} | |||||
* {@link WxConsts.XmlMsgType#IMAGE} | |||||
* {@link WxConsts.XmlMsgType#VOICE} | |||||
* {@link WxConsts.XmlMsgType#VIDEO} | |||||
* {@link WxConsts.XmlMsgType#NEWS} | |||||
* </pre> | * </pre> | ||||
* | * | ||||
* @param msgType | * @param msgType | ||||
@@ -14,7 +14,7 @@ public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage { | |||||
private String mediaId; | private String mediaId; | ||||
public WxCpXmlOutImageMessage() { | public WxCpXmlOutImageMessage() { | ||||
this.msgType = WxConsts.XML_MSG_IMAGE; | |||||
this.msgType = WxConsts.XmlMsgType.IMAGE; | |||||
} | } | ||||
public String getMediaId() { | public String getMediaId() { | ||||
@@ -18,7 +18,7 @@ public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage { | |||||
protected int articleCount; | protected int articleCount; | ||||
public WxCpXmlOutNewsMessage() { | public WxCpXmlOutNewsMessage() { | ||||
this.msgType = WxConsts.XML_MSG_NEWS; | |||||
this.msgType = WxConsts.XmlMsgType.NEWS; | |||||
} | } | ||||
public int getArticleCount() { | public int getArticleCount() { | ||||
@@ -14,7 +14,7 @@ public class WxCpXmlOutTextMessage extends WxCpXmlOutMessage { | |||||
private String content; | private String content; | ||||
public WxCpXmlOutTextMessage() { | public WxCpXmlOutTextMessage() { | ||||
this.msgType = WxConsts.XML_MSG_TEXT; | |||||
this.msgType = WxConsts.XmlMsgType.TEXT; | |||||
} | } | ||||
public String getContent() { | public String getContent() { | ||||
@@ -13,7 +13,7 @@ public class WxCpXmlOutVideoMessage extends WxCpXmlOutMessage { | |||||
protected final Video video = new Video(); | protected final Video video = new Video(); | ||||
public WxCpXmlOutVideoMessage() { | public WxCpXmlOutVideoMessage() { | ||||
this.msgType = WxConsts.XML_MSG_VIDEO; | |||||
this.msgType = WxConsts.XmlMsgType.VIDEO; | |||||
} | } | ||||
public String getMediaId() { | public String getMediaId() { | ||||
@@ -14,7 +14,7 @@ public class WxCpXmlOutVoiceMessage extends WxCpXmlOutMessage { | |||||
private String mediaId; | private String mediaId; | ||||
public WxCpXmlOutVoiceMessage() { | public WxCpXmlOutVoiceMessage() { | ||||
this.msgType = WxConsts.XML_MSG_VOICE; | |||||
this.msgType = WxConsts.XmlMsgType.VOICE; | |||||
} | } | ||||
public String getMediaId() { | public String getMediaId() { | ||||
@@ -44,7 +44,7 @@ public class BaseBuilder<T> { | |||||
m.setToUser(this.toUser); | m.setToUser(this.toUser); | ||||
m.setToParty(this.toParty); | m.setToParty(this.toParty); | ||||
m.setToTag(this.toTag); | m.setToTag(this.toTag); | ||||
m.setSafe(StringUtils.defaultIfBlank(this.safe, WxConsts.CUSTOM_MSG_SAFE_NO)); | |||||
m.setSafe(StringUtils.defaultIfBlank(this.safe, WxConsts.KefuMsgSafe.NO)); | |||||
return m; | return m; | ||||
} | } | ||||
@@ -15,7 +15,7 @@ public final class FileBuilder extends BaseBuilder<FileBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public FileBuilder() { | public FileBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_FILE; | |||||
this.msgType = WxConsts.KefuMsgType.FILE; | |||||
} | } | ||||
public FileBuilder mediaId(String media_id) { | public FileBuilder mediaId(String media_id) { | ||||
@@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public ImageBuilder() { | public ImageBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_IMAGE; | |||||
this.msgType = WxConsts.KefuMsgType.IMAGE; | |||||
} | } | ||||
public ImageBuilder mediaId(String media_id) { | public ImageBuilder mediaId(String media_id) { | ||||
@@ -23,7 +23,7 @@ public final class MpnewsBuilder extends BaseBuilder<MpnewsBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public MpnewsBuilder() { | public MpnewsBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_MPNEWS; | |||||
this.msgType = WxConsts.KefuMsgType.MPNEWS; | |||||
} | } | ||||
public MpnewsBuilder mediaId(String mediaId) { | public MpnewsBuilder mediaId(String mediaId) { | ||||
@@ -22,7 +22,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> { | |||||
private List<NewArticle> articles = new ArrayList<>(); | private List<NewArticle> articles = new ArrayList<>(); | ||||
public NewsBuilder() { | public NewsBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_NEWS; | |||||
this.msgType = WxConsts.KefuMsgType.NEWS; | |||||
} | } | ||||
public NewsBuilder addArticle(NewArticle... articles) { | public NewsBuilder addArticle(NewArticle... articles) { | ||||
@@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> { | |||||
private String content; | private String content; | ||||
public TextBuilder() { | public TextBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_TEXT; | |||||
this.msgType = WxConsts.KefuMsgType.TEXT; | |||||
} | } | ||||
public TextBuilder content(String content) { | public TextBuilder content(String content) { | ||||
@@ -18,7 +18,7 @@ public class TextCardBuilder extends BaseBuilder<TextCardBuilder> { | |||||
private String url; | private String url; | ||||
public TextCardBuilder() { | public TextCardBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_TEXTCARD; | |||||
this.msgType = WxConsts.KefuMsgType.TEXTCARD; | |||||
} | } | ||||
public TextCardBuilder title(String title) { | public TextCardBuilder title(String title) { | ||||
@@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> { | |||||
private String thumbMediaId; | private String thumbMediaId; | ||||
public VideoBuilder() { | public VideoBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_VIDEO; | |||||
this.msgType = WxConsts.KefuMsgType.VIDEO; | |||||
} | } | ||||
public VideoBuilder mediaId(String mediaId) { | public VideoBuilder mediaId(String mediaId) { | ||||
@@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public VoiceBuilder() { | public VoiceBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_VOICE; | |||||
this.msgType = WxConsts.KefuMsgType.VOICE; | |||||
} | } | ||||
public VoiceBuilder mediaId(String media_id) { | public VoiceBuilder mediaId(String media_id) { | ||||
@@ -37,13 +37,13 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> { | |||||
if (StringUtils.isNotBlank(message.getToTag())) { | if (StringUtils.isNotBlank(message.getToTag())) { | ||||
messageJson.addProperty("totag", message.getToTag()); | messageJson.addProperty("totag", message.getToTag()); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.TEXT.equals(message.getMsgType())) { | |||||
JsonObject text = new JsonObject(); | JsonObject text = new JsonObject(); | ||||
text.addProperty("content", message.getContent()); | text.addProperty("content", message.getContent()); | ||||
messageJson.add("text", text); | messageJson.add("text", text); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_TEXTCARD.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.TEXTCARD.equals(message.getMsgType())) { | |||||
JsonObject text = new JsonObject(); | JsonObject text = new JsonObject(); | ||||
text.addProperty("title", message.getTitle()); | text.addProperty("title", message.getTitle()); | ||||
text.addProperty("description", message.getDescription()); | text.addProperty("description", message.getDescription()); | ||||
@@ -51,19 +51,19 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> { | |||||
messageJson.add("textcard", text); | messageJson.add("textcard", text); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.IMAGE.equals(message.getMsgType())) { | |||||
JsonObject image = new JsonObject(); | JsonObject image = new JsonObject(); | ||||
image.addProperty("media_id", message.getMediaId()); | image.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add("image", image); | messageJson.add("image", image); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_FILE.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.FILE.equals(message.getMsgType())) { | |||||
JsonObject image = new JsonObject(); | JsonObject image = new JsonObject(); | ||||
image.addProperty("media_id", message.getMediaId()); | image.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add("file", image); | messageJson.add("file", image); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.VOICE.equals(message.getMsgType())) { | |||||
JsonObject voice = new JsonObject(); | JsonObject voice = new JsonObject(); | ||||
voice.addProperty("media_id", message.getMediaId()); | voice.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add("voice", voice); | messageJson.add("voice", voice); | ||||
@@ -73,7 +73,7 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> { | |||||
messageJson.addProperty("safe", message.getSafe()); | messageJson.addProperty("safe", message.getSafe()); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.VIDEO.equals(message.getMsgType())) { | |||||
JsonObject video = new JsonObject(); | JsonObject video = new JsonObject(); | ||||
video.addProperty("media_id", message.getMediaId()); | video.addProperty("media_id", message.getMediaId()); | ||||
video.addProperty("thumb_media_id", message.getThumbMediaId()); | video.addProperty("thumb_media_id", message.getThumbMediaId()); | ||||
@@ -82,7 +82,7 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> { | |||||
messageJson.add("video", video); | messageJson.add("video", video); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.NEWS.equals(message.getMsgType())) { | |||||
JsonObject newsJsonObject = new JsonObject(); | JsonObject newsJsonObject = new JsonObject(); | ||||
JsonArray articleJsonArray = new JsonArray(); | JsonArray articleJsonArray = new JsonArray(); | ||||
for (NewArticle article : message.getArticles()) { | for (NewArticle article : message.getArticles()) { | ||||
@@ -97,7 +97,7 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> { | |||||
messageJson.add("news", newsJsonObject); | messageJson.add("news", newsJsonObject); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_MPNEWS.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.MPNEWS.equals(message.getMsgType())) { | |||||
JsonObject newsJsonObject = new JsonObject(); | JsonObject newsJsonObject = new JsonObject(); | ||||
if (message.getMediaId() != null) { | if (message.getMediaId() != null) { | ||||
newsJsonObject.addProperty("media_id", message.getMediaId()); | newsJsonObject.addProperty("media_id", message.getMediaId()); | ||||
@@ -3,7 +3,6 @@ package me.chanjar.weixin.cp.api; | |||||
import com.google.inject.Inject; | import com.google.inject.Inject; | ||||
import me.chanjar.weixin.common.api.WxConsts; | import me.chanjar.weixin.common.api.WxConsts; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | |||||
import me.chanjar.weixin.cp.bean.WxCpMessage; | import me.chanjar.weixin.cp.bean.WxCpMessage; | ||||
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; | import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; | ||||
import org.testng.annotations.*; | import org.testng.annotations.*; | ||||
@@ -32,7 +31,7 @@ public class WxCpMessageAPITest { | |||||
public void testSendMessage() throws WxErrorException { | public void testSendMessage() throws WxErrorException { | ||||
WxCpMessage message = new WxCpMessage(); | WxCpMessage message = new WxCpMessage(); | ||||
// message.setAgentId(configStorage.getAgentId()); | // message.setAgentId(configStorage.getAgentId()); | ||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||||
message.setMsgType(WxConsts.KefuMsgType.TEXT); | |||||
message.setToUser(configStorage.getUserId()); | message.setToUser(configStorage.getUserId()); | ||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
@@ -27,21 +27,21 @@ public class WxCpMessageRouterTest { | |||||
router | router | ||||
.rule() | .rule() | ||||
.async(async) | .async(async) | ||||
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") | |||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1") | |||||
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_4")) | .handler(new WxEchoCpMessageHandler(sb, "COMBINE_4")) | ||||
.end() | .end() | ||||
.rule() | .rule() | ||||
.async(async) | .async(async) | ||||
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") | |||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1") | |||||
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_3")) | .handler(new WxEchoCpMessageHandler(sb, "COMBINE_3")) | ||||
.end() | .end() | ||||
.rule() | .rule() | ||||
.async(async) | .async(async) | ||||
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) | |||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK) | |||||
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_2")) | .handler(new WxEchoCpMessageHandler(sb, "COMBINE_2")) | ||||
.end() | .end() | ||||
.rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() | |||||
.rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EVT_CLICK)).end() | |||||
.rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end() | |||||
.rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EventType.CLICK)).end() | |||||
.rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end() | .rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end() | ||||
.rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end() | .rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end() | ||||
.rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end() | .rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end() | ||||
@@ -104,10 +104,10 @@ public class WxCpMessageRouterTest { | |||||
@DataProvider(name = "messages-1") | @DataProvider(name = "messages-1") | ||||
public Object[][] messages2() { | public Object[][] messages2() { | ||||
WxCpXmlMessage message1 = new WxCpXmlMessage(); | WxCpXmlMessage message1 = new WxCpXmlMessage(); | ||||
message1.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
message1.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
WxCpXmlMessage message2 = new WxCpXmlMessage(); | WxCpXmlMessage message2 = new WxCpXmlMessage(); | ||||
message2.setEvent(WxConsts.EVT_CLICK); | |||||
message2.setEvent(WxConsts.EventType.CLICK); | |||||
WxCpXmlMessage message3 = new WxCpXmlMessage(); | WxCpXmlMessage message3 = new WxCpXmlMessage(); | ||||
message3.setEventKey("KEY_1"); | message3.setEventKey("KEY_1"); | ||||
@@ -125,24 +125,24 @@ public class WxCpMessageRouterTest { | |||||
message7.setFormat("strangeformat"); | message7.setFormat("strangeformat"); | ||||
WxCpXmlMessage c2 = new WxCpXmlMessage(); | WxCpXmlMessage c2 = new WxCpXmlMessage(); | ||||
c2.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
c2.setEvent(WxConsts.EVT_CLICK); | |||||
c2.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
c2.setEvent(WxConsts.EventType.CLICK); | |||||
WxCpXmlMessage c3 = new WxCpXmlMessage(); | WxCpXmlMessage c3 = new WxCpXmlMessage(); | ||||
c3.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
c3.setEvent(WxConsts.EVT_CLICK); | |||||
c3.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
c3.setEvent(WxConsts.EventType.CLICK); | |||||
c3.setEventKey("KEY_1"); | c3.setEventKey("KEY_1"); | ||||
WxCpXmlMessage c4 = new WxCpXmlMessage(); | WxCpXmlMessage c4 = new WxCpXmlMessage(); | ||||
c4.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
c4.setEvent(WxConsts.EVT_CLICK); | |||||
c4.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
c4.setEvent(WxConsts.EventType.CLICK); | |||||
c4.setEventKey("KEY_1"); | c4.setEventKey("KEY_1"); | ||||
c4.setContent("CONTENT_1"); | c4.setContent("CONTENT_1"); | ||||
return new Object[][]{ | return new Object[][]{ | ||||
new Object[]{message1, WxConsts.XML_MSG_TEXT + ","}, | |||||
new Object[]{message2, WxConsts.EVT_CLICK + ","}, | |||||
new Object[]{message1, WxConsts.XmlMsgType.TEXT + ","}, | |||||
new Object[]{message2, WxConsts.EventType.CLICK + ","}, | |||||
new Object[]{message3, "KEY_1,"}, | new Object[]{message3, "KEY_1,"}, | ||||
new Object[]{message4, "CONTENT_1,"}, | new Object[]{message4, "CONTENT_1,"}, | ||||
new Object[]{message5, "ALL,"}, | new Object[]{message5, "ALL,"}, | ||||
@@ -34,11 +34,11 @@ public class WxCpMediaServiceImplTest { | |||||
@DataProvider | @DataProvider | ||||
public Object[][] mediaData() { | public Object[][] mediaData() { | ||||
return new Object[][]{ | return new Object[][]{ | ||||
new Object[]{WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, | |||||
new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, "mm.mp3"}, | |||||
new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_AMR, "mm.amr"},//{"errcode":301017,"errmsg":"voice file only support amr like myvoice.amr"} | |||||
new Object[]{WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, | |||||
new Object[]{WxConsts.MEDIA_FILE, TestConstants.FILE_JPG, "mm.jpeg"} | |||||
new Object[]{WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, | |||||
new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"}, | |||||
new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_AMR, "mm.amr"},//{"errcode":301017,"errmsg":"voice file only support amr like myvoice.amr"} | |||||
new Object[]{WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, | |||||
new Object[]{WxConsts.MediaFileType.FILE, TestConstants.FILE_JPG, "mm.jpeg"} | |||||
}; | }; | ||||
} | } | ||||
@@ -26,12 +26,12 @@ public class WxCpMenuServiceImplTest { | |||||
public Object[][] menuData() { | public Object[][] menuData() { | ||||
WxMenu menu = new WxMenu(); | WxMenu menu = new WxMenu(); | ||||
WxMenuButton button1 = new WxMenuButton(); | WxMenuButton button1 = new WxMenuButton(); | ||||
button1.setType(WxConsts.BUTTON_CLICK); | |||||
button1.setType(WxConsts.MenuButtonType.CLICK); | |||||
button1.setName("今日歌曲"); | button1.setName("今日歌曲"); | ||||
button1.setKey("V1001_TODAY_MUSIC"); | button1.setKey("V1001_TODAY_MUSIC"); | ||||
WxMenuButton button2 = new WxMenuButton(); | WxMenuButton button2 = new WxMenuButton(); | ||||
button2.setType(WxConsts.BUTTON_CLICK); | |||||
button2.setType(WxConsts.MenuButtonType.CLICK); | |||||
button2.setName("歌手简介"); | button2.setName("歌手简介"); | ||||
button2.setKey("V1001_TODAY_SINGER"); | button2.setKey("V1001_TODAY_SINGER"); | ||||
@@ -43,17 +43,17 @@ public class WxCpMenuServiceImplTest { | |||||
menu.getButtons().add(button3); | menu.getButtons().add(button3); | ||||
WxMenuButton button31 = new WxMenuButton(); | WxMenuButton button31 = new WxMenuButton(); | ||||
button31.setType(WxConsts.BUTTON_VIEW); | |||||
button31.setType(WxConsts.MenuButtonType.VIEW); | |||||
button31.setName("搜索"); | button31.setName("搜索"); | ||||
button31.setUrl("http://www.soso.com/"); | button31.setUrl("http://www.soso.com/"); | ||||
WxMenuButton button32 = new WxMenuButton(); | WxMenuButton button32 = new WxMenuButton(); | ||||
button32.setType(WxConsts.BUTTON_VIEW); | |||||
button32.setType(WxConsts.MenuButtonType.VIEW); | |||||
button32.setName("视频"); | button32.setName("视频"); | ||||
button32.setUrl("http://v.qq.com/"); | button32.setUrl("http://v.qq.com/"); | ||||
WxMenuButton button33 = new WxMenuButton(); | WxMenuButton button33 = new WxMenuButton(); | ||||
button33.setType(WxConsts.BUTTON_CLICK); | |||||
button33.setType(WxConsts.MenuButtonType.CLICK); | |||||
button33.setName("赞一下我们"); | button33.setName("赞一下我们"); | ||||
button33.setKey("V1001_GOOD"); | button33.setKey("V1001_GOOD"); | ||||
@@ -58,7 +58,7 @@ public class WxCpXmlMessageTest { | |||||
assertEquals(wxMessage.getToUserName(), "toUser"); | assertEquals(wxMessage.getToUserName(), "toUser"); | ||||
assertEquals(wxMessage.getFromUserName(), "fromUser"); | assertEquals(wxMessage.getFromUserName(), "fromUser"); | ||||
assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); | assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); | ||||
assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); | |||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | |||||
assertEquals(wxMessage.getContent(), "this is a test"); | assertEquals(wxMessage.getContent(), "this is a test"); | ||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); | assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); | ||||
assertEquals(wxMessage.getPicUrl(), "this is a url"); | assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
@@ -108,7 +108,7 @@ public class WxCpXmlMessageTest { | |||||
assertEquals(wxMessage.getToUserName(), "wx45a0972125658be9"); | assertEquals(wxMessage.getToUserName(), "wx45a0972125658be9"); | ||||
assertEquals(wxMessage.getFromUserName(), "xiaohe"); | assertEquals(wxMessage.getFromUserName(), "xiaohe"); | ||||
assertEquals(wxMessage.getCreateTime(), new Long(1502012364L)); | assertEquals(wxMessage.getCreateTime(), new Long(1502012364L)); | ||||
assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_EVENT); | |||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); | |||||
assertEquals(wxMessage.getAgentId(), Integer.valueOf(1000004)); | assertEquals(wxMessage.getAgentId(), Integer.valueOf(1000004)); | ||||
assertEquals(wxMessage.getEvent(), "pic_weixin"); | assertEquals(wxMessage.getEvent(), "pic_weixin"); | ||||
assertEquals(wxMessage.getEventKey(), "faceSimilarity"); | assertEquals(wxMessage.getEventKey(), "faceSimilarity"); | ||||
@@ -31,7 +31,7 @@ public class WxMaMsgServiceImplTest { | |||||
TestConfig configStorage = (TestConfig) this.wxService | TestConfig configStorage = (TestConfig) this.wxService | ||||
.getWxMaConfig(); | .getWxMaConfig(); | ||||
WxMaKefuMessage message = new WxMaKefuMessage(); | WxMaKefuMessage message = new WxMaKefuMessage(); | ||||
message.setMsgType(WxConsts.CUSTOM_MSG_MPNEWS); | |||||
message.setMsgType(WxConsts.KefuMsgType.MPNEWS); | |||||
message.setToUser(configStorage.getOpenid()); | message.setToUser(configStorage.getOpenid()); | ||||
this.wxService.getMsgService().sendKefuMsg(message); | this.wxService.getMsgService().sendKefuMsg(message); | ||||
@@ -41,7 +41,7 @@ public class WxMaMsgServiceImplTest { | |||||
TestConfig config = (TestConfig) this.wxService | TestConfig config = (TestConfig) this.wxService | ||||
.getWxMaConfig(); | .getWxMaConfig(); | ||||
WxMaKefuMessage message = new WxMaKefuMessage(); | WxMaKefuMessage message = new WxMaKefuMessage(); | ||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||||
message.setMsgType(WxConsts.KefuMsgType.TEXT); | |||||
message.setToUser(config.getOpenid()); | message.setToUser(config.getOpenid()); | ||||
message.setContent( | message.setContent( | ||||
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | "欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
@@ -13,7 +13,7 @@ public class WxMaKefuMessageTest { | |||||
public void testTextReply() { | public void testTextReply() { | ||||
WxMaKefuMessage reply = new WxMaKefuMessage(); | WxMaKefuMessage reply = new WxMaKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||||
reply.setMsgType(WxConsts.KefuMsgType.TEXT); | |||||
reply.setContent("sfsfdsdf"); | reply.setContent("sfsfdsdf"); | ||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); | Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); | ||||
} | } | ||||
@@ -26,7 +26,7 @@ public class WxMaKefuMessageTest { | |||||
public void testImageReply() { | public void testImageReply() { | ||||
WxMaKefuMessage reply = new WxMaKefuMessage(); | WxMaKefuMessage reply = new WxMaKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); | |||||
reply.setMsgType(WxConsts.KefuMsgType.IMAGE); | |||||
reply.setMediaId("MEDIA_ID"); | reply.setMediaId("MEDIA_ID"); | ||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); | Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); | ||||
} | } | ||||
@@ -60,7 +60,7 @@ public class WxMaMessageTest { | |||||
assertEquals(wxMessage.getToUser(), "toUser"); | assertEquals(wxMessage.getToUser(), "toUser"); | ||||
assertEquals(wxMessage.getFromUser(), "fromUser"); | assertEquals(wxMessage.getFromUser(), "fromUser"); | ||||
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | ||||
assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); | |||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | |||||
assertEquals(wxMessage.getContent(), "this is a test"); | assertEquals(wxMessage.getContent(), "this is a test"); | ||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | ||||
assertEquals(wxMessage.getPicUrl(), "this is a url"); | assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
@@ -118,7 +118,7 @@ public class WxMaMessageTest { | |||||
assertEquals(wxMessage.getToUser(), "toUser"); | assertEquals(wxMessage.getToUser(), "toUser"); | ||||
assertEquals(wxMessage.getFromUser(), "fromUser"); | assertEquals(wxMessage.getFromUser(), "fromUser"); | ||||
assertEquals(wxMessage.getCreateTime(), new Integer(1348831860)); | assertEquals(wxMessage.getCreateTime(), new Integer(1348831860)); | ||||
assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); | |||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | |||||
assertEquals(wxMessage.getContent(), "this is a test"); | assertEquals(wxMessage.getContent(), "this is a test"); | ||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | ||||
assertEquals(wxMessage.getPicUrl(), "this is a url"); | assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
@@ -121,7 +121,7 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService { | |||||
@Override | @Override | ||||
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException { | public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException { | ||||
Map<String, Object> params = new HashMap<>(); | Map<String, Object> params = new HashMap<>(); | ||||
params.put("type", WxConsts.MATERIAL_NEWS); | |||||
params.put("type", WxConsts.MaterialType.NEWS); | |||||
params.put("offset", offset); | params.put("offset", offset); | ||||
params.put("count", count); | params.put("count", count); | ||||
String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); | String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); | ||||
@@ -1,6 +1,7 @@ | |||||
package me.chanjar.weixin.mp.bean; | package me.chanjar.weixin.mp.bean; | ||||
import lombok.Data; | import lombok.Data; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
@@ -24,11 +25,11 @@ public class WxMpMassOpenIdsMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 请使用 | * 请使用 | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} | |||||
* {@link WxConsts.MassMsgType#IMAGE} | |||||
* {@link WxConsts.MassMsgType#MPNEWS} | |||||
* {@link WxConsts.MassMsgType#TEXT} | |||||
* {@link WxConsts.MassMsgType#MPVIDEO} | |||||
* {@link WxConsts.MassMsgType#VOICE} | |||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | ||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
@@ -1,6 +1,7 @@ | |||||
package me.chanjar.weixin.mp.bean; | package me.chanjar.weixin.mp.bean; | ||||
import lombok.Data; | import lombok.Data; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
@@ -18,11 +19,11 @@ public class WxMpMassPreviewMessage implements Serializable { | |||||
* <pre> | * <pre> | ||||
* 消息类型 | * 消息类型 | ||||
* 请使用 | * 请使用 | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} | |||||
* {@link WxConsts.MassMsgType#IMAGE} | |||||
* {@link WxConsts.MassMsgType#MPNEWS} | |||||
* {@link WxConsts.MassMsgType#TEXT} | |||||
* {@link WxConsts.MassMsgType#MPVIDEO} | |||||
* {@link WxConsts.MassMsgType#VOICE} | |||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | ||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
@@ -1,6 +1,7 @@ | |||||
package me.chanjar.weixin.mp.bean; | package me.chanjar.weixin.mp.bean; | ||||
import lombok.Data; | import lombok.Data; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
@@ -22,11 +23,11 @@ public class WxMpMassTagMessage implements Serializable { | |||||
* <pre> | * <pre> | ||||
* 消息类型 | * 消息类型 | ||||
* 请使用 | * 请使用 | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} | |||||
* {@link WxConsts.MassMsgType#IMAGE} | |||||
* {@link WxConsts.MassMsgType#MPNEWS} | |||||
* {@link WxConsts.MassMsgType#TEXT} | |||||
* {@link WxConsts.MassMsgType#MPVIDEO} | |||||
* {@link WxConsts.MassMsgType#VOICE} | |||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | ||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
@@ -1,6 +1,7 @@ | |||||
package me.chanjar.weixin.mp.bean.kefu; | package me.chanjar.weixin.mp.bean.kefu; | ||||
import lombok.Data; | import lombok.Data; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.mp.builder.kefu.*; | import me.chanjar.weixin.mp.builder.kefu.*; | ||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
@@ -90,14 +91,14 @@ public class WxMpKefuMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 请使用 | * 请使用 | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MPNEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_WXCARD} | |||||
* {@link WxConsts.KefuMsgType#TEXT} | |||||
* {@link WxConsts.KefuMsgType#IMAGE} | |||||
* {@link WxConsts.KefuMsgType#VOICE} | |||||
* {@link WxConsts.KefuMsgType#MUSIC} | |||||
* {@link WxConsts.KefuMsgType#VIDEO} | |||||
* {@link WxConsts.KefuMsgType#NEWS} | |||||
* {@link WxConsts.KefuMsgType#MPNEWS} | |||||
* {@link WxConsts.KefuMsgType#WXCARD} | |||||
* </pre> | * </pre> | ||||
* | * | ||||
*/ | */ | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.bean.message; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import com.thoughtworks.xstream.annotations.XStreamConverter; | import com.thoughtworks.xstream.annotations.XStreamConverter; | ||||
import lombok.Data; | import lombok.Data; | ||||
import me.chanjar.weixin.common.api.WxConsts; | |||||
import me.chanjar.weixin.common.util.ToStringUtils; | import me.chanjar.weixin.common.util.ToStringUtils; | ||||
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; | import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; | ||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage; | import me.chanjar.weixin.mp.api.WxMpConfigStorage; | ||||
@@ -467,13 +468,13 @@ public class WxMpXmlMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 当接受用户消息时,可能会获得以下值: | * 当接受用户消息时,可能会获得以下值: | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT} | |||||
* {@link WxConsts.XmlMsgType#TEXT} | |||||
* {@link WxConsts.XmlMsgType#IMAGE} | |||||
* {@link WxConsts.XmlMsgType#VOICE} | |||||
* {@link WxConsts.XmlMsgType#VIDEO} | |||||
* {@link WxConsts.XmlMsgType#LOCATION} | |||||
* {@link WxConsts.XmlMsgType#LINK} | |||||
* {@link WxConsts.XmlMsgType#EVENT} | |||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
public String getMsgType() { | public String getMsgType() { | ||||
@@ -483,12 +484,12 @@ public class WxMpXmlMessage implements Serializable { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 当发送消息的时候使用: | * 当发送消息的时候使用: | ||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS} | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_MUSIC} | |||||
* {@link WxConsts.XmlMsgType#TEXT} | |||||
* {@link WxConsts.XmlMsgType#IMAGE} | |||||
* {@link WxConsts.XmlMsgType#VOICE} | |||||
* {@link WxConsts.XmlMsgType#VIDEO} | |||||
* {@link WxConsts.XmlMsgType#NEWS} | |||||
* {@link WxConsts.XmlMsgType#MUSIC} | |||||
* </pre> | * </pre> | ||||
* | * | ||||
*/ | */ | ||||
@@ -16,7 +16,7 @@ public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage { | |||||
private String mediaId; | private String mediaId; | ||||
public WxMpXmlOutImageMessage() { | public WxMpXmlOutImageMessage() { | ||||
this.msgType = WxConsts.XML_MSG_IMAGE; | |||||
this.msgType = WxConsts.XmlMsgType.IMAGE; | |||||
} | } | ||||
} | } |
@@ -19,7 +19,7 @@ public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage { | |||||
protected final Music music = new Music(); | protected final Music music = new Music(); | ||||
public WxMpXmlOutMusicMessage() { | public WxMpXmlOutMusicMessage() { | ||||
this.msgType = WxConsts.XML_MSG_MUSIC; | |||||
this.msgType = WxConsts.XmlMsgType.MUSIC; | |||||
} | } | ||||
@XStreamAlias("Music") | @XStreamAlias("Music") | ||||
@@ -21,7 +21,7 @@ public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage { | |||||
protected int articleCount; | protected int articleCount; | ||||
public WxMpXmlOutNewsMessage() { | public WxMpXmlOutNewsMessage() { | ||||
this.msgType = WxConsts.XML_MSG_NEWS; | |||||
this.msgType = WxConsts.XmlMsgType.NEWS; | |||||
} | } | ||||
public void addArticle(Item item) { | public void addArticle(Item item) { | ||||
@@ -16,7 +16,7 @@ public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage { | |||||
private String content; | private String content; | ||||
public WxMpXmlOutTextMessage() { | public WxMpXmlOutTextMessage() { | ||||
this.msgType = WxConsts.XML_MSG_TEXT; | |||||
this.msgType = WxConsts.XmlMsgType.TEXT; | |||||
} | } | ||||
} | } |
@@ -17,7 +17,7 @@ public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage { | |||||
protected TransInfo transInfo; | protected TransInfo transInfo; | ||||
public WxMpXmlOutTransferKefuMessage() { | public WxMpXmlOutTransferKefuMessage() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE; | |||||
this.msgType = WxConsts.KefuMsgType.TRANSFER_CUSTOMER_SERVICE; | |||||
} | } | ||||
@XStreamAlias("TransInfo") | @XStreamAlias("TransInfo") | ||||
@@ -19,7 +19,7 @@ public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage { | |||||
protected final Video video = new Video(); | protected final Video video = new Video(); | ||||
public WxMpXmlOutVideoMessage() { | public WxMpXmlOutVideoMessage() { | ||||
this.msgType = WxConsts.XML_MSG_VIDEO; | |||||
this.msgType = WxConsts.XmlMsgType.VIDEO; | |||||
} | } | ||||
@XStreamAlias("Video") | @XStreamAlias("Video") | ||||
@@ -16,7 +16,7 @@ public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage { | |||||
private String mediaId; | private String mediaId; | ||||
public WxMpXmlOutVoiceMessage() { | public WxMpXmlOutVoiceMessage() { | ||||
this.msgType = WxConsts.XML_MSG_VOICE; | |||||
this.msgType = WxConsts.XmlMsgType.VOICE; | |||||
} | } | ||||
} | } |
@@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public ImageBuilder() { | public ImageBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_IMAGE; | |||||
this.msgType = WxConsts.KefuMsgType.IMAGE; | |||||
} | } | ||||
public ImageBuilder mediaId(String media_id) { | public ImageBuilder mediaId(String media_id) { | ||||
@@ -16,7 +16,7 @@ public final class MpNewsBuilder extends BaseBuilder<MpNewsBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public MpNewsBuilder() { | public MpNewsBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_MPNEWS; | |||||
this.msgType = WxConsts.KefuMsgType.MPNEWS; | |||||
} | } | ||||
public MpNewsBuilder mediaId(String mediaId) { | public MpNewsBuilder mediaId(String mediaId) { | ||||
@@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> { | |||||
private String hqMusicUrl; | private String hqMusicUrl; | ||||
public MusicBuilder() { | public MusicBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_MUSIC; | |||||
this.msgType = WxConsts.KefuMsgType.MUSIC; | |||||
} | } | ||||
public MusicBuilder musicUrl(String musicurl) { | public MusicBuilder musicUrl(String musicurl) { | ||||
@@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> { | |||||
private List<WxMpKefuMessage.WxArticle> articles = new ArrayList<>(); | private List<WxMpKefuMessage.WxArticle> articles = new ArrayList<>(); | ||||
public NewsBuilder() { | public NewsBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_NEWS; | |||||
this.msgType = WxConsts.KefuMsgType.NEWS; | |||||
} | } | ||||
public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) { | public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) { | ||||
@@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> { | |||||
private String content; | private String content; | ||||
public TextBuilder() { | public TextBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_TEXT; | |||||
this.msgType = WxConsts.KefuMsgType.TEXT; | |||||
} | } | ||||
public TextBuilder content(String content) { | public TextBuilder content(String content) { | ||||
@@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> { | |||||
private String thumbMediaId; | private String thumbMediaId; | ||||
public VideoBuilder() { | public VideoBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_VIDEO; | |||||
this.msgType = WxConsts.KefuMsgType.VIDEO; | |||||
} | } | ||||
public VideoBuilder mediaId(String mediaId) { | public VideoBuilder mediaId(String mediaId) { | ||||
@@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> { | |||||
private String mediaId; | private String mediaId; | ||||
public VoiceBuilder() { | public VoiceBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_VOICE; | |||||
this.msgType = WxConsts.KefuMsgType.VOICE; | |||||
} | } | ||||
public VoiceBuilder mediaId(String media_id) { | public VoiceBuilder mediaId(String media_id) { | ||||
@@ -15,7 +15,7 @@ public final class WxCardBuilder extends BaseBuilder<WxCardBuilder> { | |||||
private String cardId; | private String cardId; | ||||
public WxCardBuilder() { | public WxCardBuilder() { | ||||
this.msgType = WxConsts.CUSTOM_MSG_WXCARD; | |||||
this.msgType = WxConsts.KefuMsgType.WXCARD; | |||||
} | } | ||||
public WxCardBuilder cardId(String cardId) { | public WxCardBuilder cardId(String cardId) { | ||||
@@ -23,25 +23,25 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag | |||||
messageJson.addProperty("touser", message.getToUser()); | messageJson.addProperty("touser", message.getToUser()); | ||||
messageJson.addProperty("msgtype", message.getMsgType()); | messageJson.addProperty("msgtype", message.getMsgType()); | ||||
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.TEXT.equals(message.getMsgType())) { | |||||
JsonObject text = new JsonObject(); | JsonObject text = new JsonObject(); | ||||
text.addProperty("content", message.getContent()); | text.addProperty("content", message.getContent()); | ||||
messageJson.add("text", text); | messageJson.add("text", text); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.IMAGE.equals(message.getMsgType())) { | |||||
JsonObject image = new JsonObject(); | JsonObject image = new JsonObject(); | ||||
image.addProperty("media_id", message.getMediaId()); | image.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add("image", image); | messageJson.add("image", image); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.VOICE.equals(message.getMsgType())) { | |||||
JsonObject voice = new JsonObject(); | JsonObject voice = new JsonObject(); | ||||
voice.addProperty("media_id", message.getMediaId()); | voice.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add("voice", voice); | messageJson.add("voice", voice); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.VIDEO.equals(message.getMsgType())) { | |||||
JsonObject video = new JsonObject(); | JsonObject video = new JsonObject(); | ||||
video.addProperty("media_id", message.getMediaId()); | video.addProperty("media_id", message.getMediaId()); | ||||
video.addProperty("thumb_media_id", message.getThumbMediaId()); | video.addProperty("thumb_media_id", message.getThumbMediaId()); | ||||
@@ -50,7 +50,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag | |||||
messageJson.add("video", video); | messageJson.add("video", video); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.MUSIC.equals(message.getMsgType())) { | |||||
JsonObject music = new JsonObject(); | JsonObject music = new JsonObject(); | ||||
music.addProperty("title", message.getTitle()); | music.addProperty("title", message.getTitle()); | ||||
music.addProperty("description", message.getDescription()); | music.addProperty("description", message.getDescription()); | ||||
@@ -60,7 +60,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag | |||||
messageJson.add("music", music); | messageJson.add("music", music); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.NEWS.equals(message.getMsgType())) { | |||||
JsonObject newsJsonObject = new JsonObject(); | JsonObject newsJsonObject = new JsonObject(); | ||||
JsonArray articleJsonArray = new JsonArray(); | JsonArray articleJsonArray = new JsonArray(); | ||||
for (WxMpKefuMessage.WxArticle article : message.getArticles()) { | for (WxMpKefuMessage.WxArticle article : message.getArticles()) { | ||||
@@ -75,13 +75,13 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag | |||||
messageJson.add("news", newsJsonObject); | messageJson.add("news", newsJsonObject); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_MPNEWS.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.MPNEWS.equals(message.getMsgType())) { | |||||
JsonObject json = new JsonObject(); | JsonObject json = new JsonObject(); | ||||
json.addProperty("media_id", message.getMpNewsMediaId()); | json.addProperty("media_id", message.getMpNewsMediaId()); | ||||
messageJson.add("mpnews", json); | messageJson.add("mpnews", json); | ||||
} | } | ||||
if (WxConsts.CUSTOM_MSG_WXCARD.equals(message.getMsgType())) { | |||||
if (WxConsts.KefuMsgType.WXCARD.equals(message.getMsgType())) { | |||||
JsonObject wxcard = new JsonObject(); | JsonObject wxcard = new JsonObject(); | ||||
wxcard.addProperty("card_id", message.getCardId()); | wxcard.addProperty("card_id", message.getCardId()); | ||||
messageJson.add("wxcard", wxcard); | messageJson.add("wxcard", wxcard); | ||||
@@ -26,30 +26,30 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas | |||||
} | } | ||||
messageJson.add("touser", toUsers); | messageJson.add("touser", toUsers); | ||||
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.MPNEWS.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_NEWS, sub); | |||||
messageJson.add(WxConsts.MassMsgType.MPNEWS, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.TEXT.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("content", message.getContent()); | sub.addProperty("content", message.getContent()); | ||||
messageJson.add(WxConsts.MASS_MSG_TEXT, sub); | |||||
messageJson.add(WxConsts.MassMsgType.TEXT, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.VOICE.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_VOICE, sub); | |||||
messageJson.add(WxConsts.MassMsgType.VOICE, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); | |||||
messageJson.add(WxConsts.MassMsgType.IMAGE, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); | |||||
messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub); | |||||
} | } | ||||
messageJson.addProperty("msgtype", message.getMsgType()); | messageJson.addProperty("msgtype", message.getMsgType()); | ||||
messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1); | messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1); | ||||
@@ -18,30 +18,30 @@ public class WxMpMassPreviewMessageGsonAdapter implements JsonSerializer<WxMpMas | |||||
JsonObject jsonObject = new JsonObject(); | JsonObject jsonObject = new JsonObject(); | ||||
jsonObject.addProperty("towxname", wxMpMassPreviewMessage.getToWxUserName()); | jsonObject.addProperty("towxname", wxMpMassPreviewMessage.getToWxUserName()); | ||||
jsonObject.addProperty("touser", wxMpMassPreviewMessage.getToWxUserOpenid()); | jsonObject.addProperty("touser", wxMpMassPreviewMessage.getToWxUserOpenid()); | ||||
if (WxConsts.MASS_MSG_NEWS.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
if (WxConsts.MassMsgType.MPNEWS.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
JsonObject news = new JsonObject(); | JsonObject news = new JsonObject(); | ||||
news.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | news.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | ||||
jsonObject.add(WxConsts.MASS_MSG_NEWS, news); | |||||
jsonObject.add(WxConsts.MassMsgType.MPNEWS, news); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_TEXT.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
if (WxConsts.MassMsgType.TEXT.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("content", wxMpMassPreviewMessage.getContent()); | sub.addProperty("content", wxMpMassPreviewMessage.getContent()); | ||||
jsonObject.add(WxConsts.MASS_MSG_TEXT, sub); | |||||
jsonObject.add(WxConsts.MassMsgType.TEXT, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_VOICE.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
if (WxConsts.MassMsgType.VOICE.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | ||||
jsonObject.add(WxConsts.MASS_MSG_VOICE, sub); | |||||
jsonObject.add(WxConsts.MassMsgType.VOICE, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_IMAGE.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
if (WxConsts.MassMsgType.IMAGE.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | ||||
jsonObject.add(WxConsts.MASS_MSG_IMAGE, sub); | |||||
jsonObject.add(WxConsts.MassMsgType.IMAGE, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_VIDEO.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
if (WxConsts.MassMsgType.MPVIDEO.equals(wxMpMassPreviewMessage.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); | ||||
jsonObject.add(WxConsts.MASS_MSG_VIDEO, sub); | |||||
jsonObject.add(WxConsts.MassMsgType.MPVIDEO, sub); | |||||
} | } | ||||
jsonObject.addProperty("msgtype", wxMpMassPreviewMessage.getMsgType()); | jsonObject.addProperty("msgtype", wxMpMassPreviewMessage.getMsgType()); | ||||
return jsonObject; | return jsonObject; | ||||
@@ -32,30 +32,30 @@ public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTag | |||||
} | } | ||||
messageJson.add("filter", filter); | messageJson.add("filter", filter); | ||||
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.MPNEWS.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_NEWS, sub); | |||||
messageJson.add(WxConsts.MassMsgType.MPNEWS, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.TEXT.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("content", message.getContent()); | sub.addProperty("content", message.getContent()); | ||||
messageJson.add(WxConsts.MASS_MSG_TEXT, sub); | |||||
messageJson.add(WxConsts.MassMsgType.TEXT, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.VOICE.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_VOICE, sub); | |||||
messageJson.add(WxConsts.MassMsgType.VOICE, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); | |||||
messageJson.add(WxConsts.MassMsgType.IMAGE, sub); | |||||
} | } | ||||
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { | |||||
if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) { | |||||
JsonObject sub = new JsonObject(); | JsonObject sub = new JsonObject(); | ||||
sub.addProperty("media_id", message.getMediaId()); | sub.addProperty("media_id", message.getMediaId()); | ||||
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); | |||||
messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub); | |||||
} | } | ||||
messageJson.addProperty("msgtype", message.getMsgType()); | messageJson.addProperty("msgtype", message.getMsgType()); | ||||
messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1); | messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1); | ||||
@@ -23,21 +23,21 @@ public class WxMpMessageRouterTest { | |||||
router | router | ||||
.rule() | .rule() | ||||
.async(async) | .async(async) | ||||
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") | |||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1") | |||||
.handler(new WxEchoMpMessageHandler(sb, "COMBINE_4")) | .handler(new WxEchoMpMessageHandler(sb, "COMBINE_4")) | ||||
.end() | .end() | ||||
.rule() | .rule() | ||||
.async(async) | .async(async) | ||||
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") | |||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1") | |||||
.handler(new WxEchoMpMessageHandler(sb, "COMBINE_3")) | .handler(new WxEchoMpMessageHandler(sb, "COMBINE_3")) | ||||
.end() | .end() | ||||
.rule() | .rule() | ||||
.async(async) | .async(async) | ||||
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) | |||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK) | |||||
.handler(new WxEchoMpMessageHandler(sb, "COMBINE_2")) | .handler(new WxEchoMpMessageHandler(sb, "COMBINE_2")) | ||||
.end() | .end() | ||||
.rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() | |||||
.rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EVT_CLICK)).end() | |||||
.rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end() | |||||
.rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EventType.CLICK)).end() | |||||
.rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end() | .rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end() | ||||
.rule().async(async).eventKeyRegex("KEY_1*").handler(new WxEchoMpMessageHandler(sb, "KEY_123")).end() | .rule().async(async).eventKeyRegex("KEY_1*").handler(new WxEchoMpMessageHandler(sb, "KEY_123")).end() | ||||
.rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end() | .rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end() | ||||
@@ -101,10 +101,10 @@ public class WxMpMessageRouterTest { | |||||
@DataProvider(name = "messages-1") | @DataProvider(name = "messages-1") | ||||
public Object[][] messages2() { | public Object[][] messages2() { | ||||
WxMpXmlMessage message1 = new WxMpXmlMessage(); | WxMpXmlMessage message1 = new WxMpXmlMessage(); | ||||
message1.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
message1.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
WxMpXmlMessage message2 = new WxMpXmlMessage(); | WxMpXmlMessage message2 = new WxMpXmlMessage(); | ||||
message2.setEvent(WxConsts.EVT_CLICK); | |||||
message2.setEvent(WxConsts.EventType.CLICK); | |||||
WxMpXmlMessage message3 = new WxMpXmlMessage(); | WxMpXmlMessage message3 = new WxMpXmlMessage(); | ||||
message3.setEventKey("KEY_1"); | message3.setEventKey("KEY_1"); | ||||
@@ -122,23 +122,23 @@ public class WxMpMessageRouterTest { | |||||
message7.setFormat("strangeformat"); | message7.setFormat("strangeformat"); | ||||
WxMpXmlMessage c2 = new WxMpXmlMessage(); | WxMpXmlMessage c2 = new WxMpXmlMessage(); | ||||
c2.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
c2.setEvent(WxConsts.EVT_CLICK); | |||||
c2.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
c2.setEvent(WxConsts.EventType.CLICK); | |||||
WxMpXmlMessage c3 = new WxMpXmlMessage(); | WxMpXmlMessage c3 = new WxMpXmlMessage(); | ||||
c3.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
c3.setEvent(WxConsts.EVT_CLICK); | |||||
c3.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
c3.setEvent(WxConsts.EventType.CLICK); | |||||
c3.setEventKey("KEY_1"); | c3.setEventKey("KEY_1"); | ||||
WxMpXmlMessage c4 = new WxMpXmlMessage(); | WxMpXmlMessage c4 = new WxMpXmlMessage(); | ||||
c4.setMsgType(WxConsts.XML_MSG_TEXT); | |||||
c4.setEvent(WxConsts.EVT_CLICK); | |||||
c4.setMsgType(WxConsts.XmlMsgType.TEXT); | |||||
c4.setEvent(WxConsts.EventType.CLICK); | |||||
c4.setEventKey("KEY_1"); | c4.setEventKey("KEY_1"); | ||||
c4.setContent("CONTENT_1"); | c4.setContent("CONTENT_1"); | ||||
return new Object[][]{ | return new Object[][]{ | ||||
new Object[]{message1, WxConsts.XML_MSG_TEXT + ","}, | |||||
new Object[]{message2, WxConsts.EVT_CLICK + ","}, | |||||
new Object[]{message1, WxConsts.XmlMsgType.TEXT + ","}, | |||||
new Object[]{message2, WxConsts.EventType.CLICK + ","}, | |||||
new Object[]{message3, "KEY_1,"}, | new Object[]{message3, "KEY_1,"}, | ||||
new Object[]{message4, "CONTENT_1,"}, | new Object[]{message4, "CONTENT_1,"}, | ||||
new Object[]{message5, "ALL,"}, | new Object[]{message5, "ALL,"}, | ||||
@@ -32,7 +32,7 @@ public class WxMpKefuServiceImplTest { | |||||
TestConfigStorage configStorage = (TestConfigStorage) this.wxService | TestConfigStorage configStorage = (TestConfigStorage) this.wxService | ||||
.getWxMpConfigStorage(); | .getWxMpConfigStorage(); | ||||
WxMpKefuMessage message = new WxMpKefuMessage(); | WxMpKefuMessage message = new WxMpKefuMessage(); | ||||
message.setMsgType(WxConsts.CUSTOM_MSG_MPNEWS); | |||||
message.setMsgType(WxConsts.KefuMsgType.MPNEWS); | |||||
message.setToUser(configStorage.getOpenid()); | message.setToUser(configStorage.getOpenid()); | ||||
message.setMpNewsMediaId("52R6dL2FxDpM9N1rCY3sYBqHwq-L7K_lz1sPI71idMg"); | message.setMpNewsMediaId("52R6dL2FxDpM9N1rCY3sYBqHwq-L7K_lz1sPI71idMg"); | ||||
@@ -43,7 +43,7 @@ public class WxMpKefuServiceImplTest { | |||||
TestConfigStorage configStorage = (TestConfigStorage) this.wxService | TestConfigStorage configStorage = (TestConfigStorage) this.wxService | ||||
.getWxMpConfigStorage(); | .getWxMpConfigStorage(); | ||||
WxMpKefuMessage message = new WxMpKefuMessage(); | WxMpKefuMessage message = new WxMpKefuMessage(); | ||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||||
message.setMsgType(WxConsts.KefuMsgType.TEXT); | |||||
message.setToUser(configStorage.getOpenid()); | message.setToUser(configStorage.getOpenid()); | ||||
message.setContent( | message.setContent( | ||||
"欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | "欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
@@ -55,7 +55,7 @@ public class WxMpKefuServiceImplTest { | |||||
TestConfigStorage configStorage = (TestConfigStorage) this.wxService | TestConfigStorage configStorage = (TestConfigStorage) this.wxService | ||||
.getWxMpConfigStorage(); | .getWxMpConfigStorage(); | ||||
WxMpKefuMessage message = new WxMpKefuMessage(); | WxMpKefuMessage message = new WxMpKefuMessage(); | ||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||||
message.setMsgType(WxConsts.KefuMsgType.TEXT); | |||||
message.setToUser(configStorage.getOpenid()); | message.setToUser(configStorage.getOpenid()); | ||||
message.setKfAccount(configStorage.getKfAccount()); | message.setKfAccount(configStorage.getKfAccount()); | ||||
message.setContent( | message.setContent( | ||||
@@ -38,7 +38,7 @@ public class WxMpMassMessageServiceImplTest { | |||||
TestConfigStorage configProvider = (TestConfigStorage) this.wxService | TestConfigStorage configProvider = (TestConfigStorage) this.wxService | ||||
.getWxMpConfigStorage(); | .getWxMpConfigStorage(); | ||||
WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); | WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); | ||||
massMessage.setMsgType(WxConsts.MASS_MSG_TEXT); | |||||
massMessage.setMsgType(WxConsts.MassMsgType.TEXT); | |||||
massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
massMessage.getToUsers().add(configProvider.getOpenid()); | massMessage.getToUsers().add(configProvider.getOpenid()); | ||||
@@ -67,7 +67,7 @@ public class WxMpMassMessageServiceImplTest { | |||||
@Test | @Test | ||||
public void testTextMassGroupMessageSend() throws WxErrorException { | public void testTextMassGroupMessageSend() throws WxErrorException { | ||||
WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); | WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); | ||||
massMessage.setMsgType(WxConsts.MASS_MSG_TEXT); | |||||
massMessage.setMsgType(WxConsts.MassMsgType.TEXT); | |||||
massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>"); | ||||
massMessage | massMessage | ||||
.setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); | .setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); | ||||
@@ -103,7 +103,7 @@ public class WxMpMassMessageServiceImplTest { | |||||
.getSystemResourceAsStream("mm.mp4")) { | .getSystemResourceAsStream("mm.mp4")) { | ||||
// 上传视频到媒体库 | // 上传视频到媒体库 | ||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | ||||
.mediaUpload(WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, inputStream); | |||||
.mediaUpload(WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, inputStream); | |||||
assertNotNull(uploadMediaRes); | assertNotNull(uploadMediaRes); | ||||
assertNotNull(uploadMediaRes.getMediaId()); | assertNotNull(uploadMediaRes.getMediaId()); | ||||
@@ -115,7 +115,7 @@ public class WxMpMassMessageServiceImplTest { | |||||
WxMpMassUploadResult uploadResult = this.wxService.getMassMessageService().massVideoUpload(video); | WxMpMassUploadResult uploadResult = this.wxService.getMassMessageService().massVideoUpload(video); | ||||
assertNotNull(uploadResult); | assertNotNull(uploadResult); | ||||
assertNotNull(uploadResult.getMediaId()); | assertNotNull(uploadResult.getMediaId()); | ||||
messages[0] = new Object[]{WxConsts.MASS_MSG_VIDEO, uploadResult.getMediaId()}; | |||||
messages[0] = new Object[]{WxConsts.MassMsgType.MPVIDEO, uploadResult.getMediaId()}; | |||||
} | } | ||||
/* | /* | ||||
@@ -124,10 +124,10 @@ public class WxMpMassMessageServiceImplTest { | |||||
try (InputStream inputStream = ClassLoader | try (InputStream inputStream = ClassLoader | ||||
.getSystemResourceAsStream("mm.jpeg")) { | .getSystemResourceAsStream("mm.jpeg")) { | ||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | ||||
.mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream); | |||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream); | |||||
assertNotNull(uploadMediaRes); | assertNotNull(uploadMediaRes); | ||||
assertNotNull(uploadMediaRes.getMediaId()); | assertNotNull(uploadMediaRes.getMediaId()); | ||||
messages[1] = new Object[]{WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId()}; | |||||
messages[1] = new Object[]{WxConsts.MassMsgType.IMAGE, uploadMediaRes.getMediaId()}; | |||||
} | } | ||||
/* | /* | ||||
@@ -136,10 +136,10 @@ public class WxMpMassMessageServiceImplTest { | |||||
try (InputStream inputStream = ClassLoader | try (InputStream inputStream = ClassLoader | ||||
.getSystemResourceAsStream("mm.mp3")) { | .getSystemResourceAsStream("mm.mp3")) { | ||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | ||||
.mediaUpload(WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, inputStream); | |||||
.mediaUpload(WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, inputStream); | |||||
assertNotNull(uploadMediaRes); | assertNotNull(uploadMediaRes); | ||||
assertNotNull(uploadMediaRes.getMediaId()); | assertNotNull(uploadMediaRes.getMediaId()); | ||||
messages[2] = new Object[]{WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId()}; | |||||
messages[2] = new Object[]{WxConsts.MassMsgType.VOICE, uploadMediaRes.getMediaId()}; | |||||
} | } | ||||
/* | /* | ||||
@@ -149,7 +149,7 @@ public class WxMpMassMessageServiceImplTest { | |||||
.getSystemResourceAsStream("mm.jpeg")) { | .getSystemResourceAsStream("mm.jpeg")) { | ||||
// 上传照片到媒体库 | // 上传照片到媒体库 | ||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() | ||||
.mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream); | |||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream); | |||||
assertNotNull(uploadMediaRes); | assertNotNull(uploadMediaRes); | ||||
assertNotNull(uploadMediaRes.getMediaId()); | assertNotNull(uploadMediaRes.getMediaId()); | ||||
@@ -175,7 +175,7 @@ public class WxMpMassMessageServiceImplTest { | |||||
.massNewsUpload(news); | .massNewsUpload(news); | ||||
assertNotNull(massUploadResult); | assertNotNull(massUploadResult); | ||||
assertNotNull(uploadMediaRes.getMediaId()); | assertNotNull(uploadMediaRes.getMediaId()); | ||||
messages[3] = new Object[]{WxConsts.MASS_MSG_NEWS, massUploadResult.getMediaId()}; | |||||
messages[3] = new Object[]{WxConsts.MassMsgType.MPNEWS, massUploadResult.getMediaId()}; | |||||
} | } | ||||
return messages; | return messages; | ||||
@@ -48,10 +48,10 @@ public class WxMpMaterialServiceImplTest { | |||||
@DataProvider | @DataProvider | ||||
public Object[][] mediaFiles() { | public Object[][] mediaFiles() { | ||||
return new Object[][]{ | return new Object[][]{ | ||||
new Object[]{WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, | |||||
new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, "mm.mp3"}, | |||||
new Object[]{WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, | |||||
new Object[]{WxConsts.MEDIA_THUMB, TestConstants.FILE_JPG, "mm.jpeg"} | |||||
new Object[]{WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, | |||||
new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"}, | |||||
new Object[]{WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, | |||||
new Object[]{WxConsts.MediaFileType.THUMB, TestConstants.FILE_JPG, "mm.jpeg"} | |||||
}; | }; | ||||
} | } | ||||
@@ -69,7 +69,7 @@ public class WxMpMaterialServiceImplTest { | |||||
WxMpMaterial wxMaterial = new WxMpMaterial(); | WxMpMaterial wxMaterial = new WxMpMaterial(); | ||||
wxMaterial.setFile(tempFile); | wxMaterial.setFile(tempFile); | ||||
wxMaterial.setName(fileName); | wxMaterial.setName(fileName); | ||||
if (WxConsts.MEDIA_VIDEO.equals(mediaType)) { | |||||
if (WxConsts.MediaFileType.VIDEO.equals(mediaType)) { | |||||
wxMaterial.setVideoTitle("title"); | wxMaterial.setVideoTitle("title"); | ||||
wxMaterial.setVideoIntroduction("test video description"); | wxMaterial.setVideoIntroduction("test video description"); | ||||
} | } | ||||
@@ -78,12 +78,12 @@ public class WxMpMaterialServiceImplTest { | |||||
.materialFileUpload(mediaType, wxMaterial); | .materialFileUpload(mediaType, wxMaterial); | ||||
assertNotNull(res.getMediaId()); | assertNotNull(res.getMediaId()); | ||||
if (WxConsts.MEDIA_IMAGE.equals(mediaType) | |||||
|| WxConsts.MEDIA_THUMB.equals(mediaType)) { | |||||
if (WxConsts.MediaFileType.IMAGE.equals(mediaType) | |||||
|| WxConsts.MediaFileType.THUMB.equals(mediaType)) { | |||||
assertNotNull(res.getUrl()); | assertNotNull(res.getUrl()); | ||||
} | } | ||||
if (WxConsts.MEDIA_THUMB.equals(mediaType)) { | |||||
if (WxConsts.MediaFileType.THUMB.equals(mediaType)) { | |||||
this.thumbMediaId = res.getMediaId(); | this.thumbMediaId = res.getMediaId(); | ||||
} | } | ||||
@@ -233,9 +233,9 @@ public class WxMpMaterialServiceImplTest { | |||||
@Test//(dependsOnMethods = {"testMaterialNewsList"}) | @Test//(dependsOnMethods = {"testMaterialNewsList"}) | ||||
public void testMaterialFileList() throws WxErrorException { | public void testMaterialFileList() throws WxErrorException { | ||||
WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_VOICE, 0, 20); | |||||
WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_VIDEO, 0, 20); | |||||
WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_IMAGE, 0, 20); | |||||
WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VOICE, 0, 20); | |||||
WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VIDEO, 0, 20); | |||||
WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.IMAGE, 0, 20); | |||||
assertNotNull(wxMpMaterialVoiceBatchGetResult); | assertNotNull(wxMpMaterialVoiceBatchGetResult); | ||||
assertNotNull(wxMpMaterialVideoBatchGetResult); | assertNotNull(wxMpMaterialVideoBatchGetResult); | ||||
assertNotNull(wxMpMaterialImageBatchGetResult); | assertNotNull(wxMpMaterialImageBatchGetResult); | ||||
@@ -277,7 +277,7 @@ public class WxMpMaterialServiceImplTest { | |||||
assertNotNull(res.getCreatedAt()); | assertNotNull(res.getCreatedAt()); | ||||
assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null); | assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null); | ||||
if (res.getMediaId() != null && !mediaType.equals(WxConsts.MEDIA_VIDEO)) { | |||||
if (res.getMediaId() != null && !mediaType.equals(WxConsts.MediaFileType.VIDEO)) { | |||||
//video 不支持下载,所以不加入 | //video 不支持下载,所以不加入 | ||||
this.mediaIdsToDownload.add(res.getMediaId()); | this.mediaIdsToDownload.add(res.getMediaId()); | ||||
} | } | ||||
@@ -156,12 +156,12 @@ public class WxMpMenuServiceImplTest { | |||||
public Object[][] getMenu() { | public Object[][] getMenu() { | ||||
WxMenu menu = new WxMenu(); | WxMenu menu = new WxMenu(); | ||||
WxMenuButton button1 = new WxMenuButton(); | WxMenuButton button1 = new WxMenuButton(); | ||||
button1.setType(WxConsts.BUTTON_CLICK); | |||||
button1.setType(WxConsts.MenuButtonType.CLICK); | |||||
button1.setName("今日歌曲"); | button1.setName("今日歌曲"); | ||||
button1.setKey("V1001_TODAY_MUSIC"); | button1.setKey("V1001_TODAY_MUSIC"); | ||||
// WxMenuButton button2 = new WxMenuButton(); | // WxMenuButton button2 = new WxMenuButton(); | ||||
// button2.setType(WxConsts.BUTTON_MINIPROGRAM); | |||||
// button2.setType(WxConsts.MenuButtonType.MINIPROGRAM); | |||||
// button2.setName("小程序"); | // button2.setName("小程序"); | ||||
// button2.setAppId("wx286b93c14bbf93aa"); | // button2.setAppId("wx286b93c14bbf93aa"); | ||||
// button2.setPagePath("pages/lunar/index.html"); | // button2.setPagePath("pages/lunar/index.html"); | ||||
@@ -175,17 +175,17 @@ public class WxMpMenuServiceImplTest { | |||||
menu.getButtons().add(button3); | menu.getButtons().add(button3); | ||||
WxMenuButton button31 = new WxMenuButton(); | WxMenuButton button31 = new WxMenuButton(); | ||||
button31.setType(WxConsts.BUTTON_VIEW); | |||||
button31.setType(WxConsts.MenuButtonType.VIEW); | |||||
button31.setName("搜索"); | button31.setName("搜索"); | ||||
button31.setUrl("http://www.soso.com/"); | button31.setUrl("http://www.soso.com/"); | ||||
WxMenuButton button32 = new WxMenuButton(); | WxMenuButton button32 = new WxMenuButton(); | ||||
button32.setType(WxConsts.BUTTON_VIEW); | |||||
button32.setType(WxConsts.MenuButtonType.VIEW); | |||||
button32.setName("视频"); | button32.setName("视频"); | ||||
button32.setUrl("http://v.qq.com/"); | button32.setUrl("http://v.qq.com/"); | ||||
WxMenuButton button33 = new WxMenuButton(); | WxMenuButton button33 = new WxMenuButton(); | ||||
button33.setType(WxConsts.BUTTON_CLICK); | |||||
button33.setType(WxConsts.MenuButtonType.CLICK); | |||||
button33.setName("赞一下我们"); | button33.setName("赞一下我们"); | ||||
button33.setKey("V1001_GOOD"); | button33.setKey("V1001_GOOD"); | ||||
@@ -116,7 +116,7 @@ public class WxMpServiceImplTest { | |||||
public void testBuildQrConnectUrl() { | public void testBuildQrConnectUrl() { | ||||
String qrconnectRedirectUrl = ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl(); | String qrconnectRedirectUrl = ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl(); | ||||
String qrConnectUrl = this.wxService.buildQrConnectUrl(qrconnectRedirectUrl, | String qrConnectUrl = this.wxService.buildQrConnectUrl(qrconnectRedirectUrl, | ||||
WxConsts.QRCONNECT_SCOPE_SNSAPI_LOGIN, null); | |||||
WxConsts.QrConnectScope.SNSAPI_LOGIN, null); | |||||
Assert.assertNotNull(qrConnectUrl); | Assert.assertNotNull(qrConnectUrl); | ||||
System.out.println(qrConnectUrl); | System.out.println(qrConnectUrl); | ||||
} | } | ||||
@@ -11,7 +11,7 @@ public class WxMpKefuMessageTest { | |||||
public void testTextReply() { | public void testTextReply() { | ||||
WxMpKefuMessage reply = new WxMpKefuMessage(); | WxMpKefuMessage reply = new WxMpKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); | |||||
reply.setMsgType(WxConsts.KefuMsgType.TEXT); | |||||
reply.setContent("sfsfdsdf"); | reply.setContent("sfsfdsdf"); | ||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); | Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); | ||||
} | } | ||||
@@ -24,7 +24,7 @@ public class WxMpKefuMessageTest { | |||||
public void testImageReply() { | public void testImageReply() { | ||||
WxMpKefuMessage reply = new WxMpKefuMessage(); | WxMpKefuMessage reply = new WxMpKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); | |||||
reply.setMsgType(WxConsts.KefuMsgType.IMAGE); | |||||
reply.setMediaId("MEDIA_ID"); | reply.setMediaId("MEDIA_ID"); | ||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); | Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); | ||||
} | } | ||||
@@ -37,7 +37,7 @@ public class WxMpKefuMessageTest { | |||||
public void testVoiceReply() { | public void testVoiceReply() { | ||||
WxMpKefuMessage reply = new WxMpKefuMessage(); | WxMpKefuMessage reply = new WxMpKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE); | |||||
reply.setMsgType(WxConsts.KefuMsgType.VOICE); | |||||
reply.setMediaId("MEDIA_ID"); | reply.setMediaId("MEDIA_ID"); | ||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); | Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); | ||||
} | } | ||||
@@ -50,7 +50,7 @@ public class WxMpKefuMessageTest { | |||||
public void testVideoReply() { | public void testVideoReply() { | ||||
WxMpKefuMessage reply = new WxMpKefuMessage(); | WxMpKefuMessage reply = new WxMpKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO); | |||||
reply.setMsgType(WxConsts.KefuMsgType.VIDEO); | |||||
reply.setMediaId("MEDIA_ID"); | reply.setMediaId("MEDIA_ID"); | ||||
reply.setThumbMediaId("MEDIA_ID"); | reply.setThumbMediaId("MEDIA_ID"); | ||||
reply.setTitle("TITLE"); | reply.setTitle("TITLE"); | ||||
@@ -66,7 +66,7 @@ public class WxMpKefuMessageTest { | |||||
public void testMusicReply() { | public void testMusicReply() { | ||||
WxMpKefuMessage reply = new WxMpKefuMessage(); | WxMpKefuMessage reply = new WxMpKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC); | |||||
reply.setMsgType(WxConsts.KefuMsgType.MUSIC); | |||||
reply.setThumbMediaId("MEDIA_ID"); | reply.setThumbMediaId("MEDIA_ID"); | ||||
reply.setDescription("DESCRIPTION"); | reply.setDescription("DESCRIPTION"); | ||||
reply.setTitle("TITLE"); | reply.setTitle("TITLE"); | ||||
@@ -90,7 +90,7 @@ public class WxMpKefuMessageTest { | |||||
public void testNewsReply() { | public void testNewsReply() { | ||||
WxMpKefuMessage reply = new WxMpKefuMessage(); | WxMpKefuMessage reply = new WxMpKefuMessage(); | ||||
reply.setToUser("OPENID"); | reply.setToUser("OPENID"); | ||||
reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); | |||||
reply.setMsgType(WxConsts.KefuMsgType.NEWS); | |||||
WxArticle article1 = new WxArticle(); | WxArticle article1 = new WxArticle(); | ||||
article1.setUrl("URL"); | article1.setUrl("URL"); | ||||
@@ -58,7 +58,7 @@ public class WxMpXmlMessageTest { | |||||
assertEquals(wxMessage.getToUser(), "toUser"); | assertEquals(wxMessage.getToUser(), "toUser"); | ||||
assertEquals(wxMessage.getFromUser(), "fromUser"); | assertEquals(wxMessage.getFromUser(), "fromUser"); | ||||
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | ||||
assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); | |||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | |||||
assertEquals(wxMessage.getContent(), "this is a test"); | assertEquals(wxMessage.getContent(), "this is a test"); | ||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | ||||
assertEquals(wxMessage.getPicUrl(), "this is a url"); | assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
@@ -139,7 +139,7 @@ public class WxMpXmlMessageTest { | |||||
assertEquals(wxMessage.getToUser(), "toUser"); | assertEquals(wxMessage.getToUser(), "toUser"); | ||||
assertEquals(wxMessage.getFromUser(), "fromUser"); | assertEquals(wxMessage.getFromUser(), "fromUser"); | ||||
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); | ||||
assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); | |||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); | |||||
assertEquals(wxMessage.getContent(), "this is a test"); | assertEquals(wxMessage.getContent(), "this is a test"); | ||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); | ||||
assertEquals(wxMessage.getPicUrl(), "this is a url"); | assertEquals(wxMessage.getPicUrl(), "this is a url"); | ||||
@@ -19,7 +19,7 @@ public class DemoImageHandler implements WxMpMessageHandler { | |||||
WxMpService wxMpService, WxSessionManager sessionManager) { | WxMpService wxMpService, WxSessionManager sessionManager) { | ||||
try { | try { | ||||
WxMediaUploadResult wxMediaUploadResult = wxMpService.getMaterialService() | WxMediaUploadResult wxMediaUploadResult = wxMpService.getMaterialService() | ||||
.mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg")); | |||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg")); | |||||
WxMpXmlOutImageMessage m | WxMpXmlOutImageMessage m | ||||
= WxMpXmlOutMessage | = WxMpXmlOutMessage | ||||
.IMAGE() | .IMAGE() | ||||
@@ -19,7 +19,7 @@ public class DemoOAuth2Handler implements WxMpMessageHandler { | |||||
WxSessionManager sessionManager) { | WxSessionManager sessionManager) { | ||||
String href = "<a href=\"" + wxMpService.oauth2buildAuthorizationUrl( | String href = "<a href=\"" + wxMpService.oauth2buildAuthorizationUrl( | ||||
wxMpService.getWxMpConfigStorage().getOauth2redirectUri(), | wxMpService.getWxMpConfigStorage().getOauth2redirectUri(), | ||||
WxConsts.OAUTH2_SCOPE_USER_INFO, null) + "\">测试oauth2</a>"; | |||||
WxConsts.OAuth2Scope.SNSAPI_USERINFO, null) + "\">测试oauth2</a>"; | |||||
return WxMpXmlOutMessage.TEXT().content(href) | return WxMpXmlOutMessage.TEXT().content(href) | ||||
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) | .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) | ||||
.build(); | .build(); | ||||
@@ -58,7 +58,7 @@ public class WxMpDemoServer { | |||||
wxMpMessageRouter = new WxMpMessageRouter(wxMpService); | wxMpMessageRouter = new WxMpMessageRouter(wxMpService); | ||||
wxMpMessageRouter.rule().handler(logHandler).next().rule() | wxMpMessageRouter.rule().handler(logHandler).next().rule() | ||||
.msgType(WxConsts.XML_MSG_TEXT).matcher(guessNumberHandler) | |||||
.msgType(WxConsts.XmlMsgType.TEXT).matcher(guessNumberHandler) | |||||
.handler(guessNumberHandler).end().rule().async(false).content("哈哈") | .handler(guessNumberHandler).end().rule().async(false).content("哈哈") | ||||
.handler(textHandler).end().rule().async(false).content("图片") | .handler(textHandler).end().rule().async(false).content("图片") | ||||
.handler(imageHandler).end().rule().async(false).content("oauth") | .handler(imageHandler).end().rule().async(false).content("oauth") | ||||