polish code

This commit is contained in:
Daniel Qian
2014-10-22 13:38:16 +08:00
parent f76f0e6773
commit 2c96d542d6
31 changed files with 145 additions and 220 deletions

View File

@@ -1,128 +0,0 @@
package me.chanjar.weixin.mp.api;
import java.util.HashMap;
import java.util.Map;
public class WxMpConsts {
///////////////////////
// 微信推送过来的消息的类型和发送给微信xml格式消息的消息类型
///////////////////////
public static final String XML_MSG_TEXT = "text";
public static final String XML_MSG_IMAGE = "image";
public static final String XML_MSG_VOICE = "voice";
public static final String XML_MSG_VIDEO = "video";
public static final String XML_MSG_NEWS = "news";
public static final String XML_MSG_MUSIC = "music";
public static final String XML_MSG_LOCATION = "location";
public static final String XML_MSG_LINK = "link";
public static final String XML_MSG_EVENT = "event";
public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
///////////////////////
// 客服消息的消息类型
///////////////////////
public static final String CUSTOM_MSG_TEXT = "text";
public static final String CUSTOM_MSG_IMAGE = "image";
public static final String CUSTOM_MSG_VOICE = "voice";
public static final String CUSTOM_MSG_VIDEO = "video";
public static final String CUSTOM_MSG_MUSIC = "music";
public static final String CUSTOM_MSG_NEWS = "news";
///////////////////////
// 群发消息的消息类型
///////////////////////
public static final String MASS_MSG_NEWS = "mpnews";
public static final String MASS_MSG_TEXT = "text";
public static final String MASS_MSG_VOICE = "voice";
public static final String MASS_MSG_IMAGE = "image";
public static final String MASS_MSG_VIDEO = "mpvideo";
///////////////////////
// 群发消息后微信端推送给服务器的反馈消息
///////////////////////
public static final String MASS_ST_SUCCESS = "send success";
public static final String MASS_ST_FAIL = "send fail";
public static final String MASS_ST_涉嫌广告 = "err(10001)";
public static final String MASS_ST_涉嫌政治 = "err(20001)";
public static final String MASS_ST_涉嫌社会 = "err(20004)";
public static final String MASS_ST_涉嫌色情 = "err(20002)";
public static final String MASS_ST_涉嫌违法犯罪 = "err(20006)";
public static final String MASS_ST_涉嫌欺诈 = "err(20008)";
public static final String MASS_ST_涉嫌版权 = "err(20013)";
public static final String MASS_ST_涉嫌互推_互相宣传 = "err(22000)";
public static final String MASS_ST_涉嫌其他 = "err(21000)";
/**
* 群发反馈消息代码所对应的文字描述
*/
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<String, String>();
static {
MASS_ST_2_DESC.put(MASS_ST_SUCCESS, "发送成功");
MASS_ST_2_DESC.put(MASS_ST_FAIL, "发送失败");
MASS_ST_2_DESC.put(MASS_ST_涉嫌广告, "涉嫌广告");
MASS_ST_2_DESC.put(MASS_ST_涉嫌政治, "涉嫌政治");
MASS_ST_2_DESC.put(MASS_ST_涉嫌社会, "涉嫌社会");
MASS_ST_2_DESC.put(MASS_ST_涉嫌色情, "涉嫌色情");
MASS_ST_2_DESC.put(MASS_ST_涉嫌违法犯罪, "涉嫌违法犯罪");
MASS_ST_2_DESC.put(MASS_ST_涉嫌欺诈, "涉嫌欺诈");
MASS_ST_2_DESC.put(MASS_ST_涉嫌版权, "涉嫌版权");
MASS_ST_2_DESC.put(MASS_ST_涉嫌互推_互相宣传, "涉嫌互推_互相宣传");
MASS_ST_2_DESC.put(MASS_ST_涉嫌其他, "涉嫌其他");
}
///////////////////////
// 微信端推送过来的事件类型
///////////////////////
public static final String EVT_SUBSCRIBE = "subscribe";
public static final String EVT_UNSUBSCRIBE = "unsubscribe";
public static final String EVT_SCAN = "SCAN";
public static final String EVT_LOCATION = "LOCATION";
public static final String EVT_CLICK = "CLICK";
public static final String EVT_VIEW = "VIEW";
public static final String EVT_MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH";
public static final String EVT_SCANCODE_PUSH = "scancode_push";
public static final String EVT_SCANCODE_WAITMSG = "scancode_waitmsg";
public static final String EVT_PIC_SYSPHOTO = "pic_sysphoto";
public static final String EVT_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
public static final String EVT_PIC_WEIXIN = "pic_weixin";
public static final String EVT_LOCATION_SELECT = "location_select";
///////////////////////
// 上传多媒体文件的类型
///////////////////////
public static final String MEDIA_IMAGE = "image";
public static final String MEDIA_VOICE = "voice";
public static final String MEDIA_VIDEO = "video";
public static final String MEDIA_THUMB = "thumb";
///////////////////////
// 文件类型
///////////////////////
public static final String FILE_JPG = "jpeg";
public static final String FILE_MP3 = "mp3";
public static final String FILE_ARM = "arm";
public static final String FILE_MP4 = "mp4";
///////////////////////
// 自定义菜单的按钮类型
///////////////////////
/** 点击推事件 */
public static final String BUTTON_CLICK = "click";
/** 跳转URL */
public static final String BUTTON_VIEW = "view";
/** 扫码推事件 */
public static final String BUTTON_SCANCODE_PUSH = "scancode_push";
/** 扫码推事件且弹出“消息接收中”提示框 */
public static final String BUTTON_SCANCODE_WAITMSG = "scancode_waitmsg";
/** 弹出系统拍照发图 */
public static final String PIC_SYSPHOTO = "pic_sysphoto";
/** 弹出拍照或者相册发图 */
public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
/** 弹出微信相册发图器 */
public static final String PIC_WEIXIN = "pic_weixin";
/** 弹出地理位置选择器 */
public static final String LOCATION_SELECT = "location_select";
}

