|
@@ -15,13 +15,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
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.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
@@ -34,6 +37,8 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
|
|
|
private IOauthAgentTokenService agentTokenService;
|
|
private IOauthAgentTokenService agentTokenService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IOauthConfigService configService;
|
|
private IOauthConfigService configService;
|
|
|
|
|
+ @Resource(name = "adqRedisTemplate")
|
|
|
|
|
+ private StringRedisTemplate adqRedisTemplate;
|
|
|
private static ExecutorService kuaishouTokenExecutorService = Executors.newFixedThreadPool(4);
|
|
private static ExecutorService kuaishouTokenExecutorService = Executors.newFixedThreadPool(4);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -137,6 +142,19 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
|
|
|
String updateAccessToken = data.getString("access_token");
|
|
String updateAccessToken = data.getString("access_token");
|
|
|
String updateRefreshToken = data.getString("refresh_token");
|
|
String updateRefreshToken = data.getString("refresh_token");
|
|
|
oauthTokenService.updateAdqToken(adminAdvertiserId, updateAccessToken, updateRefreshToken);
|
|
oauthTokenService.updateAdqToken(adminAdvertiserId, updateAccessToken, updateRefreshToken);
|
|
|
|
|
+ // 同步到 ADQ 独立 Redis,key 规则:adq:access_token:{adminAdvertiserId}
|
|
|
|
|
+ try {
|
|
|
|
|
+ String redisKey = "adq:access_token:" + adminAdvertiserId;
|
|
|
|
|
+ Integer expiresIn = data.getInteger("expires_in");
|
|
|
|
|
+ if (expiresIn != null && expiresIn > 0) {
|
|
|
|
|
+ adqRedisTemplate.opsForValue().set(redisKey, updateAccessToken, expiresIn, TimeUnit.SECONDS);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ adqRedisTemplate.opsForValue().set(redisKey, updateAccessToken);
|
|
|
|
|
+ }
|
|
|
|
|
+ XxlJobHelper.log("ADQ token 已同步到 Redis, account:{}, key:{}", adminAdvertiserId, redisKey);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("ADQ token 同步到 Redis 失败, account:{}", adminAdvertiserId, e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|