🎨 #1554 优化小程序获取token逻辑,减少刷新请求次数

This commit is contained in:
Binary Wang
2020-05-13 18:28:18 +08:00
parent a219035bfa
commit b87ec9a574

View File

@@ -116,6 +116,10 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
Lock lock = this.getWxMaConfig().getAccessTokenLock();
lock.lock();
try {
if (!this.getWxMaConfig().isAccessTokenExpired() && !forceRefresh) {
return this.getWxMaConfig().getAccessToken();
}
String url = String.format(WxMaService.GET_ACCESS_TOKEN_URL, this.getWxMaConfig().getAppid(),
this.getWxMaConfig().getSecret());
try {