Pārlūkot izejas kodu

对接新接口

yumeng 5 gadi atpakaļ
vecāks
revīzija
5c7d0c99b0

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java

@@ -32,7 +32,7 @@ public class KuaishouCampaignGroupJob implements Job {
             public void run() {
                 //1:查询当日数据
                 List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-                executorService = Executors.newFixedThreadPool(8);
+                executorService = Executors.newFixedThreadPool(5);
                 tokens.forEach(token -> {
                     executorService.submit(new Runnable() {
                         @Override

+ 1 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -46,9 +46,7 @@ public class KuaishouCommentAutoDelete implements Job {
                             } else {
                                 log.info("error,删除评论调用shell脚本执行失败");
                             }
-
-
-                            Thread.sleep(10000);
+                            Thread.sleep(5 * 1000);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }

+ 2 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/shiro/authc/aop/JwtFilter.java

@@ -56,10 +56,9 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
             // 如果没有抛出异常则代表登入成功,返回true
             return true;
         } catch (Exception e) {
-            log.error("登录失败");
-
+            return false;
         }
-        return false;
+
 
     }
 

+ 1 - 4
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -2,8 +2,6 @@ package org.jeecg;
 
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
-import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
@@ -29,7 +27,6 @@ import org.springframework.test.context.junit4.SpringRunner;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -147,7 +144,7 @@ public class SampleTest {
     @Test
     public void testMail() throws Exception {
         // String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page
-        kuaishouInterfaceService.getTargetingTags(23212L, "cbe8dfe599d36ff59417d5037bbc0a15");
+        kuaishouInterfaceService.getAppSearch(23212L, "cbe8dfe599d36ff59417d5037bbc0a15", "快");
     }
 
 

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -99,6 +99,11 @@ public class KuaishouInterfaceConstant {
      */
     public static final String POPULATION_LIST = "/rest/openapi/v1/dmp/population/list";
 
+    /**
+     * 获取可选的应用定向
+     */
+    public static final String APP_SEARCH = "/rest/openapi/v1/tool/app/search";
+
 
     /**
      * 获取定向标签

+ 61 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -429,4 +429,65 @@ public class BatchController {
     }
 
 
+    /**
+     * 获取可选的深度类型
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getIsActivate")
+    public Result<JSONObject> getIsActivate(Long accountId) {
+        Result result = new Result<JSONObject>();
+        try {
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取授权信息");
+            }
+            JSONObject deepConversionJson = iKuaishouInterfaceService.getDeepConversionInfosV2(accountId, token.getAccessToken());
+            if (Check.isNull(deepConversionJson)) {
+                throw new Exception("深度类型数据返回为空");
+            }
+
+            result.setSuccess(true);
+            result.setResult(deepConversionJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+
+    /**
+     * 获取可选的深度类型
+     *
+     * @param accountId
+     * @param appName
+     * @return
+     */
+    @GetMapping(value = "/getAppSearch")
+    public Result<JSONObject> getAppSearch(Long accountId, String appName) {
+        Result result = new Result<JSONObject>();
+        try {
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取授权信息");
+            }
+            JSONArray appArray = iKuaishouInterfaceService.getAppSearch(accountId, token.getAccessToken(), appName);
+            result.setSuccess(true);
+            result.setResult(appArray);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+
 }

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -126,6 +126,8 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> getDeepConversionInfos(Long advertiserId, String accessToken);
 
+    JSONObject getDeepConversionInfosV2(Long advertiserId, String accessToken);
+
 
     /**
      * 创建广告创意
@@ -324,4 +326,16 @@ public interface IKuaishouInterfaceService {
      * @param accessToken
      */
     void getTargetingTags(Long accountId, String accessToken);
+
+
+    /**
+     * 获取可选的应用定向
+     *
+     * @param accountId
+     * @param accessToken
+     * @param appName
+     * @return
+     */
+    JSONArray getAppSearch(Long accountId, String accessToken, String appName);
+
 }

+ 71 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -1912,6 +1912,42 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+    @Override
+    public JSONObject getDeepConversionInfosV2(Long advertiserId, String accessToken) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.DEEP_CONVERSION_INFOS;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", advertiserId);
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", " application/json");
+        try {
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            log.info(resultJson.toJSONString());
+            if (!Check.isNullMap(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNullMap(dataJson)) {
+                        return dataJson;
+                    }
+                } else {
+                    log.error("获取可选的深度转化类型返回异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
+
+                }
+            } else {
+                log.error("快手,获取可选的深度转化类型返回为空,advertiserId:{}", advertiserId);
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+        return null;
+
+    }
+
+
     /**
      * 创建广告创意
      *
@@ -3031,15 +3067,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONArray data = resultJson.getJSONArray("data");
                     return data;
                 } else {
-
-
                     log.error("获取人群包管理返回数据为空,accountId:{}", accountId);
                     return null;
                 }
-
             }
-
-
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -3066,21 +3097,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             headers.put("Content-Type", "application/json");
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", accountId);
-
-
             JSONArray typeArr = new JSONArray();
             typeArr.add("BUSINESS_INTEREST");
             typeArr.add("APP_INTEREST");
             typeArr.add("FANS_STAR");
             typeArr.add("INTEREST_VIDEO");
-
-
             for (int i = 0; i < typeArr.size(); i++) {
                 String type = typeArr.get(i).toString();
                 requestJson.put("type", type);
                 String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
                 JSONObject resultJson = JSONObject.parseObject(result);
-                System.err.println(resultJson);
                 if (!Check.isNull(resultJson)) {
                     Integer code = resultJson.getInteger("code");
                     if (code == 0) {
@@ -3100,20 +3126,51 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 }
                             }
                         }
-
                     } else {
                         log.error("获取定向标签返回数据为空,accountId:{}", accountId);
-
                     }
-
                 }
-
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
 
+    /**
+     * 获取可选的应用定向
+     *
+     * @param accountId
+     * @param accessToken
+     * @param appName
+     * @return
+     */
+
+    @Override
+    public JSONArray getAppSearch(Long accountId, String accessToken, String appName) {
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_SEARCH;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            requestJson.put("app_name", appName);
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONArray data = resultJson.getJSONArray("data");
+                    return data;
+                }
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }
+
+        return null;
     }