|
|
@@ -30,14 +30,14 @@ public class BytedanceAppletTokenRefreshServiceImpl implements BytedanceAppletTo
|
|
|
Jedis jedis = refreshTokenService.getJedisToken();
|
|
|
List<JSONObject> list = tokenRefreshMapper.queryAppletList();
|
|
|
for (JSONObject applet : list) {
|
|
|
- buildAppletToken(applet, jedis);
|
|
|
+ buildAppletToken(applet, jedis, 0);
|
|
|
}
|
|
|
tokenRefreshMapper.refreshAppletTokens(list);
|
|
|
jedis.close();
|
|
|
}
|
|
|
|
|
|
//构建小程序token
|
|
|
- private void buildAppletToken(JSONObject applet, Jedis jedis) {
|
|
|
+ private void buildAppletToken(JSONObject applet, Jedis jedis, int count) {
|
|
|
String name = applet.getString("name");
|
|
|
try {
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
@@ -55,7 +55,12 @@ public class BytedanceAppletTokenRefreshServiceImpl implements BytedanceAppletTo
|
|
|
log.info("小程序:{},获取token完成", name);
|
|
|
applet.put("token", accessToken);
|
|
|
} else {
|
|
|
- log.error("小程序:{},获取token失败!结果:{}", name, tokenInfo);
|
|
|
+ if (count < 3) {
|
|
|
+ Thread.sleep(5000L);
|
|
|
+ buildAppletToken(applet, jedis, count + 1);
|
|
|
+ } else {
|
|
|
+ log.error("小程序:{},获取token失败!结果:{}", name, tokenInfo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|