整理及重构

This commit is contained in:
Daniel Qian
2014-10-22 10:29:47 +08:00
parent 67795a092d
commit a8f5d07ff3
212 changed files with 1701 additions and 3459 deletions

View File

@@ -1,31 +0,0 @@
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);
}
}

View File

@@ -1,90 +0,0 @@
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;
}
}
}

View File

@@ -1,23 +1,17 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.bean.custombuilder.*;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
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 {
public class WxMpCustomMessage {
private String toUser;
private String msgType;
@@ -43,12 +37,12 @@ public class WxCustomMessage {
/**
* <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}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_TEXT}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_IMAGE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_VOICE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_MUSIC}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_VIDEO}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#CUSTOM_MSG_NEWS}
* </pre>
* @param msgType
*/
@@ -105,7 +99,7 @@ public class WxCustomMessage {
}
public String toJson() {
return WxGsonBuilder.INSTANCE.create().toJson(this);
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
public static class WxArticle {

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* 微信用户分组
* @author chanjarster
*
*/
public class WxGroup {
public class WxMpGroup {
private long id = -1;
private String name;
@@ -31,16 +31,16 @@ public class WxGroup {
this.count = count;
}
public static WxGroup fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxGroup.class);
public static WxMpGroup fromJson(String json) {
return WxMpGsonBuilder.create().fromJson(json, WxMpGroup.class);
}
public String toJson() {
return WxGsonBuilder.create().toJson(this);
return WxMpGsonBuilder.create().toJson(this);
}
@Override
public String toString() {
return "WxGroup [id=" + id + ", name=" + name + ", count=" + count + "]";
return "WxMpGroup [id=" + id + ", name=" + name + ", count=" + count + "]";
}
}

View File

@@ -1,21 +1,20 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.api.WxConsts;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* 分组群发的消息
*
* @author chanjarster
*/
public class WxMassGroupMessage {
public class WxMpMassGroupMessage {
private long groupId;
private String msgtype;
private String content;
private String mediaId;
public WxMassGroupMessage() {
public WxMpMassGroupMessage() {
super();
}
@@ -26,11 +25,11 @@ public class WxMassGroupMessage {
/**
* <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}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_IMAGE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_NEWS}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_TEXT}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VIDEO}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VOICE}
* 如果msgtype和media_id不匹配的话会返回系统繁忙的错误
* </pre>
* @param msgtype
@@ -56,7 +55,7 @@ public class WxMassGroupMessage {
}
public String toJson() {
return WxGsonBuilder.INSTANCE.create().toJson(this);
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
public long getGroupId() {

View File

@@ -1,16 +1,16 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.util.ArrayList;
import java.util.List;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
/**
* 群发时用到的图文消息素材
* @author chanjarster
*
*/
public class WxMassNews {
public class WxMpMassNews {
private List<WxMassNewsArticle> articles = new ArrayList<WxMassNewsArticle>();
@@ -23,7 +23,7 @@ public class WxMassNews {
}
public String toJson() {
return WxGsonBuilder.INSTANCE.create().toJson(this);
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
/**

View File

@@ -1,23 +1,23 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.util.ArrayList;
import java.util.List;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
/**
* OpenId列表群发的消息
*
* @author chanjarster
*/
public class WxMassOpenIdsMessage {
public class WxMpMassOpenIdsMessage {
private List<String> toUsers = new ArrayList<String>();
private String msgType;
private String content;
private String mediaId;
public WxMassOpenIdsMessage() {
public WxMpMassOpenIdsMessage() {
super();
}
@@ -28,11 +28,11 @@ public class WxMassOpenIdsMessage {
/**
* <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}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_IMAGE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_NEWS}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_TEXT}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VIDEO}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#MASS_MSG_VOICE}
* 如果msgtype和media_id不匹配的话会返回系统繁忙的错误
* </pre>
* @param msgType
@@ -58,7 +58,7 @@ public class WxMassOpenIdsMessage {
}
public String toJson() {
return WxGsonBuilder.INSTANCE.create().toJson(this);
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
/**

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* 群发时用到的视频素材
*
* @author chanjarster
*/
public class WxMassVideo {
public class WxMpMassVideo {
private String mediaId;
private String title;
@@ -38,6 +38,6 @@ public class WxMassVideo {
}
public String toJson() {
return WxGsonBuilder.INSTANCE.create().toJson(this);
return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
}

View File

@@ -1,24 +1,24 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.MediaIdMarshaller;
import me.chanjar.weixin.mp.api.WxMpConsts;
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 {
public class WxMpMpXmlOutImageMessage extends WxMpXmlOutMessage {
@XmlElement(name="Image")
@XmlJavaTypeAdapter(MediaIdMarshaller.class)
private String mediaId;
public WxXmlOutImageMessage() {
this.msgType = WxConsts.XML_MSG_IMAGE;
public WxMpMpXmlOutImageMessage() {
this.msgType = WxMpConsts.XML_MSG_IMAGE;
}
public String getMediaId() {

View File

@@ -1,8 +1,8 @@
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.common.util.xml.AdapterCDATA;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
import me.chanjar.weixin.mp.util.xml.XmlTransformer;
import org.apache.commons.io.IOUtils;
@@ -27,7 +27,7 @@ import java.util.List;
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class WxXmlMessage {
public class WxMpXmlMessage {
///////////////////////
// 以下都是微信推送过来的消息的xml的element所对应的属性
@@ -179,13 +179,13 @@ public class WxXmlMessage {
/**
* <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}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_LOCATION}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_LINK}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_EVENT}
* </pre>
*
* @return
@@ -197,12 +197,12 @@ public class WxXmlMessage {
/**
* <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}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_NEWS}
* {@link me.chanjar.weixin.mp.api.WxMpConsts#XML_MSG_MUSIC}
* </pre>
*
* @param msgType
@@ -379,17 +379,17 @@ public class WxXmlMessage {
this.fromUserName = fromUserName;
}
public static WxXmlMessage fromXml(String xml) {
public static WxMpXmlMessage fromXml(String xml) {
try {
return XmlTransformer.fromXml(WxXmlMessage.class, xml);
return XmlTransformer.fromXml(WxMpXmlMessage.class, xml);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
public static WxXmlMessage fromXml(InputStream is) {
public static WxMpXmlMessage fromXml(InputStream is) {
try {
return XmlTransformer.fromXml(WxXmlMessage.class, is);
return XmlTransformer.fromXml(WxMpXmlMessage.class, is);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
@@ -399,27 +399,27 @@ public class WxXmlMessage {
* 从加密字符串转换
*
* @param encryptedXml
* @param wxConfigStorage
* @param wxMpConfigStorage
* @param timestamp
* @param nonce
* @param msgSignature
* @return
*/
public static WxXmlMessage fromEncryptedXml(
public static WxMpXmlMessage fromEncryptedXml(
String encryptedXml,
WxConfigStorage wxConfigStorage,
WxMpConfigStorage wxMpConfigStorage,
String timestamp, String nonce, String msgSignature) {
WxCryptUtil cryptUtil = new WxCryptUtil(wxConfigStorage);
WxMpCryptUtil cryptUtil = new WxMpCryptUtil(wxMpConfigStorage);
String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml);
return fromXml(plainText);
}
public static WxXmlMessage fromEncryptedXml(
public static WxMpXmlMessage fromEncryptedXml(
InputStream is,
WxConfigStorage wxConfigStorage,
WxMpConfigStorage wxMpConfigStorage,
String timestamp, String nonce, String msgSignature) {
try {
return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxConfigStorage, timestamp, nonce, msgSignature);
return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxMpConfigStorage, timestamp, nonce, msgSignature);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -465,27 +465,27 @@ public class WxXmlMessage {
this.errorCount = errorCount;
}
public WxXmlMessage.ScanCodeInfo getScanCodeInfo() {
public WxMpXmlMessage.ScanCodeInfo getScanCodeInfo() {
return scanCodeInfo;
}
public void setScanCodeInfo(WxXmlMessage.ScanCodeInfo scanCodeInfo) {
public void setScanCodeInfo(WxMpXmlMessage.ScanCodeInfo scanCodeInfo) {
this.scanCodeInfo = scanCodeInfo;
}
public WxXmlMessage.SendPicsInfo getSendPicsInfo() {
public WxMpXmlMessage.SendPicsInfo getSendPicsInfo() {
return sendPicsInfo;
}
public void setSendPicsInfo(WxXmlMessage.SendPicsInfo sendPicsInfo) {
public void setSendPicsInfo(WxMpXmlMessage.SendPicsInfo sendPicsInfo) {
this.sendPicsInfo = sendPicsInfo;
}
public WxXmlMessage.SendLocationInfo getSendLocationInfo() {
public WxMpXmlMessage.SendLocationInfo getSendLocationInfo() {
return sendLocationInfo;
}
public void setSendLocationInfo(WxXmlMessage.SendLocationInfo sendLocationInfo) {
public void setSendLocationInfo(WxMpXmlMessage.SendLocationInfo sendLocationInfo) {
this.sendLocationInfo = sendLocationInfo;
}

View File

@@ -1,5 +1,11 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.bean.outxmlbuilder.*;
import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
import me.chanjar.weixin.mp.util.xml.XmlTransformer;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -7,20 +13,9 @@ 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 {
public class WxMpXmlOutMessage {
@XmlElement(name="ToUserName")
@XmlJavaTypeAdapter(AdapterCDATA.class)
@@ -81,9 +76,9 @@ public class WxXmlOutMessage {
* 转换成加密的xml格式
* @return
*/
public String toEncryptedXml(WxConfigStorage wxConfigStorage) {
public String toEncryptedXml(WxMpConfigStorage wxMpConfigStorage) {
String plainXml = toXml();
WxCryptUtil pc = new WxCryptUtil(wxConfigStorage);
WxMpCryptUtil pc = new WxMpCryptUtil(wxMpConfigStorage);
return pc.encrypt(plainXml);
}

View File

@@ -1,21 +1,16 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;
import me.chanjar.weixin.mp.api.WxMpConsts;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
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 {
public class WxMpXmlOutMewsMessage extends WxMpXmlOutMessage {
@XmlElement(name = "ArticleCount")
protected int articleCount;
@@ -24,8 +19,8 @@ public class WxXmlOutMewsMessage extends WxXmlOutMessage {
@XmlElement(name = "item")
protected final List<Item> articles = new ArrayList<Item>();
public WxXmlOutMewsMessage() {
this.msgType = WxConsts.XML_MSG_NEWS;
public WxMpXmlOutMewsMessage() {
this.msgType = WxMpConsts.XML_MSG_NEWS;
}
public int getArticleCount() {

View File

@@ -1,23 +1,23 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;
import me.chanjar.weixin.mp.api.WxMpConsts;
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 {
public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
@XmlElement(name = "Music")
protected final Music music = new Music();
public WxXmlOutMusicMessage() {
this.msgType = WxConsts.XML_MSG_MUSIC;
public WxMpXmlOutMusicMessage() {
this.msgType = WxMpConsts.XML_MSG_MUSIC;
}
public String getTitle() {

View File

@@ -1,24 +1,24 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;
import me.chanjar.weixin.mp.api.WxMpConsts;
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 {
public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage {
@XmlElement(name="Content")
@XmlJavaTypeAdapter(AdapterCDATA.class)
private String content;
public WxXmlOutTextMessage() {
this.msgType = WxConsts.XML_MSG_TEXT;
public WxMpXmlOutTextMessage() {
this.msgType = WxMpConsts.XML_MSG_TEXT;
}
public String getContent() {

View File

@@ -1,23 +1,23 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;
import me.chanjar.weixin.mp.api.WxMpConsts;
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 {
public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage {
@XmlElement(name = "Video")
protected final Video video = new Video();
public WxXmlOutVideoMessage() {
this.msgType = WxConsts.XML_MSG_VIDEO;
public WxMpXmlOutVideoMessage() {
this.msgType = WxMpConsts.XML_MSG_VIDEO;
}
public String getMediaId() {

View File

@@ -1,24 +1,24 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.util.xml.MediaIdMarshaller;
import me.chanjar.weixin.mp.api.WxMpConsts;
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 {
public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage {
@XmlElement(name="Voice")
@XmlJavaTypeAdapter(MediaIdMarshaller.class)
private String mediaId;
public WxXmlOutVoiceMessage() {
this.msgType = WxConsts.XML_MSG_VOICE;
public WxMpXmlOutVoiceMessage() {
this.msgType = WxMpConsts.XML_MSG_VOICE;
}
public String getMediaId() {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.bean.WxCustomMessage;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
public class BaseBuilder<T> {
protected String msgType;
@@ -11,8 +11,8 @@ public class BaseBuilder<T> {
return (T) this;
}
public WxCustomMessage build() {
WxCustomMessage m = new WxCustomMessage();
public WxMpCustomMessage build() {
WxMpCustomMessage m = new WxMpCustomMessage();
m.setMsgType(this.msgType);
m.setToUser(this.toUser);
return m;

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxCustomMessage;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
* 获得消息builder
* <pre>
* 用法: WxCustomMessage m = WxCustomMessage.IMAGE().mediaId(...).toUser(...).build();
* 用法: WxMpCustomMessage m = WxMpCustomMessage.IMAGE().mediaId(...).toUser(...).build();
* </pre>
* @author chanjarster
*
@@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
private String mediaId;
public ImageBuilder() {
this.msgType = WxConsts.CUSTOM_MSG_IMAGE;
this.msgType = WxMpConsts.CUSTOM_MSG_IMAGE;
}
public ImageBuilder mediaId(String media_id) {
@@ -23,8 +23,8 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
return this;
}
public WxCustomMessage build() {
WxCustomMessage m = super.build();
public WxMpCustomMessage build() {
WxMpCustomMessage m = super.build();
m.setMediaId(this.mediaId);
return m;
}

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxCustomMessage;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
* 音乐消息builder
* <pre>
* 用法: WxCustomMessage m = WxCustomMessage.MUSIC()
* 用法: WxMpCustomMessage m = WxMpCustomMessage.MUSIC()
* .musicUrl(...)
* .hqMusicUrl(...)
* .title(...)
@@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
private String hqMusicUrl;
public MusicBuilder() {
this.msgType = WxConsts.CUSTOM_MSG_MUSIC;
this.msgType = WxMpConsts.CUSTOM_MSG_MUSIC;
}
public MusicBuilder musicUrl(String musicurl) {
@@ -52,8 +52,8 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
return this;
}
public WxCustomMessage build() {
WxCustomMessage m = super.build();
public WxMpCustomMessage build() {
WxMpCustomMessage m = super.build();
m.setMusicUrl(this.musicUrl);
m.setHqMusicUrl(this.hqMusicUrl);
m.setTitle(title);

View File

@@ -1,35 +1,35 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
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();
* WxMpCustomMessage m = WxMpCustomMessage.NEWS().addArticle(article).toUser(...).build();
* </pre>
* @author chanjarster
*
*/
public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
private List<WxCustomMessage.WxArticle> articles = new ArrayList<WxCustomMessage.WxArticle>();
private List<WxMpCustomMessage.WxArticle> articles = new ArrayList<WxMpCustomMessage.WxArticle>();
public NewsBuilder() {
this.msgType = WxConsts.CUSTOM_MSG_NEWS;
this.msgType = WxMpConsts.CUSTOM_MSG_NEWS;
}
public NewsBuilder addArticle(WxCustomMessage.WxArticle article) {
public NewsBuilder addArticle(WxMpCustomMessage.WxArticle article) {
this.articles.add(article);
return this;
}
public WxCustomMessage build() {
WxCustomMessage m = super.build();
public WxMpCustomMessage build() {
WxMpCustomMessage m = super.build();
m.setArticles(this.articles);
return m;
}

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxCustomMessage;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
* 文本消息builder
* <pre>
* 用法: WxCustomMessage m = WxCustomMessage.TEXT().content(...).toUser(...).build();
* 用法: WxMpCustomMessage m = WxMpCustomMessage.TEXT().content(...).toUser(...).build();
* </pre>
* @author chanjarster
*
@@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
private String content;
public TextBuilder() {
this.msgType = WxConsts.CUSTOM_MSG_TEXT;
this.msgType = WxMpConsts.CUSTOM_MSG_TEXT;
}
public TextBuilder content(String content) {
@@ -23,8 +23,8 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
return this;
}
public WxCustomMessage build() {
WxCustomMessage m = super.build();
public WxMpCustomMessage build() {
WxMpCustomMessage m = super.build();
m.setContent(this.content);
return m;
}

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxCustomMessage;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
* 视频消息builder
* <pre>
* 用法: WxCustomMessage m = WxCustomMessage.VOICE()
* 用法: WxMpCustomMessage m = WxMpCustomMessage.VOICE()
* .mediaId(...)
* .title(...)
* .thumbMediaId(..)
@@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
private String thumbMediaId;
public VideoBuilder() {
this.msgType = WxConsts.CUSTOM_MSG_VIDEO;
this.msgType = WxMpConsts.CUSTOM_MSG_VIDEO;
}
public VideoBuilder mediaId(String mediaId) {
@@ -47,8 +47,8 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
return this;
}
public WxCustomMessage build() {
WxCustomMessage m = super.build();
public WxMpCustomMessage build() {
WxMpCustomMessage m = super.build();
m.setMediaId(this.mediaId);
m.setTitle(title);
m.setDescription(description);

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxCustomMessage;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
* 语音消息builder
* <pre>
* 用法: WxCustomMessage m = WxCustomMessage.VOICE().mediaId(...).toUser(...).build();
* 用法: WxMpCustomMessage m = WxMpCustomMessage.VOICE().mediaId(...).toUser(...).build();
* </pre>
* @author chanjarster
*
@@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
private String mediaId;
public VoiceBuilder() {
this.msgType = WxConsts.CUSTOM_MSG_VOICE;
this.msgType = WxMpConsts.CUSTOM_MSG_VOICE;
}
public VoiceBuilder mediaId(String media_id) {
@@ -23,8 +23,8 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
return this;
}
public WxCustomMessage build() {
WxCustomMessage m = super.build();
public WxMpCustomMessage build() {
WxMpCustomMessage m = super.build();
m.setMediaId(this.mediaId);
return m;
}

View File

@@ -1,7 +1,6 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxXmlOutMessage;
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
public abstract class BaseBuilder<BuilderType, ValueType> {
@@ -21,7 +20,7 @@ public abstract class BaseBuilder<BuilderType, ValueType> {
public abstract ValueType build();
public void setCommon(WxXmlOutMessage m) {
public void setCommon(WxMpXmlOutMessage m) {
m.setToUserName(this.toUserName);
m.setFromUserName(this.fromUserName);
m.setCreateTime(System.currentTimeMillis() / 1000l);

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxXmlOutImageMessage;
import me.chanjar.weixin.mp.bean.WxMpMpXmlOutImageMessage;
/**
* 图片消息builder
* @author chanjarster
*/
public final class ImageBuilder extends BaseBuilder<ImageBuilder, WxXmlOutImageMessage> {
public final class ImageBuilder extends BaseBuilder<ImageBuilder, WxMpMpXmlOutImageMessage> {
private String mediaId;
@@ -15,8 +15,8 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder, WxXmlOutImageM
return this;
}
public WxXmlOutImageMessage build() {
WxXmlOutImageMessage m = new WxXmlOutImageMessage();
public WxMpMpXmlOutImageMessage build() {
WxMpMpXmlOutImageMessage m = new WxMpMpXmlOutImageMessage();
setCommon(m);
m.setMediaId(this.mediaId);
return m;

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxXmlOutMusicMessage;
import me.chanjar.weixin.mp.bean.WxMpXmlOutMusicMessage;
/**
* 音乐消息builder
*
* @author chanjarster
*/
public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxXmlOutMusicMessage> {
public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxMpXmlOutMusicMessage> {
private String title;
private String description;
@@ -40,8 +40,8 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxXmlOutMusicM
return this;
}
public WxXmlOutMusicMessage build() {
WxXmlOutMusicMessage m = new WxXmlOutMusicMessage();
public WxMpXmlOutMusicMessage build() {
WxMpXmlOutMusicMessage m = new WxMpXmlOutMusicMessage();
setCommon(m);
m.setTitle(title);
m.setDescription(description);

View File

@@ -1,26 +1,26 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxMpXmlOutMewsMessage;
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> {
public final class NewsBuilder extends BaseBuilder<NewsBuilder, WxMpXmlOutMewsMessage> {
protected final List<WxXmlOutMewsMessage.Item> articles = new ArrayList<WxXmlOutMewsMessage.Item>();
protected final List<WxMpXmlOutMewsMessage.Item> articles = new ArrayList<WxMpXmlOutMewsMessage.Item>();
public NewsBuilder addArticle(WxXmlOutMewsMessage.Item item) {
public NewsBuilder addArticle(WxMpXmlOutMewsMessage.Item item) {
this.articles.add(item);
return this;
}
public WxXmlOutMewsMessage build() {
WxXmlOutMewsMessage m = new WxXmlOutMewsMessage();
for(WxXmlOutMewsMessage.Item item : articles) {
public WxMpXmlOutMewsMessage build() {
WxMpXmlOutMewsMessage m = new WxMpXmlOutMewsMessage();
for(WxMpXmlOutMewsMessage.Item item : articles) {
m.addArticle(item);
}
setCommon(m);

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxXmlOutTextMessage;
import me.chanjar.weixin.mp.bean.WxMpXmlOutTextMessage;
/**
* 文本消息builder
* @author chanjarster
*
*/
public final class TextBuilder extends BaseBuilder<TextBuilder, WxXmlOutTextMessage> {
public final class TextBuilder extends BaseBuilder<TextBuilder, WxMpXmlOutTextMessage> {
private String content;
public TextBuilder content(String content) {
@@ -15,8 +15,8 @@ public final class TextBuilder extends BaseBuilder<TextBuilder, WxXmlOutTextMess
return this;
}
public WxXmlOutTextMessage build() {
WxXmlOutTextMessage m = new WxXmlOutTextMessage();
public WxMpXmlOutTextMessage build() {
WxMpXmlOutTextMessage m = new WxMpXmlOutTextMessage();
setCommon(m);
m.setContent(this.content);
return m;

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxXmlOutVideoMessage;
import me.chanjar.weixin.mp.bean.WxMpXmlOutVideoMessage;
/**
* 视频消息builder
* @author chanjarster
*
*/
public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxXmlOutVideoMessage> {
public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxMpXmlOutVideoMessage> {
private String mediaId;
private String title;
@@ -26,8 +26,8 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxXmlOutVideoM
return this;
}
public WxXmlOutVideoMessage build() {
WxXmlOutVideoMessage m = new WxXmlOutVideoMessage();
public WxMpXmlOutVideoMessage build() {
WxMpXmlOutVideoMessage m = new WxMpXmlOutVideoMessage();
setCommon(m);
m.setTitle(title);
m.setDescription(description);

View File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.mp.bean.outxmlbuilder;
import me.chanjar.weixin.mp.bean.WxXmlOutVoiceMessage;
import me.chanjar.weixin.mp.bean.WxMpXmlOutVoiceMessage;
/**
* 语音消息builder
* @author chanjarster
*/
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder, WxXmlOutVoiceMessage> {
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder, WxMpXmlOutVoiceMessage> {
private String mediaId;
@@ -15,8 +15,8 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder, WxXmlOutVoiceM
return this;
}
public WxXmlOutVoiceMessage build() {
WxXmlOutVoiceMessage m = new WxXmlOutVoiceMessage();
public WxMpXmlOutVoiceMessage build() {
WxMpXmlOutVoiceMessage m = new WxMpXmlOutVoiceMessage();
setCommon(m);
m.setMediaId(mediaId);
return m;

View File

@@ -1,136 +0,0 @@
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();
}
}

View File

@@ -1,54 +0,0 @@
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 + "]";
}
}

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.result;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* <pre>
@@ -13,7 +13,7 @@ import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
* @author chanjarster
*
*/
public class WxMassSendResult {
public class WxMpMassSendResult {
private String errorCode;
private String errorMsg;
@@ -43,8 +43,8 @@ public class WxMassSendResult {
this.msgId = msgId;
}
public static WxMassSendResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxMassSendResult.class);
public static WxMpMassSendResult fromJson(String json) {
return WxMpGsonBuilder.create().fromJson(json, WxMpMassSendResult.class);
}
@Override

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.result;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* <pre>
@@ -10,7 +10,7 @@ import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
* @author chanjarster
*
*/
public class WxMassUploadResult {
public class WxMpMassUploadResult {
private String type;
private String mediaId;
@@ -40,8 +40,8 @@ public class WxMassUploadResult {
this.createdAt = createdAt;
}
public static WxMassUploadResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxMassUploadResult.class);
public static WxMpMassUploadResult fromJson(String json) {
return WxMpGsonBuilder.create().fromJson(json, WxMpMassUploadResult.class);
}
@Override

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean.result;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* 换取二维码的Ticket
*
* @author chanjarster
*/
public class WxQrCodeTicket {
public class WxMpQrCodeTicket {
protected String ticket;
protected int expire_seconds = -1;
@@ -40,7 +40,7 @@ public class WxQrCodeTicket {
this.url = url;
}
public static WxQrCodeTicket fromJson(String json) {
return WxGsonBuilder.INSTANCE.create().fromJson(json, WxQrCodeTicket.class);
public static WxMpQrCodeTicket fromJson(String json) {
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpQrCodeTicket.class);
}
}

View File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.bean.result;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
/**
* 微信用户信息
* @author chanjarster
*
*/
public class WxUser {
public class WxMpUser {
protected boolean subscribe;
protected String openId;
@@ -88,8 +88,8 @@ public class WxUser {
this.unionId = unionId;
}
public static WxUser fromJson(String json) {
return WxGsonBuilder.INSTANCE.create().fromJson(json, WxUser.class);
public static WxMpUser fromJson(String json) {
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUser.class);
}
}

View File

@@ -1,16 +1,16 @@
package me.chanjar.weixin.mp.bean.result;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.util.ArrayList;
import java.util.List;
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
/**
* 关注者列表
* @author chanjarster
*
*/
public class WxUserList {
public class WxMpUserList {
protected int total = -1;
protected int count = -1;
@@ -41,7 +41,7 @@ public class WxUserList {
this.nextOpenId = nextOpenId;
}
public static WxUserList fromJson(String json) {
return WxGsonBuilder.INSTANCE.create().fromJson(json, WxUserList.class);
public static WxMpUserList fromJson(String json) {
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUserList.class);
}
}