mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
#1081 开放平台模块增加获取所有授权方列表的接口
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package me.chanjar.weixin.open.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerListResult;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author robgao
|
||||
* @Email 315789501@qq.com
|
||||
*/
|
||||
public class WxOpenAuthorizerListResultGsonAdapter implements JsonDeserializer<WxOpenAuthorizerListResult> {
|
||||
|
||||
private static final String AUTHORIZER_APPID="authorizer_appid";
|
||||
private static final String REFRESH_TOKEN="refresh_token";
|
||||
private static final String AUTH_TIME="auth_time";
|
||||
@Override
|
||||
public WxOpenAuthorizerListResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
|
||||
WxOpenAuthorizerListResult wxOpenAuthorizerListResult= new WxOpenAuthorizerListResult();
|
||||
wxOpenAuthorizerListResult.setTotalCount(GsonHelper.getInteger(jsonObject, "total_count").intValue());
|
||||
|
||||
List<Map<String,String>> list = new ArrayList<>();
|
||||
Iterator<JsonElement> jsonElementIterator = jsonObject.getAsJsonArray("list").iterator();
|
||||
|
||||
while(jsonElementIterator.hasNext()){
|
||||
JsonObject authorizer = jsonElementIterator.next().getAsJsonObject();
|
||||
Map<String,String> authorizerMap = new HashMap<>(10);
|
||||
|
||||
authorizerMap.put(AUTHORIZER_APPID, GsonHelper.getString(authorizer,AUTHORIZER_APPID));
|
||||
authorizerMap.put(REFRESH_TOKEN, GsonHelper.getString(authorizer,REFRESH_TOKEN));
|
||||
authorizerMap.put(AUTH_TIME, GsonHelper.getString(authorizer,AUTH_TIME));
|
||||
list.add(authorizerMap);
|
||||
}
|
||||
wxOpenAuthorizerListResult.setList(list);
|
||||
return wxOpenAuthorizerListResult;
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,7 @@ import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
|
||||
import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
|
||||
import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
|
||||
import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizerInfo;
|
||||
import me.chanjar.weixin.open.bean.result.WxFastMaAccountBasicInfoResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
|
||||
import me.chanjar.weixin.open.bean.result.*;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/007gzs">007</a>
|
||||
@@ -27,8 +24,8 @@ public class WxOpenGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxOpenQueryAuthResult.class, new WxOpenQueryAuthResultGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxOpenAuthorizerInfoResult.class, new WxOpenAuthorizerInfoResultGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxOpenAuthorizerOptionResult.class, new WxOpenAuthorizerOptionResultGsonAdapter());
|
||||
|
||||
INSTANCE.registerTypeAdapter(WxFastMaAccountBasicInfoResult.class, new WxFastMaAccountBasicInfoGsonAdapter ());
|
||||
INSTANCE.registerTypeAdapter(WxOpenAuthorizerListResult.class, new WxOpenAuthorizerListResultGsonAdapter ());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user