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