mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
公众平台增加群发接口对原创校验逻辑的支持
This commit is contained in:
@@ -19,13 +19,13 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas
|
||||
@Override
|
||||
public JsonElement serialize(WxMpMassOpenIdsMessage message, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject messageJson = new JsonObject();
|
||||
|
||||
|
||||
JsonArray toUsers = new JsonArray();
|
||||
for (String openId : message.getToUsers()) {
|
||||
toUsers.add(new JsonPrimitive(openId));
|
||||
}
|
||||
messageJson.add("touser", toUsers);
|
||||
|
||||
|
||||
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
@@ -52,6 +52,7 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas
|
||||
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub);
|
||||
}
|
||||
messageJson.addProperty("msgtype", message.getMsgType());
|
||||
messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1);
|
||||
return messageJson;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxMpMassSendResultAdapter implements JsonDeserializer<WxMpMassSendResult> {
|
||||
|
||||
@@ -40,5 +38,5 @@ public class WxMpMassSendResultAdapter implements JsonDeserializer<WxMpMassSendR
|
||||
}
|
||||
return sendResult;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,57 +8,57 @@
|
||||
*/
|
||||
package me.chanjar.weixin.mp.util.json;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTagMessage> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(WxMpMassTagMessage message, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject messageJson = new JsonObject();
|
||||
|
||||
|
||||
JsonObject filter = new JsonObject();
|
||||
if(null == message.getTagId()) {
|
||||
if (null == message.getTagId()) {
|
||||
filter.addProperty("is_to_all", true);
|
||||
} else {
|
||||
filter.addProperty("is_to_all", false);
|
||||
filter.addProperty("tag_id", message.getTagId());
|
||||
}
|
||||
messageJson.add("filter", filter);
|
||||
|
||||
if (WxConsts.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(WxConsts.MASS_MSG_NEWS, sub);
|
||||
}
|
||||
if (WxConsts.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(WxConsts.MASS_MSG_TEXT, sub);
|
||||
}
|
||||
if (WxConsts.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(WxConsts.MASS_MSG_VOICE, sub);
|
||||
}
|
||||
if (WxConsts.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(WxConsts.MASS_MSG_IMAGE, sub);
|
||||
}
|
||||
if (WxConsts.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(WxConsts.MASS_MSG_VIDEO, sub);
|
||||
}
|
||||
messageJson.addProperty("msgtype", message.getMsgtype());
|
||||
messageJson.addProperty("msgtype", message.getMsgType());
|
||||
messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1);
|
||||
return messageJson;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user