瀏覽代碼

去除accountId

yumeng 5 年之前
父節點
當前提交
5e5bb7acb4

+ 0 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AuthController.java

@@ -1,16 +1,5 @@
 package org.jeecg.modules.ctop.controller;
 
-import cn.com.ctop.common.utils.Check;
-import cn.com.ctop.common.utils.HttpUtils;
-import cn.com.ctop.common.utils.PropertiesUtils;
-import cn.com.ctop.toutiao.common.BytedanceInterfaceConstant;
-import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
-import constant.KuaishouInterfaceConstant;
-import org.apache.commons.lang.StringUtils;
-import org.jeecg.modules.ctop.entity.AuthTask;
-import org.jeecg.modules.ctop.entity.CTopOauthToken;
-import org.jeecg.modules.ctop.entity.UserAllocation;
 import org.jeecg.modules.ctop.mapper.CTopOauthTokenMapper;
 import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
 import org.jeecg.modules.ctop.service.IAuthTaskService;
@@ -28,7 +17,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 

+ 7 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -122,16 +122,16 @@ public class CallbackController {
     public String bytedance(HttpServletRequest request,
                             HttpServletResponse response,
                             @RequestParam("auth_code") String authCode,
-                            @RequestParam("state") String state, @RequestParam("accountId") String accountId) {
+                            @RequestParam("state") String state) {
         System.out.println(request.getQueryString());
         if (StringUtils.isNotBlank(authCode)) {
-            System.out.println(this.getByteDanceAccessToken(authCode, accountId, state));
+            System.out.println(this.getByteDanceAccessToken(authCode, state));
             return "auth_success";
         }
         return "auth_fail";
     }
 
-    public String getByteDanceAccessToken(String authCode, String accountId, String state) {
+    public String getByteDanceAccessToken(String authCode, String state) {
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("app_id", PropertiesUtils.getValue("bytedance_config", "bytedance_appid"));
         param.put("secret", PropertiesUtils.getValue("bytedance_config", "bytedance_secret"));
@@ -146,10 +146,10 @@ public class CallbackController {
             Integer code = resultObject.getInteger("code");
             String message = resultObject.getString("message");
             if (null == code || code != 0) {
-                logger.info("获取token失败,accountId:{},message:{}", accountId, message);
+                logger.info("获取token失败,state:{},message:{}", state, message);
             }
             JSONObject data = resultObject.getJSONObject("data");
-            CTopOauthToken token = new CTopOauthToken(accountId, data);
+            CTopOauthToken token = new CTopOauthToken(data.getString("advertiser_id"), data);
             if (Check.isNull(token)) {
                 AuthTask authTask = authTaskService.getAuthTask(state);
                 if (Check.isNull(authTask)) {
@@ -168,12 +168,12 @@ public class CallbackController {
                 userAllocation.setAccountId(token.getAccountId());
                 allocationMapper.deleteById(userAllocation.getId());
                 Map<String, Object> deleteUserMap = new HashMap<>();
-                deleteUserMap.put("account_id", accountId);
+                deleteUserMap.put("account_id", token.getAccountId());
                 deleteUserMap.put("advertiser_id", advertiserId);
                 allocationMapper.deleteByMap(deleteUserMap);
                 int i = allocationMapper.insert(userAllocation);
                 if (i > 0) {
-                    logger.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
+                    logger.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
 
                 }
             }