mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
微信企业号
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
public class WxAccessToken {
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private int expiresIn;
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public int getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public void setExpiresIn(int expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
public static WxAccessToken fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxAccessToken.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.custombuilder.ImageBuilder;
|
||||
import me.chanjar.weixin.mp.bean.custombuilder.MusicBuilder;
|
||||
import me.chanjar.weixin.mp.bean.custombuilder.NewsBuilder;
|
||||
import me.chanjar.weixin.mp.bean.custombuilder.TextBuilder;
|
||||
import me.chanjar.weixin.mp.bean.custombuilder.VideoBuilder;
|
||||
import me.chanjar.weixin.mp.bean.custombuilder.VoiceBuilder;
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 客服消息
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxCustomMessage {
|
||||
|
||||
private String toUser;
|
||||
private String msgType;
|
||||
private String content;
|
||||
private String mediaId;
|
||||
private String thumbMediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
private String musicUrl;
|
||||
private String hqMusicUrl;
|
||||
private List<WxArticle> articles = new ArrayList<WxArticle>();
|
||||
|
||||
public String getToUser() {
|
||||
return toUser;
|
||||
}
|
||||
public void setToUser(String toUser) {
|
||||
this.toUser = toUser;
|
||||
}
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 请使用
|
||||
* {@link WxConsts#CUSTOM_MSG_TEXT}
|
||||
* {@link WxConsts#CUSTOM_MSG_IMAGE}
|
||||
* {@link WxConsts#CUSTOM_MSG_VOICE}
|
||||
* {@link WxConsts#CUSTOM_MSG_MUSIC}
|
||||
* {@link WxConsts#CUSTOM_MSG_VIDEO}
|
||||
* {@link WxConsts#CUSTOM_MSG_NEWS}
|
||||
* </pre>
|
||||
* @param msgType
|
||||
*/
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getMusicUrl() {
|
||||
return musicUrl;
|
||||
}
|
||||
public void setMusicUrl(String musicUrl) {
|
||||
this.musicUrl = musicUrl;
|
||||
}
|
||||
public String getHqMusicUrl() {
|
||||
return hqMusicUrl;
|
||||
}
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
this.hqMusicUrl = hqMusicUrl;
|
||||
}
|
||||
public List<WxArticle> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
public void setArticles(List<WxArticle> articles) {
|
||||
this.articles = articles;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.INSTANCE.create().toJson(this);
|
||||
}
|
||||
|
||||
public static class WxArticle {
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
private String url;
|
||||
private String picUrl;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
public String getPicUrl() {
|
||||
return picUrl;
|
||||
}
|
||||
public void setPicUrl(String picUrl) {
|
||||
this.picUrl = picUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得文本消息builder
|
||||
* @return
|
||||
*/
|
||||
public static TextBuilder TEXT() {
|
||||
return new TextBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得图片消息builder
|
||||
* @return
|
||||
*/
|
||||
public static ImageBuilder IMAGE() {
|
||||
return new ImageBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得语音消息builder
|
||||
* @return
|
||||
*/
|
||||
public static VoiceBuilder VOICE() {
|
||||
return new VoiceBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得视频消息builder
|
||||
* @return
|
||||
*/
|
||||
public static VideoBuilder VIDEO() {
|
||||
return new VideoBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得音乐消息builder
|
||||
* @return
|
||||
*/
|
||||
public static MusicBuilder MUSIC() {
|
||||
return new MusicBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得图文消息builder
|
||||
* @return
|
||||
*/
|
||||
public static NewsBuilder NEWS() {
|
||||
return new NewsBuilder();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 微信用户分组
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxGroup {
|
||||
|
||||
private long id = -1;
|
||||
private String name;
|
||||
private long count;
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public static WxGroup fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxGroup.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.create().toJson(this);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxGroup [id=" + id + ", name=" + name + ", count=" + count + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 分组群发的消息
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
public class WxMassGroupMessage {
|
||||
|
||||
private long groupId;
|
||||
private String msgtype;
|
||||
private String content;
|
||||
private String mediaId;
|
||||
|
||||
public WxMassGroupMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getMsgtype() {
|
||||
return msgtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 请使用
|
||||
* {@link WxConsts#MASS_MSG_IMAGE}
|
||||
* {@link WxConsts#MASS_MSG_NEWS}
|
||||
* {@link WxConsts#MASS_MSG_TEXT}
|
||||
* {@link WxConsts#MASS_MSG_VIDEO}
|
||||
* {@link WxConsts#MASS_MSG_VOICE}
|
||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
|
||||
* </pre>
|
||||
* @param msgtype
|
||||
*/
|
||||
public void setMsgtype(String msgtype) {
|
||||
this.msgtype = msgtype;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.INSTANCE.create().toJson(this);
|
||||
}
|
||||
|
||||
public long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 群发时用到的图文消息素材
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxMassNews {
|
||||
|
||||
private List<WxMassNewsArticle> articles = new ArrayList<WxMassNewsArticle>();
|
||||
|
||||
public List<WxMassNewsArticle> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
|
||||
public void addArticle(WxMassNewsArticle article) {
|
||||
this.articles.add(article);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.INSTANCE.create().toJson(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 群发图文消息article
|
||||
* 1. thumbMediaId (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得
|
||||
* 2. author 图文消息的作者
|
||||
* 3. title (必填) 图文消息的标题
|
||||
* 4. contentSourceUrl 在图文消息页面点击“阅读原文”后的页面链接
|
||||
* 5. content (必填) 图文消息页面的内容,支持HTML标签
|
||||
* 6. digest 图文消息的描述
|
||||
* 7, showCoverPic 是否显示封面,true为显示,false为不显示
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public static class WxMassNewsArticle {
|
||||
/**
|
||||
* (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得
|
||||
*/
|
||||
private String thumbMediaId;
|
||||
/**
|
||||
* 图文消息的作者
|
||||
*/
|
||||
private String author;
|
||||
/**
|
||||
* (必填) 图文消息的标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 在图文消息页面点击“阅读原文”后的页面链接
|
||||
*/
|
||||
private String contentSourceUrl;
|
||||
/**
|
||||
* (必填) 图文消息页面的内容,支持HTML标签
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 图文消息的描述
|
||||
*/
|
||||
private String digest;
|
||||
/**
|
||||
* 是否显示封面,true为显示,false为不显示
|
||||
*/
|
||||
private boolean showCoverPic;
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getContentSourceUrl() {
|
||||
return contentSourceUrl;
|
||||
}
|
||||
public void setContentSourceUrl(String contentSourceUrl) {
|
||||
this.contentSourceUrl = contentSourceUrl;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
public String getDigest() {
|
||||
return digest;
|
||||
}
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
public boolean isShowCoverPic() {
|
||||
return showCoverPic;
|
||||
}
|
||||
public void setShowCoverPic(boolean showCoverPic) {
|
||||
this.showCoverPic = showCoverPic;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* OpenId列表群发的消息
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
public class WxMassOpenIdsMessage {
|
||||
|
||||
private List<String> toUsers = new ArrayList<String>();
|
||||
private String msgType;
|
||||
private String content;
|
||||
private String mediaId;
|
||||
|
||||
public WxMassOpenIdsMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 请使用
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#MASS_MSG_IMAGE}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#MASS_MSG_NEWS}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#MASS_MSG_TEXT}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#MASS_MSG_VIDEO}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#MASS_MSG_VOICE}
|
||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
|
||||
* </pre>
|
||||
* @param msgType
|
||||
*/
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.INSTANCE.create().toJson(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenId列表,最多支持10,000个
|
||||
* @return
|
||||
*/
|
||||
public List<String> getToUsers() {
|
||||
return toUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加OpenId,最多支持10,000个
|
||||
* @param openId
|
||||
*/
|
||||
public void addUser(String openId) {
|
||||
this.toUsers.add(openId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 群发时用到的视频素材
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
public class WxMassVideo {
|
||||
|
||||
private String mediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.INSTANCE.create().toJson(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 公众号菜单
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxMenu {
|
||||
|
||||
private List<WxMenuButton> buttons = new ArrayList<WxMenuButton>();
|
||||
|
||||
public List<WxMenuButton> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void setButtons(List<WxMenuButton> buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static WxMenu fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMenu.class);
|
||||
}
|
||||
|
||||
public static WxMenu fromJson(InputStream is) {
|
||||
return WxGsonBuilder.create().fromJson(new InputStreamReader(is), WxMenu.class);
|
||||
}
|
||||
|
||||
public static class WxMenuButton {
|
||||
|
||||
private String type;
|
||||
private String name;
|
||||
private String key;
|
||||
private String url;
|
||||
|
||||
private List<WxMenuButton> subButtons = new ArrayList<WxMenuButton>();
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public List<WxMenuButton> getSubButtons() {
|
||||
return subButtons;
|
||||
}
|
||||
|
||||
public void setSubButtons(List<WxMenuButton> subButtons) {
|
||||
this.subButtons = subButtons;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,638 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConfigStorage;
|
||||
import me.chanjar.weixin.mp.util.crypto.WxCryptUtil;
|
||||
import me.chanjar.weixin.mp.util.xml.AdapterCDATA;
|
||||
import me.chanjar.weixin.mp.util.xml.XmlTransformer;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.*;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信推送过来的消息,也是同步回复给用户的消息,xml格式
|
||||
* 相关字段的解释看微信开发者文档:
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=接收普通消息
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=接收事件推送
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=接收语音识别结果
|
||||
* </pre>
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlMessage {
|
||||
|
||||
///////////////////////
|
||||
// 以下都是微信推送过来的消息的xml的element所对应的属性
|
||||
///////////////////////
|
||||
|
||||
@XmlElement(name = "ToUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String toUserName;
|
||||
|
||||
@XmlElement(name = "FromUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String fromUserName;
|
||||
|
||||
@XmlElement(name = "CreateTime")
|
||||
private Long createTime;
|
||||
|
||||
@XmlElement(name = "MsgType")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String msgType;
|
||||
|
||||
@XmlElement(name = "Content")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String content;
|
||||
|
||||
@XmlElement(name = "MsgId")
|
||||
private Long msgId;
|
||||
|
||||
@XmlElement(name = "PicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String picUrl;
|
||||
|
||||
@XmlElement(name = "MediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String mediaId;
|
||||
|
||||
@XmlElement(name = "Format")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String format;
|
||||
|
||||
@XmlElement(name = "ThumbMediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String thumbMediaId;
|
||||
|
||||
@XmlElement(name = "Location_X")
|
||||
private Double locationX;
|
||||
|
||||
@XmlElement(name = "Location_Y")
|
||||
private Double locationY;
|
||||
|
||||
@XmlElement(name = "Scale")
|
||||
private Double scale;
|
||||
|
||||
@XmlElement(name = "Label")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String label;
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String description;
|
||||
|
||||
@XmlElement(name = "Url")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String url;
|
||||
|
||||
@XmlElement(name = "Event")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String event;
|
||||
|
||||
@XmlElement(name = "EventKey")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String eventKey;
|
||||
|
||||
@XmlElement(name = "Ticket")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String ticket;
|
||||
|
||||
@XmlElement(name = "Latitude")
|
||||
private Double latitude;
|
||||
|
||||
@XmlElement(name = "Longitude")
|
||||
private Double longitude;
|
||||
|
||||
@XmlElement(name = "Precision")
|
||||
private Double precision;
|
||||
|
||||
@XmlElement(name = "Recognition")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String recognition;
|
||||
|
||||
///////////////////////////////////////
|
||||
// 群发消息返回的结果
|
||||
///////////////////////////////////////
|
||||
/**
|
||||
* 群发的结果
|
||||
*/
|
||||
@XmlElement(name = "Status")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String status;
|
||||
/**
|
||||
* group_id下粉丝数;或者openid_list中的粉丝数
|
||||
*/
|
||||
@XmlElement(name = "TotalCount")
|
||||
private Integer totalCount;
|
||||
/**
|
||||
* 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,filterCount = sentCount + errorCount
|
||||
*/
|
||||
@XmlElement(name = "FilterCount")
|
||||
private Integer filterCount;
|
||||
/**
|
||||
* 发送成功的粉丝数
|
||||
*/
|
||||
@XmlElement(name = "SentCount")
|
||||
private Integer sentCount;
|
||||
/**
|
||||
* 发送失败的粉丝数
|
||||
*/
|
||||
@XmlElement(name = "ErrorCount")
|
||||
private Integer errorCount;
|
||||
|
||||
@XmlElement(name = "ScanCodeInfo")
|
||||
private ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
|
||||
|
||||
@XmlElement(name = "SendPicsInfo")
|
||||
private SendPicsInfo sendPicsInfo = new SendPicsInfo();
|
||||
|
||||
@XmlElement(name = "SendLocationInfo")
|
||||
private SendLocationInfo sendLocationInfo = new SendLocationInfo();
|
||||
|
||||
public String getToUserName() {
|
||||
return toUserName;
|
||||
}
|
||||
|
||||
public void setToUserName(String toUserName) {
|
||||
this.toUserName = toUserName;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 当接受用户消息时,可能会获得以下值:
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_TEXT}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_IMAGE}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_VOICE}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_VIDEO}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_LOCATION}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_LINK}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_EVENT}
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 当发送消息的时候使用:
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_TEXT}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_IMAGE}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_VOICE}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_VIDEO}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_NEWS}
|
||||
* {@link me.chanjar.weixin.mp.api.WxConsts#XML_MSG_MUSIC}
|
||||
* </pre>
|
||||
*
|
||||
* @param msgType
|
||||
*/
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Long getMsgId() {
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public void setMsgId(Long msgId) {
|
||||
this.msgId = msgId;
|
||||
}
|
||||
|
||||
public String getPicUrl() {
|
||||
return picUrl;
|
||||
}
|
||||
|
||||
public void setPicUrl(String picUrl) {
|
||||
this.picUrl = picUrl;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
public Double getLocationX() {
|
||||
return locationX;
|
||||
}
|
||||
|
||||
public void setLocationX(Double locationX) {
|
||||
this.locationX = locationX;
|
||||
}
|
||||
|
||||
public Double getLocationY() {
|
||||
return locationY;
|
||||
}
|
||||
|
||||
public void setLocationY(Double locationY) {
|
||||
this.locationY = locationY;
|
||||
}
|
||||
|
||||
public Double getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(Double scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(String event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public String getEventKey() {
|
||||
return eventKey;
|
||||
}
|
||||
|
||||
public void setEventKey(String eventKey) {
|
||||
this.eventKey = eventKey;
|
||||
}
|
||||
|
||||
public String getTicket() {
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public void setTicket(String ticket) {
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public Double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(Double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public Double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(Double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public Double getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
public void setPrecision(Double precision) {
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
public String getRecognition() {
|
||||
return recognition;
|
||||
}
|
||||
|
||||
public void setRecognition(String recognition) {
|
||||
this.recognition = recognition;
|
||||
}
|
||||
|
||||
public String getFromUserName() {
|
||||
return fromUserName;
|
||||
}
|
||||
|
||||
public void setFromUserName(String fromUserName) {
|
||||
this.fromUserName = fromUserName;
|
||||
}
|
||||
|
||||
public static WxXmlMessage fromXml(String xml) {
|
||||
try {
|
||||
return XmlTransformer.fromXml(WxXmlMessage.class, xml);
|
||||
} catch (JAXBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static WxXmlMessage fromXml(InputStream is) {
|
||||
try {
|
||||
return XmlTransformer.fromXml(WxXmlMessage.class, is);
|
||||
} catch (JAXBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从加密字符串转换
|
||||
*
|
||||
* @param encryptedXml
|
||||
* @param wxConfigStorage
|
||||
* @param timestamp
|
||||
* @param nonce
|
||||
* @param msgSignature
|
||||
* @return
|
||||
*/
|
||||
public static WxXmlMessage fromEncryptedXml(
|
||||
String encryptedXml,
|
||||
WxConfigStorage wxConfigStorage,
|
||||
String timestamp, String nonce, String msgSignature) {
|
||||
WxCryptUtil cryptUtil = new WxCryptUtil(wxConfigStorage);
|
||||
String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml);
|
||||
return fromXml(plainText);
|
||||
}
|
||||
|
||||
public static WxXmlMessage fromEncryptedXml(
|
||||
InputStream is,
|
||||
WxConfigStorage wxConfigStorage,
|
||||
String timestamp, String nonce, String msgSignature) {
|
||||
try {
|
||||
return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxConfigStorage, timestamp, nonce, msgSignature);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(Integer totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public Integer getFilterCount() {
|
||||
return filterCount;
|
||||
}
|
||||
|
||||
public void setFilterCount(Integer filterCount) {
|
||||
this.filterCount = filterCount;
|
||||
}
|
||||
|
||||
public Integer getSentCount() {
|
||||
return sentCount;
|
||||
}
|
||||
|
||||
public void setSentCount(Integer sentCount) {
|
||||
this.sentCount = sentCount;
|
||||
}
|
||||
|
||||
public Integer getErrorCount() {
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
public void setErrorCount(Integer errorCount) {
|
||||
this.errorCount = errorCount;
|
||||
}
|
||||
|
||||
public WxXmlMessage.ScanCodeInfo getScanCodeInfo() {
|
||||
return scanCodeInfo;
|
||||
}
|
||||
|
||||
public void setScanCodeInfo(WxXmlMessage.ScanCodeInfo scanCodeInfo) {
|
||||
this.scanCodeInfo = scanCodeInfo;
|
||||
}
|
||||
|
||||
public WxXmlMessage.SendPicsInfo getSendPicsInfo() {
|
||||
return sendPicsInfo;
|
||||
}
|
||||
|
||||
public void setSendPicsInfo(WxXmlMessage.SendPicsInfo sendPicsInfo) {
|
||||
this.sendPicsInfo = sendPicsInfo;
|
||||
}
|
||||
|
||||
public WxXmlMessage.SendLocationInfo getSendLocationInfo() {
|
||||
return sendLocationInfo;
|
||||
}
|
||||
|
||||
public void setSendLocationInfo(WxXmlMessage.SendLocationInfo sendLocationInfo) {
|
||||
this.sendLocationInfo = sendLocationInfo;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "ScanCodeInfo")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class ScanCodeInfo {
|
||||
|
||||
@XmlElement(name = "ScanType")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String scanType;
|
||||
|
||||
@XmlElement(name = "ScanResult")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String scanResult;
|
||||
|
||||
/**
|
||||
* 扫描类型,一般是qrcode
|
||||
* @return
|
||||
*/
|
||||
public String getScanType() {
|
||||
|
||||
return scanType;
|
||||
}
|
||||
|
||||
public void setScanType(String scanType) {
|
||||
this.scanType = scanType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫描结果,即二维码对应的字符串信息
|
||||
* @return
|
||||
*/
|
||||
public String getScanResult() {
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
public void setScanResult(String scanResult) {
|
||||
this.scanResult = scanResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "SendPicsInfo")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class SendPicsInfo {
|
||||
|
||||
@XmlElement(name = "Count")
|
||||
private Long count;
|
||||
|
||||
@XmlElementWrapper(name="PicList")
|
||||
@XmlElement(name = "item")
|
||||
protected final List<Item> picList = new ArrayList<Item>();
|
||||
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public List<Item> getPicList() {
|
||||
return picList;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "item")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "WxXmlMessage.SendPicsInfo.Item")
|
||||
public static class Item {
|
||||
|
||||
@XmlElement(name = "PicMd5Sum")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String PicMd5Sum;
|
||||
|
||||
public String getPicMd5Sum() {
|
||||
return PicMd5Sum;
|
||||
}
|
||||
|
||||
public void setPicMd5Sum(String picMd5Sum) {
|
||||
PicMd5Sum = picMd5Sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "SendLocationInfo")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class SendLocationInfo {
|
||||
|
||||
@XmlElement(name = "Location_X")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String locationX;
|
||||
|
||||
@XmlElement(name = "Location_Y")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String locationY;
|
||||
|
||||
@XmlElement(name = "Scale")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String scale;
|
||||
|
||||
@XmlElement(name = "Label")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String label;
|
||||
|
||||
@XmlElement(name = "Poiname")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String poiname;
|
||||
|
||||
public String getLocationX() {
|
||||
return locationX;
|
||||
}
|
||||
|
||||
public void setLocationX(String locationX) {
|
||||
this.locationX = locationX;
|
||||
}
|
||||
|
||||
public String getLocationY() {
|
||||
return locationY;
|
||||
}
|
||||
|
||||
public void setLocationY(String locationY) {
|
||||
this.locationY = locationY;
|
||||
}
|
||||
|
||||
public String getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(String scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getPoiname() {
|
||||
return poiname;
|
||||
}
|
||||
|
||||
public void setPoiname(String poiname) {
|
||||
this.poiname = poiname;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.xml.MediaIdMarshaller;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutImageMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="Image")
|
||||
@XmlJavaTypeAdapter(MediaIdMarshaller.class)
|
||||
private String mediaId;
|
||||
|
||||
public WxXmlOutImageMessage() {
|
||||
this.msgType = WxConsts.XML_MSG_IMAGE;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConfigStorage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.ImageBuilder;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.MusicBuilder;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.NewsBuilder;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.VideoBuilder;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.VoiceBuilder;
|
||||
import me.chanjar.weixin.mp.util.crypto.WxCryptUtil;
|
||||
import me.chanjar.weixin.mp.util.xml.AdapterCDATA;
|
||||
import me.chanjar.weixin.mp.util.xml.XmlTransformer;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="ToUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
protected String toUserName;
|
||||
|
||||
@XmlElement(name="FromUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
protected String fromUserName;
|
||||
|
||||
@XmlElement(name="CreateTime")
|
||||
protected Long createTime;
|
||||
|
||||
@XmlElement(name="MsgType")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
protected String msgType;
|
||||
|
||||
public String getToUserName() {
|
||||
return toUserName;
|
||||
}
|
||||
|
||||
public void setToUserName(String toUserName) {
|
||||
this.toUserName = toUserName;
|
||||
}
|
||||
|
||||
public String getFromUserName() {
|
||||
return fromUserName;
|
||||
}
|
||||
|
||||
public void setFromUserName(String fromUserName) {
|
||||
this.fromUserName = fromUserName;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String toXml() {
|
||||
try {
|
||||
return XmlTransformer.toXml((Class)this.getClass(), this);
|
||||
} catch (JAXBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换成加密的xml格式
|
||||
* @return
|
||||
*/
|
||||
public String toEncryptedXml(WxConfigStorage wxConfigStorage) {
|
||||
String plainXml = toXml();
|
||||
WxCryptUtil pc = new WxCryptUtil(wxConfigStorage);
|
||||
return pc.encrypt(plainXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得文本消息builder
|
||||
* @return
|
||||
*/
|
||||
public static TextBuilder TEXT() {
|
||||
return new TextBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得图片消息builder
|
||||
* @return
|
||||
*/
|
||||
public static ImageBuilder IMAGE() {
|
||||
return new ImageBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得语音消息builder
|
||||
* @return
|
||||
*/
|
||||
public static VoiceBuilder VOICE() {
|
||||
return new VoiceBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得视频消息builder
|
||||
* @return
|
||||
*/
|
||||
public static VideoBuilder VIDEO() {
|
||||
return new VideoBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得音乐消息builder
|
||||
* @return
|
||||
*/
|
||||
public static MusicBuilder MUSIC() {
|
||||
return new MusicBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得图文消息builder
|
||||
* @return
|
||||
*/
|
||||
public static NewsBuilder NEWS() {
|
||||
return new NewsBuilder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.xml.AdapterCDATA;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutMewsMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name = "ArticleCount")
|
||||
protected int articleCount;
|
||||
|
||||
@XmlElementWrapper(name="Articles")
|
||||
@XmlElement(name = "item")
|
||||
protected final List<Item> articles = new ArrayList<Item>();
|
||||
|
||||
public WxXmlOutMewsMessage() {
|
||||
this.msgType = WxConsts.XML_MSG_NEWS;
|
||||
}
|
||||
|
||||
public int getArticleCount() {
|
||||
return articleCount;
|
||||
}
|
||||
|
||||
public void addArticle(Item item) {
|
||||
this.articles.add(item);
|
||||
this.articleCount = this.articles.size();
|
||||
}
|
||||
|
||||
public List<Item> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
|
||||
|
||||
@XmlRootElement(name = "Item")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class Item {
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Description;
|
||||
|
||||
@XmlElement(name="PicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String PicUrl;
|
||||
|
||||
@XmlElement(name="Url")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Url;
|
||||
|
||||
public String getTitle() {
|
||||
return Title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
Title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return Description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public String getPicUrl() {
|
||||
return PicUrl;
|
||||
}
|
||||
|
||||
public void setPicUrl(String picUrl) {
|
||||
PicUrl = picUrl;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return Url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
Url = url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.xml.AdapterCDATA;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutMusicMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name = "Music")
|
||||
protected final Music music = new Music();
|
||||
|
||||
public WxXmlOutMusicMessage() {
|
||||
this.msgType = WxConsts.XML_MSG_MUSIC;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return music.getTitle();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
music.setTitle(title);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return music.getDescription();
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
music.setDescription(description);
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return music.getThumbMediaId();
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
music.setThumbMediaId(thumbMediaId);
|
||||
}
|
||||
|
||||
public String getMusicUrl() {
|
||||
return music.getMusicUrl();
|
||||
}
|
||||
|
||||
public void setMusicUrl(String musicUrl) {
|
||||
music.setMusicUrl(musicUrl);
|
||||
}
|
||||
|
||||
public String getHqMusicUrl() {
|
||||
return music.getHqMusicUrl();
|
||||
}
|
||||
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
music.setHqMusicUrl(hqMusicUrl);
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "Music")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
private static class Music {
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String description;
|
||||
|
||||
@XmlElement(name="ThumbMediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String thumbMediaId;
|
||||
|
||||
@XmlElement(name="MusicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String musicUrl;
|
||||
|
||||
@XmlElement(name="HQMusicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String hqMusicUrl;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
public String getMusicUrl() {
|
||||
return musicUrl;
|
||||
}
|
||||
|
||||
public void setMusicUrl(String musicUrl) {
|
||||
this.musicUrl = musicUrl;
|
||||
}
|
||||
|
||||
public String getHqMusicUrl() {
|
||||
return hqMusicUrl;
|
||||
}
|
||||
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
this.hqMusicUrl = hqMusicUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.xml.AdapterCDATA;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutTextMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="Content")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String content;
|
||||
|
||||
public WxXmlOutTextMessage() {
|
||||
this.msgType = WxConsts.XML_MSG_TEXT;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.xml.AdapterCDATA;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutVideoMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name = "Video")
|
||||
protected final Video video = new Video();
|
||||
|
||||
public WxXmlOutVideoMessage() {
|
||||
this.msgType = WxConsts.XML_MSG_VIDEO;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return video.getMediaId();
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
video.setMediaId(mediaId);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return video.getTitle();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
video.setTitle(title);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return video.getDescription();
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
video.setDescription(description);
|
||||
}
|
||||
|
||||
|
||||
@XmlRootElement(name = "Video")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
private static class Video {
|
||||
|
||||
@XmlElement(name = "MediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String mediaId;
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String description;
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.chanjar.weixin.mp.bean;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.util.xml.MediaIdMarshaller;
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class WxXmlOutVoiceMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="Voice")
|
||||
@XmlJavaTypeAdapter(MediaIdMarshaller.class)
|
||||
private String mediaId;
|
||||
|
||||
public WxXmlOutVoiceMessage() {
|
||||
this.msgType = WxConsts.XML_MSG_VOICE;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
public class BaseBuilder<T> {
|
||||
protected String msgType;
|
||||
protected String toUser;
|
||||
|
||||
public T toUser(String toUser) {
|
||||
this.toUser = toUser;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = new WxCustomMessage();
|
||||
m.setMsgType(this.msgType);
|
||||
m.setToUser(this.toUser);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
/**
|
||||
* 获得消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.IMAGE().mediaId(...).toUser(...).build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
||||
private String mediaId;
|
||||
|
||||
public ImageBuilder() {
|
||||
this.msgType = WxConsts.CUSTOM_MSG_IMAGE;
|
||||
}
|
||||
|
||||
public ImageBuilder mediaId(String media_id) {
|
||||
this.mediaId = media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMediaId(this.mediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
/**
|
||||
* 音乐消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.MUSIC()
|
||||
* .musicUrl(...)
|
||||
* .hqMusicUrl(...)
|
||||
* .title(...)
|
||||
* .thumbMediaId(..)
|
||||
* .description(..)
|
||||
* .toUser(...)
|
||||
* .build();
|
||||
* </pre>
|
||||
*/
|
||||
public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
|
||||
private String title;
|
||||
private String description;
|
||||
private String thumbMediaId;
|
||||
private String musicUrl;
|
||||
private String hqMusicUrl;
|
||||
|
||||
public MusicBuilder() {
|
||||
this.msgType = WxConsts.CUSTOM_MSG_MUSIC;
|
||||
}
|
||||
|
||||
public MusicBuilder musicUrl(String musicurl) {
|
||||
this.musicUrl = musicurl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder hqMusicUrl(String hqMusicurl) {
|
||||
this.hqMusicUrl = hqMusicurl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder thumbMediaId(String thumb_media_id) {
|
||||
this.thumbMediaId = thumb_media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMusicUrl(this.musicUrl);
|
||||
m.setHqMusicUrl(this.hqMusicUrl);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setThumbMediaId(thumbMediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
/**
|
||||
* 图文消息builder
|
||||
* <pre>
|
||||
* 用法:
|
||||
* WxCustomMessage m = WxCustomMessage.NEWS().addArticle(article).toUser(...).build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
||||
|
||||
private List<WxCustomMessage.WxArticle> articles = new ArrayList<WxCustomMessage.WxArticle>();
|
||||
|
||||
public NewsBuilder() {
|
||||
this.msgType = WxConsts.CUSTOM_MSG_NEWS;
|
||||
}
|
||||
|
||||
public NewsBuilder addArticle(WxCustomMessage.WxArticle article) {
|
||||
this.articles.add(article);
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setArticles(this.articles);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
/**
|
||||
* 文本消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.TEXT().content(...).toUser(...).build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
||||
private String content;
|
||||
|
||||
public TextBuilder() {
|
||||
this.msgType = WxConsts.CUSTOM_MSG_TEXT;
|
||||
}
|
||||
|
||||
public TextBuilder content(String content) {
|
||||
this.content = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setContent(this.content);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
/**
|
||||
* 视频消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.VOICE()
|
||||
* .mediaId(...)
|
||||
* .title(...)
|
||||
* .thumbMediaId(..)
|
||||
* .description(..)
|
||||
* .toUser(...)
|
||||
* .build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
||||
private String mediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
private String thumbMediaId;
|
||||
|
||||
public VideoBuilder() {
|
||||
this.msgType = WxConsts.CUSTOM_MSG_VIDEO;
|
||||
}
|
||||
|
||||
public VideoBuilder mediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VideoBuilder title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VideoBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VideoBuilder thumbMediaId(String thumb_media_id) {
|
||||
this.thumbMediaId = thumb_media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMediaId(this.mediaId);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setThumbMediaId(thumbMediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.mp.bean.custombuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxCustomMessage;
|
||||
|
||||
/**
|
||||
* 语音消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.VOICE().mediaId(...).toUser(...).build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
||||
private String mediaId;
|
||||
|
||||
public VoiceBuilder() {
|
||||
this.msgType = WxConsts.CUSTOM_MSG_VOICE;
|
||||
}
|
||||
|
||||
public VoiceBuilder mediaId(String media_id) {
|
||||
this.mediaId = media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMediaId(this.mediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutMessage;
|
||||
|
||||
|
||||
public abstract class BaseBuilder<BuilderType, ValueType> {
|
||||
|
||||
protected String toUserName;
|
||||
|
||||
protected String fromUserName;
|
||||
|
||||
public BuilderType toUser(String touser) {
|
||||
this.toUserName = touser;
|
||||
return (BuilderType) this;
|
||||
}
|
||||
|
||||
public BuilderType fromUser(String fromusername) {
|
||||
this.fromUserName = fromusername;
|
||||
return (BuilderType) this;
|
||||
}
|
||||
|
||||
public abstract ValueType build();
|
||||
|
||||
public void setCommon(WxXmlOutMessage m) {
|
||||
m.setToUserName(this.toUserName);
|
||||
m.setFromUserName(this.fromUserName);
|
||||
m.setCreateTime(System.currentTimeMillis() / 1000l);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutImageMessage;
|
||||
|
||||
/**
|
||||
* 图片消息builder
|
||||
* @author chanjarster
|
||||
*/
|
||||
public final class ImageBuilder extends BaseBuilder<ImageBuilder, WxXmlOutImageMessage> {
|
||||
|
||||
private String mediaId;
|
||||
|
||||
public ImageBuilder mediaId(String media_id) {
|
||||
this.mediaId = media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxXmlOutImageMessage build() {
|
||||
WxXmlOutImageMessage m = new WxXmlOutImageMessage();
|
||||
setCommon(m);
|
||||
m.setMediaId(this.mediaId);
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutMusicMessage;
|
||||
|
||||
/**
|
||||
* 音乐消息builder
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxXmlOutMusicMessage> {
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
private String hqMusicUrl;
|
||||
private String musicUrl;
|
||||
private String thumbMediaId;
|
||||
|
||||
public MusicBuilder title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder hqMusicUrl(String hqMusicUrl) {
|
||||
this.hqMusicUrl = hqMusicUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder musicUrl(String musicUrl) {
|
||||
this.musicUrl = musicUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder thumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxXmlOutMusicMessage build() {
|
||||
WxXmlOutMusicMessage m = new WxXmlOutMusicMessage();
|
||||
setCommon(m);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setHqMusicUrl(hqMusicUrl);
|
||||
m.setMusicUrl(musicUrl);
|
||||
m.setThumbMediaId(thumbMediaId);
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutMewsMessage;
|
||||
|
||||
/**
|
||||
* 图文消息builder
|
||||
* @author chanjarster
|
||||
*/
|
||||
public final class NewsBuilder extends BaseBuilder<NewsBuilder, WxXmlOutMewsMessage> {
|
||||
|
||||
protected final List<WxXmlOutMewsMessage.Item> articles = new ArrayList<WxXmlOutMewsMessage.Item>();
|
||||
|
||||
public NewsBuilder addArticle(WxXmlOutMewsMessage.Item item) {
|
||||
this.articles.add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxXmlOutMewsMessage build() {
|
||||
WxXmlOutMewsMessage m = new WxXmlOutMewsMessage();
|
||||
for(WxXmlOutMewsMessage.Item item : articles) {
|
||||
m.addArticle(item);
|
||||
}
|
||||
setCommon(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutTextMessage;
|
||||
|
||||
/**
|
||||
* 文本消息builder
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class TextBuilder extends BaseBuilder<TextBuilder, WxXmlOutTextMessage> {
|
||||
private String content;
|
||||
|
||||
public TextBuilder content(String content) {
|
||||
this.content = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxXmlOutTextMessage build() {
|
||||
WxXmlOutTextMessage m = new WxXmlOutTextMessage();
|
||||
setCommon(m);
|
||||
m.setContent(this.content);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutVideoMessage;
|
||||
|
||||
/**
|
||||
* 视频消息builder
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxXmlOutVideoMessage> {
|
||||
|
||||
private String mediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
|
||||
public VideoBuilder title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
public VideoBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
public VideoBuilder mediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxXmlOutVideoMessage build() {
|
||||
WxXmlOutVideoMessage m = new WxXmlOutVideoMessage();
|
||||
setCommon(m);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setMediaId(mediaId);
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.chanjar.weixin.mp.bean.outxmlbuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxXmlOutVoiceMessage;
|
||||
|
||||
/**
|
||||
* 语音消息builder
|
||||
* @author chanjarster
|
||||
*/
|
||||
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder, WxXmlOutVoiceMessage> {
|
||||
|
||||
private String mediaId;
|
||||
|
||||
public VoiceBuilder mediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxXmlOutVoiceMessage build() {
|
||||
WxXmlOutVoiceMessage m = new WxXmlOutVoiceMessage();
|
||||
setCommon(m);
|
||||
m.setMediaId(mediaId);
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 微信错误码说明
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=全局返回码说明
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxError {
|
||||
|
||||
protected static final Map<Integer, String> errMap = new HashMap<Integer, String>();
|
||||
|
||||
static {
|
||||
errMap.put(-1, "系统繁忙");
|
||||
errMap.put(0, "请求成功");
|
||||
errMap.put(40001, "获取access_token时AppSecret错误,或者access_token无效");
|
||||
errMap.put(40002, "不合法的凭证类型");
|
||||
errMap.put(40003, "不合法的OpenID");
|
||||
errMap.put(40004, "不合法的媒体文件类型");
|
||||
errMap.put(40005, "不合法的文件类型");
|
||||
errMap.put(40006, "不合法的文件大小");
|
||||
errMap.put(40007, "不合法的媒体文件id");
|
||||
errMap.put(40008, "不合法的消息类型");
|
||||
errMap.put(40009, "不合法的图片文件大小");
|
||||
errMap.put(40010, "不合法的语音文件大小");
|
||||
errMap.put(40011, "不合法的视频文件大小");
|
||||
errMap.put(40012, "不合法的缩略图文件大小");
|
||||
errMap.put(40013, "不合法的APPID");
|
||||
errMap.put(40014, "不合法的access_token");
|
||||
errMap.put(40015, "不合法的菜单类型");
|
||||
errMap.put(40016, "不合法的按钮个数");
|
||||
errMap.put(40017, "不合法的按钮个数");
|
||||
errMap.put(40018, "不合法的按钮名字长度");
|
||||
errMap.put(40019, "不合法的按钮KEY长度");
|
||||
errMap.put(40020, "不合法的按钮URL长度");
|
||||
errMap.put(40021, "不合法的菜单版本号");
|
||||
errMap.put(40022, "不合法的子菜单级数");
|
||||
errMap.put(40023, "不合法的子菜单按钮个数");
|
||||
errMap.put(40024, "不合法的子菜单按钮类型");
|
||||
errMap.put(40025, "不合法的子菜单按钮名字长度");
|
||||
errMap.put(40026, "不合法的子菜单按钮KEY长度");
|
||||
errMap.put(40027, "不合法的子菜单按钮URL长度");
|
||||
errMap.put(40028, "不合法的自定义菜单使用用户");
|
||||
errMap.put(40029, "不合法的oauth_code");
|
||||
errMap.put(40030, "不合法的refresh_token");
|
||||
errMap.put(40031, "不合法的openid列表");
|
||||
errMap.put(40032, "不合法的openid列表长度");
|
||||
errMap.put(40033, "不合法的请求字符,不能包含\\uxxxx格式的字符");
|
||||
errMap.put(40035, "不合法的参数");
|
||||
errMap.put(40038, "不合法的请求格式");
|
||||
errMap.put(40039, "不合法的URL长度");
|
||||
errMap.put(40050, "不合法的分组id");
|
||||
errMap.put(40051, "分组名字不合法");
|
||||
errMap.put(41001, "缺少access_token参数");
|
||||
errMap.put(41002, "缺少appid参数");
|
||||
errMap.put(41003, "缺少refresh_token参数");
|
||||
errMap.put(41004, "缺少secret参数");
|
||||
errMap.put(41005, "缺少多媒体文件数据");
|
||||
errMap.put(41006, "缺少media_id参数");
|
||||
errMap.put(41007, "缺少子菜单数据");
|
||||
errMap.put(41008, "缺少oauth code");
|
||||
errMap.put(41009, "缺少openid");
|
||||
errMap.put(42001, "access_token超时");
|
||||
errMap.put(42002, "refresh_token超时");
|
||||
errMap.put(42003, "oauth_code超时");
|
||||
errMap.put(43001, "需要GET请求");
|
||||
errMap.put(43002, "需要POST请求");
|
||||
errMap.put(43003, "需要HTTPS请求");
|
||||
errMap.put(43004, "需要接收者关注");
|
||||
errMap.put(43005, "需要好友关系");
|
||||
errMap.put(44001, "多媒体文件为空");
|
||||
errMap.put(44002, "POST的数据包为空");
|
||||
errMap.put(44003, "图文消息内容为空");
|
||||
errMap.put(44004, "文本消息内容为空");
|
||||
errMap.put(45001, "多媒体文件大小超过限制");
|
||||
errMap.put(45002, "消息内容超过限制");
|
||||
errMap.put(45003, "标题字段超过限制");
|
||||
errMap.put(45004, "描述字段超过限制");
|
||||
errMap.put(45005, "链接字段超过限制");
|
||||
errMap.put(45006, "图片链接字段超过限制");
|
||||
errMap.put(45007, "语音播放时间超过限制");
|
||||
errMap.put(45008, "图文消息超过限制");
|
||||
errMap.put(45009, "接口调用超过限制");
|
||||
errMap.put(45010, "创建菜单个数超过限制");
|
||||
errMap.put(45015, "回复时间超过限制");
|
||||
errMap.put(45016, "系统分组,不允许修改");
|
||||
errMap.put(45017, "分组名字过长");
|
||||
errMap.put(45018, "分组数量超过上限");
|
||||
errMap.put(46001, "不存在媒体数据");
|
||||
errMap.put(46002, "不存在的菜单版本");
|
||||
errMap.put(46003, "不存在的菜单数据");
|
||||
errMap.put(46004, "不存在的用户");
|
||||
errMap.put(47001, "解析JSON/XML内容错误");
|
||||
errMap.put(48001, "api功能未授权");
|
||||
errMap.put(50001, "用户未授权该api");
|
||||
}
|
||||
|
||||
protected int errorCode;
|
||||
|
||||
protected String errorMsg;
|
||||
|
||||
public int getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(int errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return errMap.get(errorCode);
|
||||
}
|
||||
|
||||
public static WxError fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxError.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "微信错误 errcode=" + errorCode + ", errmsg=" + errorMsg + ", description=" + getDescription();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 群发消息一发送就返回的结果
|
||||
*
|
||||
* 真正的群发消息是否发送成功要看
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口#.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81.E7.BE.A4.E5.8F.91.E7.BB.93.E6.9E.9C
|
||||
*
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxMassSendResult {
|
||||
|
||||
private String errorCode;
|
||||
private String errorMsg;
|
||||
private String msgId;
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public String getMsgId() {
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public void setMsgId(String msgId) {
|
||||
this.msgId = msgId;
|
||||
}
|
||||
|
||||
public static WxMassSendResult fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMassSendResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxMassSendResult [errcode=" + errorCode + ", errmsg=" + errorMsg + ", msg_id=" + msgId + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 上传群发用的素材的结果
|
||||
* 视频和图文消息需要在群发前上传素材
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxMassUploadResult {
|
||||
|
||||
private String type;
|
||||
private String mediaId;
|
||||
private long createdAt;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public static WxMassUploadResult fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMassUploadResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + mediaId + ", created_at=" + createdAt + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
public class WxMediaUploadResult {
|
||||
|
||||
private String type;
|
||||
private String mediaId;
|
||||
private String thumbMediaId;
|
||||
private long createdAt;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public static WxMediaUploadResult fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + mediaId + ", thumb_media_id=" + thumbMediaId
|
||||
+ ", created_at=" + createdAt + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 换取二维码的Ticket
|
||||
*
|
||||
* @author chanjarster
|
||||
*/
|
||||
public class WxQrCodeTicket {
|
||||
|
||||
protected String ticket;
|
||||
protected int expire_seconds = -1;
|
||||
protected String url;
|
||||
|
||||
public String getTicket() {
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public void setTicket(String ticket) {
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果返回-1说明是永久
|
||||
*/
|
||||
public int getExpire_seconds() {
|
||||
return expire_seconds;
|
||||
}
|
||||
|
||||
public void setExpire_seconds(int expire_seconds) {
|
||||
this.expire_seconds = expire_seconds;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public static WxQrCodeTicket fromJson(String json) {
|
||||
return WxGsonBuilder.INSTANCE.create().fromJson(json, WxQrCodeTicket.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 微信用户信息
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxUser {
|
||||
|
||||
protected boolean subscribe;
|
||||
protected String openId;
|
||||
protected String nickname;
|
||||
protected String sex;
|
||||
protected String language;
|
||||
protected String city;
|
||||
protected String province;
|
||||
protected String country;
|
||||
protected String headImgUrl;
|
||||
protected long subscribeTime;
|
||||
protected String unionId;
|
||||
|
||||
public boolean isSubscribe() {
|
||||
return subscribe;
|
||||
}
|
||||
public void setSubscribe(boolean subscribe) {
|
||||
this.subscribe = subscribe;
|
||||
}
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
public String getHeadImgUrl() {
|
||||
return headImgUrl;
|
||||
}
|
||||
public void setHeadImgUrl(String headImgUrl) {
|
||||
this.headImgUrl = headImgUrl;
|
||||
}
|
||||
public long getSubscribeTime() {
|
||||
return subscribeTime;
|
||||
}
|
||||
public void setSubscribeTime(long subscribeTime) {
|
||||
this.subscribeTime = subscribeTime;
|
||||
}
|
||||
public String getUnionId() {
|
||||
return unionId;
|
||||
}
|
||||
public void setUnionId(String unionId) {
|
||||
this.unionId = unionId;
|
||||
}
|
||||
|
||||
public static WxUser fromJson(String json) {
|
||||
return WxGsonBuilder.INSTANCE.create().fromJson(json, WxUser.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 关注者列表
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public class WxUserList {
|
||||
|
||||
protected int total = -1;
|
||||
protected int count = -1;
|
||||
protected List<String> openIds = new ArrayList<String>();
|
||||
protected String nextOpenId;
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
public List<String> getOpenIds() {
|
||||
return openIds;
|
||||
}
|
||||
public void setOpenIds(List<String> openIds) {
|
||||
this.openIds = openIds;
|
||||
}
|
||||
public String getNextOpenId() {
|
||||
return nextOpenId;
|
||||
}
|
||||
public void setNextOpenId(String nextOpenId) {
|
||||
this.nextOpenId = nextOpenId;
|
||||
}
|
||||
|
||||
public static WxUserList fromJson(String json) {
|
||||
return WxGsonBuilder.INSTANCE.create().fromJson(json, WxUserList.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user