mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 18:46:10 +08:00 
			
		
		
		
	fix #56 分组群发消息没有 is_to_all 字段
This commit is contained in:
		| @ -9,7 +9,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
|  */ | ||||
| public class WxMpMassGroupMessage { | ||||
|    | ||||
|   private long groupId; | ||||
|   private Long groupId; | ||||
|   private String msgtype; | ||||
|   private String content; | ||||
|   private String mediaId; | ||||
| @ -58,11 +58,15 @@ public class WxMpMassGroupMessage { | ||||
|     return WxMpGsonBuilder.INSTANCE.create().toJson(this); | ||||
|   } | ||||
|  | ||||
|   public long getGroupId() { | ||||
|   public Long getGroupId() { | ||||
|     return groupId; | ||||
|   } | ||||
|  | ||||
|   public void setGroupId(long groupId) { | ||||
|   /** | ||||
|    * 如果不设置则就意味着发给所有用户 | ||||
|    * @param groupId | ||||
|    */ | ||||
|   public void setGroupId(Long groupId) { | ||||
|     this.groupId = groupId; | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -14,7 +14,7 @@ public class WxMpGsonBuilder { | ||||
|     INSTANCE.disableHtmlEscaping(); | ||||
|     INSTANCE.registerTypeAdapter(WxMpCustomMessage.class, new WxMpCustomMessageGsonAdapter()); | ||||
|     INSTANCE.registerTypeAdapter(WxMpMassNews.class, new WxMpMassNewsGsonAdapter()); | ||||
|     INSTANCE.registerTypeAdapter(WxMpMassGroupMessage.class, new WxMpMassMessageGsonAdapter()); | ||||
|     INSTANCE.registerTypeAdapter(WxMpMassGroupMessage.class, new WxMpMassGroupMessageGsonAdapter()); | ||||
|     INSTANCE.registerTypeAdapter(WxMpMassOpenIdsMessage.class, new WxMpMassOpenIdsMessageGsonAdapter()); | ||||
|     INSTANCE.registerTypeAdapter(WxMpGroup.class, new WxMpGroupGsonAdapter()); | ||||
|     INSTANCE.registerTypeAdapter(WxMpUser.class, new WxUserGsonAdapter()); | ||||
|  | ||||
| @ -22,13 +22,18 @@ import java.lang.reflect.Type; | ||||
|  * @author qianjia | ||||
|  * | ||||
|  */ | ||||
| public class WxMpMassMessageGsonAdapter implements JsonSerializer<WxMpMassGroupMessage> { | ||||
| public class WxMpMassGroupMessageGsonAdapter implements JsonSerializer<WxMpMassGroupMessage> { | ||||
| 
 | ||||
|   public JsonElement serialize(WxMpMassGroupMessage message, Type typeOfSrc, JsonSerializationContext context) { | ||||
|     JsonObject messageJson = new JsonObject(); | ||||
|      | ||||
|     JsonObject filter = new JsonObject(); | ||||
|     if(null == message.getGroupId()) { | ||||
|       filter.addProperty("is_to_all", true); | ||||
|     } else { | ||||
|       filter.addProperty("is_to_all", false); | ||||
|       filter.addProperty("group_id", message.getGroupId()); | ||||
|     } | ||||
|     messageJson.add("filter", filter); | ||||
|      | ||||
|     if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) { | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Qian
					Daniel Qian