|
@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.service.IOauthConfigService;
|
|
|
import cn.com.ctop.common.module.service.IRefreshTokenService;
|
|
import cn.com.ctop.common.module.service.IRefreshTokenService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
@@ -16,6 +17,7 @@ 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 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;
|
|
@@ -103,6 +105,42 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public void adqRefreshTokenJob() {
|
|
|
|
|
+ List<JSONObject> tokenList = oauthTokenService.getAdqTokenList();
|
|
|
|
|
+ if (Check.isNull(tokenList)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (JSONObject tokenJson : tokenList) {
|
|
|
|
|
+ Long adminAdvertiserId = tokenJson.getLong("adminAdvertiserId");
|
|
|
|
|
+ String clientId = tokenJson.getString("clientId");
|
|
|
|
|
+ String clientSecret = tokenJson.getString("clientSecret");
|
|
|
|
|
+ String refreshToken = tokenJson.getString("refreshToken");
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put("client_id", clientId);
|
|
|
|
|
+ param.put("client_secret", clientSecret);
|
|
|
|
|
+ param.put("refresh_token", refreshToken);
|
|
|
|
|
+ param.put("grant_type", "refresh_token");
|
|
|
|
|
+ String s = HttpUtils.httpGet("https://api.e.qq.com/oauth/token", param, new HashMap<>());
|
|
|
|
|
+ JSONObject tokenResult = JSONObject.parseObject(s);
|
|
|
|
|
+ System.err.println(tokenResult);
|
|
|
|
|
+ if (Check.isNull(tokenResult)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer code = tokenResult.getInteger("code");
|
|
|
|
|
+ if (code != 0) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject data = tokenResult.getJSONObject("data");
|
|
|
|
|
+ if (Check.isNull(data)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String updateAccessToken = data.getString("access_token");
|
|
|
|
|
+ String updateRefreshToken = data.getString("refresh_token");
|
|
|
|
|
+ oauthTokenService.updateAdqToken(adminAdvertiserId, updateAccessToken, updateRefreshToken);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public void getKuaiShouAgentRefresh() {
|
|
public void getKuaiShouAgentRefresh() {
|
|
|
QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
|
|
|
agentTokenQueryWrapper.eq("media_id", 2);
|
|
agentTokenQueryWrapper.eq("media_id", 2);
|