View File

@@ -55,8 +55,8 @@ public interface WxMpService {
*
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
* </pre>
* @param mediaType 媒体类型, 请看{@link WxMpConsts}
* @param fileType 文件类型,请看{@link WxMpConsts}
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts}
* @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts}
* @param inputStream 输入流
* @throws WxErrorException
*/

View File

@@ -37,12 +37,12 @@ public class WxMpCustomMessage {
/**
* <pre>
* 请使用
* {@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}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
* </pre>
* @param msgType
*/

View File

@@ -25,11 +25,11 @@ public class WxMpMassGroupMessage {
/**
* <pre>
* 请使用
* {@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}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
* 如果msgtype和media_id不匹配的话会返回系统繁忙的错误
* </pre>
* @param msgtype

View File

@@ -12,13 +12,13 @@ import java.util.List;
*/
public class WxMpMassNews {
private List<WxMassNewsArticle> articles = new ArrayList<WxMassNewsArticle>();
private List<WxMpMassNewsArticle> articles = new ArrayList<WxMpMassNewsArticle>();
public List<WxMassNewsArticle> getArticles() {
public List<WxMpMassNewsArticle> getArticles() {
return articles;
}
public void addArticle(WxMassNewsArticle article) {
public void addArticle(WxMpMassNewsArticle article) {
this.articles.add(article);
}
@@ -40,7 +40,7 @@ public class WxMpMassNews {
* @author chanjarster
*
*/
public static class WxMassNewsArticle {
public static class WxMpMassNewsArticle {
/**
* (必填) 图文消息缩略图的media_id可以在基础支持-上传多媒体文件接口中获得
*/

View File

@@ -28,11 +28,11 @@ public class WxMpMassOpenIdsMessage {
/**
* <pre>
* 请使用
* {@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}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
* 如果msgtype和media_id不匹配的话会返回系统繁忙的错误
* </pre>
* @param msgType

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.api.WxConsts;
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;
@@ -18,7 +18,7 @@ public class WxMpMpXmlOutImageMessage extends WxMpXmlOutMessage {
private String mediaId;
public WxMpMpXmlOutImageMessage() {
this.msgType = WxMpConsts.XML_MSG_IMAGE;
this.msgType = WxConsts.XML_MSG_IMAGE;
}
public String getMediaId() {

View File

@@ -179,13 +179,13 @@ public class WxMpXmlMessage {
/**
* <pre>
* 当接受用户消息时,可能会获得以下值:
* {@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}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
* </pre>
*
* @return
@@ -197,12 +197,12 @@ public class WxMpXmlMessage {
/**
* <pre>
* 当发送消息的时候使用:
* {@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}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_MUSIC}
* </pre>
*
* @param msgType

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.api.WxConsts;
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;
@@ -20,7 +20,7 @@ public class WxMpXmlOutMewsMessage extends WxMpXmlOutMessage {
protected final List<Item> articles = new ArrayList<Item>();
public WxMpXmlOutMewsMessage() {
this.msgType = WxMpConsts.XML_MSG_NEWS;
this.msgType = WxConsts.XML_MSG_NEWS;
}
public int getArticleCount() {

View File

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

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.api.WxConsts;
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;
@@ -18,7 +18,7 @@ public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage {
private String content;
public WxMpXmlOutTextMessage() {
this.msgType = WxMpConsts.XML_MSG_TEXT;
this.msgType = WxConsts.XML_MSG_TEXT;
}
public String getContent() {

View File

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

View File

@@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.common.api.WxConsts;
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;
@@ -18,7 +18,7 @@ public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage {
private String mediaId;
public WxMpXmlOutVoiceMessage() {
this.msgType = WxMpConsts.XML_MSG_VOICE;
this.msgType = WxConsts.XML_MSG_VOICE;
}
public String getMediaId() {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
@@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
private String mediaId;
public ImageBuilder() {
this.msgType = WxMpConsts.CUSTOM_MSG_IMAGE;
this.msgType = WxConsts.CUSTOM_MSG_IMAGE;
}
public ImageBuilder mediaId(String media_id) {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
@@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
private String hqMusicUrl;
public MusicBuilder() {
this.msgType = WxMpConsts.CUSTOM_MSG_MUSIC;
this.msgType = WxConsts.CUSTOM_MSG_MUSIC;
}
public MusicBuilder musicUrl(String musicurl) {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
import java.util.ArrayList;
@@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
private List<WxMpCustomMessage.WxArticle> articles = new ArrayList<WxMpCustomMessage.WxArticle>();
public NewsBuilder() {
this.msgType = WxMpConsts.CUSTOM_MSG_NEWS;
this.msgType = WxConsts.CUSTOM_MSG_NEWS;
}
public NewsBuilder addArticle(WxMpCustomMessage.WxArticle article) {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
@@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
private String content;
public TextBuilder() {
this.msgType = WxMpConsts.CUSTOM_MSG_TEXT;
this.msgType = WxConsts.CUSTOM_MSG_TEXT;
}
public TextBuilder content(String content) {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
@@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
private String thumbMediaId;
public VideoBuilder() {
this.msgType = WxMpConsts.CUSTOM_MSG_VIDEO;
this.msgType = WxConsts.CUSTOM_MSG_VIDEO;
}
public VideoBuilder mediaId(String mediaId) {

View File

@@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.bean.custombuilder;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
/**
@@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
private String mediaId;
public VoiceBuilder() {
this.msgType = WxMpConsts.CUSTOM_MSG_VOICE;
this.msgType = WxConsts.CUSTOM_MSG_VOICE;
}
public VoiceBuilder mediaId(String media_id) {

View File

@@ -9,7 +9,7 @@
package me.chanjar.weixin.mp.util.json;
import com.google.gson.*;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
import java.lang.reflect.Type;
@@ -26,25 +26,25 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe
messageJson.addProperty("touser", message.getToUser());
messageJson.addProperty("msgtype", message.getMsgType());
if (WxMpConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) {
JsonObject text = new JsonObject();
text.addProperty("content", message.getContent());
messageJson.add("text", text);
}
if (WxMpConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) {
JsonObject image = new JsonObject();
image.addProperty("media_id", message.getMediaId());
messageJson.add("image", image);
}
if (WxMpConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) {
JsonObject voice = new JsonObject();
voice.addProperty("media_id", message.getMediaId());
messageJson.add("voice", voice);
}
if (WxMpConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) {
JsonObject video = new JsonObject();
video.addProperty("media_id", message.getMediaId());
video.addProperty("thumb_media_id", message.getThumbMediaId());
@@ -53,7 +53,7 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe
messageJson.add("video", video);
}
if (WxMpConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) {
JsonObject music = new JsonObject();
music.addProperty("title", message.getTitle());
music.addProperty("description", message.getDescription());
@@ -63,7 +63,7 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializer<WxMpCustomMe
messageJson.add("music", music);
}
if (WxMpConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) {
JsonArray articleJsonArray = new JsonArray();
for (WxMpCustomMessage.WxArticle article : message.getArticles()) {
JsonObject articleJson = new JsonObject();

View File

@@ -12,7 +12,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage;
import java.lang.reflect.Type;
@@ -31,30 +31,30 @@ public class WxMpMassMessageGsonAdapter implements JsonSerializer<WxMpMassGroupM
filter.addProperty("group_id", message.getGroupId());
messageJson.add("filter", filter);
if (WxMpConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) {
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_NEWS, sub);
messageJson.add(WxConsts.MASS_MSG_NEWS, sub);
}
if (WxMpConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) {
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) {
JsonObject sub = new JsonObject();
sub.addProperty("content", message.getContent());
messageJson.add(WxMpConsts.MASS_MSG_TEXT, sub);
messageJson.add(WxConsts.MASS_MSG_TEXT, sub);
}
if (WxMpConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) {
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_VOICE, sub);
messageJson.add(WxConsts.MASS_MSG_VOICE, sub);
}
if (WxMpConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) {
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_IMAGE, sub);
messageJson.add(WxConsts.MASS_MSG_IMAGE, sub);
}
if (WxMpConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) {
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_VIDEO, sub);
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub);
}
messageJson.addProperty("msgtype", message.getMsgtype());
return messageJson;

View File

@@ -24,7 +24,7 @@ public class WxMpMassNewsGsonAdapter implements JsonSerializer<WxMpMassNews> {
JsonObject newsJson = new JsonObject();
JsonArray articleJsonArray = new JsonArray();
for (WxMpMassNews.WxMassNewsArticle article : message.getArticles()) {
for (WxMpMassNews.WxMpMassNewsArticle article : message.getArticles()) {
JsonObject articleJson = new JsonObject();
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
articleJson.addProperty("title", article.getTitle());

View File

@@ -9,7 +9,7 @@
package me.chanjar.weixin.mp.util.json;
import com.google.gson.*;
import me.chanjar.weixin.mp.api.WxMpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
import java.lang.reflect.Type;
@@ -30,30 +30,30 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas
}
messageJson.add("touser", toUsers);
if (WxMpConsts.MASS_MSG_NEWS.equals(message.getMsgType())) {
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_NEWS, sub);
messageJson.add(WxConsts.MASS_MSG_NEWS, sub);
}
if (WxMpConsts.MASS_MSG_TEXT.equals(message.getMsgType())) {
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) {
JsonObject sub = new JsonObject();
sub.addProperty("content", message.getContent());
messageJson.add(WxMpConsts.MASS_MSG_TEXT, sub);
messageJson.add(WxConsts.MASS_MSG_TEXT, sub);
}
if (WxMpConsts.MASS_MSG_VOICE.equals(message.getMsgType())) {
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_VOICE, sub);
messageJson.add(WxConsts.MASS_MSG_VOICE, sub);
}
if (WxMpConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) {
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_IMAGE, sub);
messageJson.add(WxConsts.MASS_MSG_IMAGE, sub);
}
if (WxMpConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) {
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) {
JsonObject sub = new JsonObject();
sub.addProperty("media_id", message.getMediaId());
messageJson.add(WxMpConsts.MASS_MSG_VIDEO, sub);
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub);
}
messageJson.addProperty("msgtype", message.getMsgType());
return messageJson;