🆕 #2998 【小程序】增加获取稳定版接口调用凭据的接口,通过设置WxMaConfig#useStableAccessToken方法去开启使用稳定版接口

This commit is contained in:
FreeOfYou
2023-05-06 19:38:12 +08:00
committed by GitHub
parent 24c18b8bbc
commit c33ee14574
11 changed files with 213 additions and 10 deletions

View File

@@ -19,6 +19,13 @@ public interface WxMaConfig {
*/
String getAccessToken();
//region 稳定版access token
boolean isStableAccessToken();
void useStableAccessToken(boolean useStableAccessToken);
//endregion
/**
* Gets access token lock.
*

View File

@@ -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;