mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #2998 【小程序】增加获取稳定版接口调用凭据的接口,通过设置WxMaConfig#useStableAccessToken方法去开启使用稳定版接口
This commit is contained in:
@@ -19,6 +19,13 @@ public interface WxMaConfig {
|
||||
*/
|
||||
String getAccessToken();
|
||||
|
||||
//region 稳定版access token
|
||||
boolean isStableAccessToken();
|
||||
|
||||
void useStableAccessToken(boolean useStableAccessToken);
|
||||
//endregion
|
||||
|
||||
|
||||
/**
|
||||
* Gets access token lock.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.binarywang.wx.miniapp.config.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
|
||||
@@ -19,6 +20,13 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public class WxMaDefaultConfigImpl implements WxMaConfig {
|
||||
protected volatile String appid;
|
||||
protected volatile String token;
|
||||
|
||||
/**
|
||||
* 是否使用稳定版获取accessToken接口
|
||||
*/
|
||||
@Getter(value = AccessLevel.NONE)
|
||||
private boolean useStableAccessToken;
|
||||
|
||||
/**
|
||||
* 小程序原始ID
|
||||
*/
|
||||
@@ -81,6 +89,19 @@ public class WxMaDefaultConfigImpl implements WxMaConfig {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
//region 使用稳定版接口获取accessToken
|
||||
@Override
|
||||
public boolean isStableAccessToken() {
|
||||
return this.useStableAccessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useStableAccessToken(boolean useStableAccessToken) {
|
||||
this.useStableAccessToken = useStableAccessToken;
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
||||
@Override
|
||||
public Lock getAccessTokenLock() {
|
||||
return this.accessTokenLock;
|
||||
|
||||
Reference in New Issue
Block a user