mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
添加获得模板列表的接口方法,并重构模板消息相关类包结构 for issue #63
This commit is contained in:
@@ -5,7 +5,6 @@ import com.google.gson.GsonBuilder;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.WxMpCard;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpIndustry;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassNews;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
|
||||
@@ -13,7 +12,6 @@ import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassVideo;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews;
|
||||
import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
|
||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult;
|
||||
@@ -31,6 +29,8 @@ import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUserList;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||
|
||||
public class WxMpGsonBuilder {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class WxMpGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxMpCard.class, new WxMpCardGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpMassPreviewMessage.class, new WxMpMassPreviewMessageGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMediaImgUploadResult.class, new WxMediaImgUploadResultGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpIndustry.class, new WxMpIndustryGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpTemplateIndustry.class, new WxMpIndustryGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpUserBlacklistGetResult.class, new WxUserBlacklistGetResultGsonAdapter());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.chanjar.weixin.mp.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.mp.bean.WxMpIndustry;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@@ -10,9 +10,9 @@ import java.lang.reflect.Type;
|
||||
* @author miller
|
||||
*/
|
||||
public class WxMpIndustryGsonAdapter
|
||||
implements JsonSerializer<WxMpIndustry>, JsonDeserializer<WxMpIndustry> {
|
||||
implements JsonSerializer<WxMpTemplateIndustry>, JsonDeserializer<WxMpTemplateIndustry> {
|
||||
@Override
|
||||
public JsonElement serialize(WxMpIndustry wxMpIndustry, Type type,
|
||||
public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type,
|
||||
JsonSerializationContext jsonSerializationContext) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("industry_id1", wxMpIndustry.getPrimaryIndustry().getId());
|
||||
@@ -21,10 +21,10 @@ public class WxMpIndustryGsonAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpIndustry deserialize(JsonElement jsonElement, Type type,
|
||||
public WxMpTemplateIndustry deserialize(JsonElement jsonElement, Type type,
|
||||
JsonDeserializationContext jsonDeserializationContext)
|
||||
throws JsonParseException {
|
||||
WxMpIndustry wxMpIndustry = new WxMpIndustry();
|
||||
WxMpTemplateIndustry wxMpIndustry = new WxMpTemplateIndustry();
|
||||
JsonObject primaryIndustry = jsonElement.getAsJsonObject()
|
||||
.get("primary_industry").getAsJsonObject();
|
||||
wxMpIndustry.setPrimaryIndustry(convertFromJson(primaryIndustry));
|
||||
@@ -34,8 +34,8 @@ public class WxMpIndustryGsonAdapter
|
||||
return wxMpIndustry;
|
||||
}
|
||||
|
||||
private static WxMpIndustry.Industry convertFromJson(JsonObject json) {
|
||||
WxMpIndustry.Industry industry = new WxMpIndustry.Industry();
|
||||
private static WxMpTemplateIndustry.Industry convertFromJson(JsonObject json) {
|
||||
WxMpTemplateIndustry.Industry industry = new WxMpTemplateIndustry.Industry();
|
||||
industry.setFirstClass(GsonHelper.getString(json, "first_class"));
|
||||
industry.setSecondClass(GsonHelper.getString(json, "second_class"));
|
||||
return industry;
|
||||
|
||||
@@ -12,8 +12,9 @@ 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.bean.WxMpTemplateData;
|
||||
import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user