|
@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import redis.clients.jedis.Jedis;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -75,4 +76,47 @@ public class BytedanceRefreshTokenServiceImpl implements IBytedanceRefreshTokenS
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void refreshAppletTokens() {
|
|
|
|
|
+ List<JSONObject> list = bytedanceRefreshTokenMapper.queryOfficialAccounts();
|
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
|
+ Jedis jedis = getJedisToken();
|
|
|
|
|
+ if (!Check.isNull(jedis)) {
|
|
|
|
|
+ for (JSONObject app : list) {
|
|
|
|
|
+ String key = null;
|
|
|
|
|
+ if (app.getString("app_id").startsWith("tt")) {
|
|
|
|
|
+ key = "client-token-key_" + app.getString("app_id");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (app.getString("app_id").startsWith("wx")) {
|
|
|
|
|
+ key = "wechat-applet-access-token-key-" + app.getString("applet_id");
|
|
|
|
|
+ }
|
|
|
|
|
+ String token = jedis.get(key);
|
|
|
|
|
+ if (!Check.isNull(token)) {
|
|
|
|
|
+ app.put("token", token);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ jedis.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ bytedanceRefreshTokenMapper.refreshAppletTokens(list);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //获取token
|
|
|
|
|
+ private Jedis getJedisToken() {
|
|
|
|
|
+ Jedis jedis = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ String ip = "r-2zelacjrljt205nsb1pd.redis.rds.aliyuncs.com";
|
|
|
|
|
+ jedis = new Jedis(ip, 6379);
|
|
|
|
|
+ jedis.auth("Huanrui@2025!@");
|
|
|
|
|
+ jedis.select(5);
|
|
|
|
|
+ return jedis;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.info("---Jedis失败,消息:{}", e.getMessage());
|
|
|
|
|
+ log.info("---异常消息:", e);
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|