Преглед на файлове

推送模板接口 管理員可推送所有账户 && 创建 组、创建接口部分完成

yumeng преди 4 години
родител
ревизия
19612907ba

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -181,7 +181,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/shiwan/shiwanFileUpload/*", "anon");
         filterChainDefinitionMap.put("/oa/wechatNoList/*", "anon");
         filterChainDefinitionMap.put("/ruleGroup/*", "anon");
-        filterChainDefinitionMap.put("/kuaishou/Ai/*", "anon");
+        filterChainDefinitionMap.put("/kuaishou/material/*", "anon");
         filterChainDefinitionMap.put("/kuaishou/create/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt

+ 15 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreateController.java

@@ -3,9 +3,11 @@ package cn.com.ctop.kuaishou.modules.ai.controller;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
@@ -28,6 +30,8 @@ public class KuaiShouCreateController {
     private IKuaishouInterfaceService iKuaishouInterfaceService;
     @Autowired
     private IKuaiShouCampaignService campaignService;
+    @Autowired
+    private IKuaiShouCreateService kuaiShouCreateService;
 
     /**
      * 创建计划
@@ -98,32 +102,24 @@ public class KuaiShouCreateController {
         JSONObject result = new JSONObject();
         try {
             Long accountId = requestJson.getLong("account_id");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请填写账户id进行创建");
+            }
             CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到账户信息");
             }
-            JSONObject campaignJson = new JSONObject();
-
-            campaignJson.put("campaign_name", requestJson.getString("campaign_name"));
-            campaignJson.put("type", requestJson.getInteger("type"));
 
-            if (!Check.isNull(requestJson.getLong("day_budget"))) {
-                campaignJson.put("day_budget", requestJson.getLong("day_budget"));
+            Long campaign_id = requestJson.getLong("campaign_id");
+            if (Check.isNull(campaign_id)) {
+                throw new Exception("请填写需要创建的计划id");
             }
-            if (!Check.isNull(requestJson.getJSONArray("day_budget_schedule"))) {
-                campaignJson.put("day_budget_schedule", requestJson.getJSONArray("day_budget_schedule"));
+            JSONArray group_list = requestJson.getJSONArray("group_list");
+            if (Check.isNull(group_list)) {
+                throw new Exception("请填写需要创建的组信息");
             }
-            Map<String, Object> campaignMap = iKuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
-            Integer code = (Integer) campaignMap.get("code");
-            if (code != 0) {
-                throw new Exception((String) campaignMap.get("message"));
-            }
-            result.put("code", 0);
-            result.put("message", "SUCCESS");
-            JSONObject data = new JSONObject();
-            data.put("campaign_id", campaignMap.get("campaignId"));
-            data.put("account_id", requestJson.getLong("account_id"));
-            result.put("data", data);
+            kuaiShouCreateService.createUnitAndCreative(oauthToken, campaign_id, group_list);
+
         } catch (Exception e) {
             e.printStackTrace();
             result.put("code", -1);

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaiShouCreateService.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONArray;
+
+public interface IKuaiShouCreateService {
+    /**
+     * 创建组和计划
+     *
+     * @param oauthToken
+     * @param campaign_id
+     * @param group_list
+     */
+    void createUnitAndCreative(CtopOauthToken oauthToken, Long campaign_id, JSONArray group_list);
+}

+ 31 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
+    @Override
+    public void createUnitAndCreative(CtopOauthToken oauthToken, Long campaign_id, JSONArray group_list) {
+
+        JSONArray returnArr = new JSONArray();
+        try {
+            for (int i = 0; i < group_list.size(); i++) {
+                JSONObject groupCreateJson = group_list.getJSONObject(i);
+
+
+            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+}