mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-31 02:28:25 +08:00
reformat some code
This commit is contained in:
@ -1,16 +1,11 @@
|
|||||||
package me.chanjar.weixin.mp.util.json;
|
package me.chanjar.weixin.mp.util.json;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import com.google.gson.*;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.WxMpCard;
|
import me.chanjar.weixin.mp.bean.WxMpCard;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by YuJian on 15/11/11.
|
* Created by YuJian on 15/11/11.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,18 +1,13 @@
|
|||||||
package me.chanjar.weixin.mp.util.json;
|
package me.chanjar.weixin.mp.util.json;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import com.google.gson.*;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.WxMpCard;
|
import me.chanjar.weixin.mp.bean.WxMpCard;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by YuJian on 15/11/11.
|
* Created by YuJian on 15/11/11.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -2,33 +2,12 @@ package me.chanjar.weixin.mp.util.json;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import me.chanjar.weixin.mp.bean.*;
|
||||||
import me.chanjar.weixin.mp.bean.WxMpCard;
|
|
||||||
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
|
|
||||||
import me.chanjar.weixin.mp.bean.WxMpMassNews;
|
|
||||||
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
|
|
||||||
import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
|
|
||||||
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
|
|
||||||
import me.chanjar.weixin.mp.bean.WxMpMassVideo;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
|
|
||||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
||||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;
|
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
import me.chanjar.weixin.mp.bean.material.*;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
|
import me.chanjar.weixin.mp.bean.result.*;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialCountResult;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;
|
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
|
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
|
||||||
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.WxMpTemplateIndustry;
|
||||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,13 @@ import java.lang.reflect.Type;
|
|||||||
*/
|
*/
|
||||||
public class WxMpIndustryGsonAdapter
|
public class WxMpIndustryGsonAdapter
|
||||||
implements JsonSerializer<WxMpTemplateIndustry>, JsonDeserializer<WxMpTemplateIndustry> {
|
implements JsonSerializer<WxMpTemplateIndustry>, JsonDeserializer<WxMpTemplateIndustry> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type,
|
public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type,
|
||||||
JsonSerializationContext jsonSerializationContext) {
|
JsonSerializationContext jsonSerializationContext) {
|
||||||
@ -33,11 +40,4 @@ public class WxMpIndustryGsonAdapter
|
|||||||
wxMpIndustry.setSecondIndustry(convertFromJson(secondaryIndustry));
|
wxMpIndustry.setSecondIndustry(convertFromJson(secondaryIndustry));
|
||||||
return wxMpIndustry;
|
return wxMpIndustry;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
messageJson.add("wxcard", wxcard);
|
messageJson.add("wxcard", wxcard);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(message.getKfAccount())){
|
if (StringUtils.isNotBlank(message.getKfAccount())) {
|
||||||
JsonObject newsJsonObject = new JsonObject();
|
JsonObject newsJsonObject = new JsonObject();
|
||||||
newsJsonObject.addProperty("kf_account", message.getKfAccount());
|
newsJsonObject.addProperty("kf_account", message.getKfAccount());
|
||||||
messageJson.add("customservice", newsJsonObject);
|
messageJson.add("customservice", newsJsonObject);
|
||||||
|
|||||||
@ -15,9 +15,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WxMpMassUploadResultAdapter implements JsonDeserializer<WxMpMassUploadResult> {
|
public class WxMpMassUploadResultAdapter implements JsonDeserializer<WxMpMassUploadResult> {
|
||||||
|
|
||||||
|
|||||||
@ -17,9 +17,7 @@ import me.chanjar.weixin.mp.bean.WxMpMassVideo;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WxMpMassVideoAdapter implements JsonSerializer<WxMpMassVideo> {
|
public class WxMpMassVideoAdapter implements JsonSerializer<WxMpMassVideo> {
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class WxMpMaterialNewsArticleGsonAdapter implements JsonSerializer<WxMpMa
|
|||||||
JsonObject articleJson = new JsonObject();
|
JsonObject articleJson = new JsonObject();
|
||||||
|
|
||||||
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
|
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
|
||||||
articleJson.addProperty("thumb_url",article.getThumbUrl());
|
articleJson.addProperty("thumb_url", article.getThumbUrl());
|
||||||
articleJson.addProperty("title", article.getTitle());
|
articleJson.addProperty("title", article.getTitle());
|
||||||
articleJson.addProperty("content", article.getContent());
|
articleJson.addProperty("content", article.getContent());
|
||||||
if (null != article.getAuthor()) {
|
if (null != article.getAuthor()) {
|
||||||
@ -70,7 +70,7 @@ public class WxMpMaterialNewsArticleGsonAdapter implements JsonSerializer<WxMpMa
|
|||||||
article.setThumbMediaId(GsonHelper.getAsString(thumbMediaId));
|
article.setThumbMediaId(GsonHelper.getAsString(thumbMediaId));
|
||||||
}
|
}
|
||||||
JsonElement thumbUrl = articleInfo.get("thumb_url");
|
JsonElement thumbUrl = articleInfo.get("thumb_url");
|
||||||
if(thumbUrl != null && !thumbUrl.isJsonNull()) {
|
if (thumbUrl != null && !thumbUrl.isJsonNull()) {
|
||||||
article.setThumbUrl(GsonHelper.getAsString(thumbUrl));
|
article.setThumbUrl(GsonHelper.getAsString(thumbUrl));
|
||||||
}
|
}
|
||||||
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
|
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
|
||||||
|
|||||||
@ -1,16 +1,11 @@
|
|||||||
package me.chanjar.weixin.mp.util.json;
|
package me.chanjar.weixin.mp.util.json;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import com.google.gson.*;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
public class WxMpOAuth2AccessTokenAdapter implements JsonDeserializer<WxMpOAuth2AccessToken> {
|
public class WxMpOAuth2AccessTokenAdapter implements JsonDeserializer<WxMpOAuth2AccessToken> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -15,9 +15,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WxMpSemanticQueryResultAdapter implements JsonDeserializer<WxMpSemanticQueryResult> {
|
public class WxMpSemanticQueryResultAdapter implements JsonDeserializer<WxMpSemanticQueryResult> {
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@ 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.mp.bean.template.WxMpTemplateData;
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
||||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
||||||
|
|
||||||
|
|||||||
@ -8,24 +8,16 @@
|
|||||||
*/
|
*/
|
||||||
package me.chanjar.weixin.mp.util.json;
|
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.datacube.WxDataCubeUserCumulate;
|
||||||
|
import org.apache.commons.lang3.time.FastDateFormat;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.time.FastDateFormat;
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
|
||||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WxMpUserCumulateGsonAdapter implements JsonDeserializer<WxDataCubeUserCumulate> {
|
public class WxMpUserCumulateGsonAdapter implements JsonDeserializer<WxDataCubeUserCumulate> {
|
||||||
|
|
||||||
|
|||||||
@ -8,17 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
package me.chanjar.weixin.mp.util.json;
|
package me.chanjar.weixin.mp.util.json;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import com.google.gson.*;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> {
|
public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,7 +38,7 @@ public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> {
|
|||||||
wxMpUser.setGroupId(GsonHelper.getInteger(o, "groupid"));
|
wxMpUser.setGroupId(GsonHelper.getInteger(o, "groupid"));
|
||||||
wxMpUser.setTagIds(GsonHelper.getIntArray(o, "tagid_list"));
|
wxMpUser.setTagIds(GsonHelper.getIntArray(o, "tagid_list"));
|
||||||
wxMpUser.setSexId(sexId);
|
wxMpUser.setSexId(sexId);
|
||||||
if(new Integer(1).equals(sexId)) {
|
if (new Integer(1).equals(sexId)) {
|
||||||
wxMpUser.setSex("男");
|
wxMpUser.setSex("男");
|
||||||
} else if (new Integer(2).equals(sexId)) {
|
} else if (new Integer(2).equals(sexId)) {
|
||||||
wxMpUser.setSex("女");
|
wxMpUser.setSex("女");
|
||||||
|
|||||||
@ -8,19 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
package me.chanjar.weixin.mp.util.json;
|
package me.chanjar.weixin.mp.util.json;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import com.google.gson.*;
|
||||||
import java.text.ParseException;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.time.FastDateFormat;
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
|
||||||
|
import org.apache.commons.lang3.time.FastDateFormat;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
|
|||||||
@ -15,9 +15,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WxQrCodeTicketAdapter implements JsonDeserializer<WxMpQrCodeTicket> {
|
public class WxQrCodeTicketAdapter implements JsonDeserializer<WxMpQrCodeTicket> {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user