mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	公众平台增加群发接口对原创校验逻辑的支持
This commit is contained in:
		| @ -1,11 +1,11 @@ | |||||||
| package me.chanjar.weixin.mp.bean; | package me.chanjar.weixin.mp.bean; | ||||||
|  |  | ||||||
|  | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||||
|  |  | ||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * openid列表群发的消息 |  * openid列表群发的消息 | ||||||
|  * |  * | ||||||
| @ -18,6 +18,7 @@ public class WxMpMassOpenIdsMessage implements Serializable { | |||||||
|   private String msgType; |   private String msgType; | ||||||
|   private String content; |   private String content; | ||||||
|   private String mediaId; |   private String mediaId; | ||||||
|  |   private boolean sendIgnoreReprint = false; | ||||||
|  |  | ||||||
|   public WxMpMassOpenIdsMessage() { |   public WxMpMassOpenIdsMessage() { | ||||||
|     super(); |     super(); | ||||||
| @ -86,4 +87,15 @@ public class WxMpMassOpenIdsMessage implements Serializable { | |||||||
|     this.toUsers = toUsers; |     this.toUsers = toUsers; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   public boolean isSendIgnoreReprint() { | ||||||
|  |     return sendIgnoreReprint; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * | ||||||
|  |    * @param sendIgnoreReprint 文章被判定为转载时,是否继续进行群发操作。 | ||||||
|  |    */ | ||||||
|  |   public void setSendIgnoreReprint(boolean sendIgnoreReprint) { | ||||||
|  |     this.sendIgnoreReprint = sendIgnoreReprint; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| package me.chanjar.weixin.mp.bean; | package me.chanjar.weixin.mp.bean; | ||||||
|  |  | ||||||
| import java.io.Serializable; |  | ||||||
|  |  | ||||||
| import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||||
|  |  | ||||||
|  | import java.io.Serializable; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 按标签群发的消息 |  * 按标签群发的消息 | ||||||
|  * |  * | ||||||
| @ -13,16 +13,17 @@ public class WxMpMassTagMessage implements Serializable { | |||||||
|  |  | ||||||
|   private static final long serialVersionUID = -6625914040986749286L; |   private static final long serialVersionUID = -6625914040986749286L; | ||||||
|   private Long tagId; |   private Long tagId; | ||||||
|   private String msgtype; |   private String msgType; | ||||||
|   private String content; |   private String content; | ||||||
|   private String mediaId; |   private String mediaId; | ||||||
|  |   private boolean sendIgnoreReprint = false; | ||||||
|  |  | ||||||
|   public WxMpMassTagMessage() { |   public WxMpMassTagMessage() { | ||||||
|     super(); |     super(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public String getMsgtype() { |   public String getMsgType() { | ||||||
|     return this.msgtype; |     return this.msgType; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
| @ -35,10 +36,11 @@ public class WxMpMassTagMessage implements Serializable { | |||||||
|    * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} |    * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE} | ||||||
|    * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 |    * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误 | ||||||
|    * </pre> |    * </pre> | ||||||
|    * @param msgtype |    * | ||||||
|  |    * @param msgType 消息类型 | ||||||
|    */ |    */ | ||||||
|   public void setMsgtype(String msgtype) { |   public void setMsgType(String msgType) { | ||||||
|     this.msgtype = msgtype; |     this.msgType = msgType; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public String getContent() { |   public String getContent() { | ||||||
| @ -67,10 +69,23 @@ public class WxMpMassTagMessage implements Serializable { | |||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 如果不设置则就意味着发给所有用户 |    * 如果不设置则就意味着发给所有用户 | ||||||
|    * @param tagId |    * | ||||||
|  |    * @param tagId 标签id | ||||||
|    */ |    */ | ||||||
|   public void setTagId(Long tagId) { |   public void setTagId(Long tagId) { | ||||||
|     this.tagId = tagId; |     this.tagId = tagId; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   public boolean isSendIgnoreReprint() { | ||||||
|  |     return sendIgnoreReprint; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * | ||||||
|  |    * @param sendIgnoreReprint 文章被判定为转载时,是否继续进行群发操作。 | ||||||
|  |    */ | ||||||
|  |   public void setSendIgnoreReprint(boolean sendIgnoreReprint) { | ||||||
|  |     this.sendIgnoreReprint = sendIgnoreReprint; | ||||||
|  |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| package me.chanjar.weixin.mp.bean.result; | package me.chanjar.weixin.mp.bean.result; | ||||||
|  |  | ||||||
|  | import me.chanjar.weixin.common.util.ToStringUtils; | ||||||
| import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||||
|  |  | ||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
| @ -16,10 +17,6 @@ import java.io.Serializable; | |||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| public class WxMpMassSendResult implements Serializable { | public class WxMpMassSendResult implements Serializable { | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    *  |  | ||||||
|    */ |  | ||||||
|   private static final long serialVersionUID = -4816336807575562818L; |   private static final long serialVersionUID = -4816336807575562818L; | ||||||
|   private String errorCode; |   private String errorCode; | ||||||
|   private String errorMsg; |   private String errorMsg; | ||||||
| @ -64,7 +61,7 @@ public class WxMpMassSendResult implements Serializable { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public String toString() { |   public String toString() { | ||||||
|     return "WxMassSendResult [errcode=" + this.errorCode + ", errmsg=" + this.errorMsg + ", msg_id=" + this.msgId + "]"; |     return ToStringUtils.toSimpleString(this); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -52,6 +52,7 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas | |||||||
|       messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); |       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; |     return messageJson; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -15,9 +15,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; | |||||||
| import java.lang.reflect.Type; | import java.lang.reflect.Type; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  *  |  | ||||||
|  * @author Daniel Qian |  * @author Daniel Qian | ||||||
|  * |  | ||||||
|  */ |  */ | ||||||
| public class WxMpMassSendResultAdapter implements JsonDeserializer<WxMpMassSendResult> { | public class WxMpMassSendResultAdapter implements JsonDeserializer<WxMpMassSendResult> { | ||||||
|  |  | ||||||
|  | |||||||
| @ -8,16 +8,15 @@ | |||||||
|  */ |  */ | ||||||
| package me.chanjar.weixin.mp.util.json; | package me.chanjar.weixin.mp.util.json; | ||||||
|  |  | ||||||
| import java.lang.reflect.Type; |  | ||||||
|  |  | ||||||
| import com.google.gson.JsonElement; | import com.google.gson.JsonElement; | ||||||
| import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||||
| import com.google.gson.JsonSerializationContext; | import com.google.gson.JsonSerializationContext; | ||||||
| import com.google.gson.JsonSerializer; | import com.google.gson.JsonSerializer; | ||||||
|  |  | ||||||
| import me.chanjar.weixin.common.api.WxConsts; | import me.chanjar.weixin.common.api.WxConsts; | ||||||
| import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; | import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; | ||||||
|  |  | ||||||
|  | import java.lang.reflect.Type; | ||||||
|  |  | ||||||
| public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTagMessage> { | public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTagMessage> { | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
| @ -25,7 +24,7 @@ public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTag | |||||||
|     JsonObject messageJson = new JsonObject(); |     JsonObject messageJson = new JsonObject(); | ||||||
|  |  | ||||||
|     JsonObject filter = new JsonObject(); |     JsonObject filter = new JsonObject(); | ||||||
|     if(null == message.getTagId()) { |     if (null == message.getTagId()) { | ||||||
|       filter.addProperty("is_to_all", true); |       filter.addProperty("is_to_all", true); | ||||||
|     } else { |     } else { | ||||||
|       filter.addProperty("is_to_all", false); |       filter.addProperty("is_to_all", false); | ||||||
| @ -33,32 +32,33 @@ public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTag | |||||||
|     } |     } | ||||||
|     messageJson.add("filter", filter); |     messageJson.add("filter", filter); | ||||||
|  |  | ||||||
|     if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) { |     if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { | ||||||
|       JsonObject sub = new JsonObject(); |       JsonObject sub = new JsonObject(); | ||||||
|       sub.addProperty("media_id", message.getMediaId()); |       sub.addProperty("media_id", message.getMediaId()); | ||||||
|       messageJson.add(WxConsts.MASS_MSG_NEWS, sub); |       messageJson.add(WxConsts.MASS_MSG_NEWS, sub); | ||||||
|     } |     } | ||||||
|     if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) { |     if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { | ||||||
|       JsonObject sub = new JsonObject(); |       JsonObject sub = new JsonObject(); | ||||||
|       sub.addProperty("content", message.getContent()); |       sub.addProperty("content", message.getContent()); | ||||||
|       messageJson.add(WxConsts.MASS_MSG_TEXT, sub); |       messageJson.add(WxConsts.MASS_MSG_TEXT, sub); | ||||||
|     } |     } | ||||||
|     if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) { |     if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { | ||||||
|       JsonObject sub = new JsonObject(); |       JsonObject sub = new JsonObject(); | ||||||
|       sub.addProperty("media_id", message.getMediaId()); |       sub.addProperty("media_id", message.getMediaId()); | ||||||
|       messageJson.add(WxConsts.MASS_MSG_VOICE, sub); |       messageJson.add(WxConsts.MASS_MSG_VOICE, sub); | ||||||
|     } |     } | ||||||
|     if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) { |     if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { | ||||||
|       JsonObject sub = new JsonObject(); |       JsonObject sub = new JsonObject(); | ||||||
|       sub.addProperty("media_id", message.getMediaId()); |       sub.addProperty("media_id", message.getMediaId()); | ||||||
|       messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); |       messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); | ||||||
|     } |     } | ||||||
|     if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) { |     if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { | ||||||
|       JsonObject sub = new JsonObject(); |       JsonObject sub = new JsonObject(); | ||||||
|       sub.addProperty("media_id", message.getMediaId()); |       sub.addProperty("media_id", message.getMediaId()); | ||||||
|       messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); |       messageJson.add(WxConsts.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; |     return messageJson; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang