yumeng vor 4 Jahren
Ursprung
Commit
96cb1c08f7

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

@@ -182,6 +182,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/oa/wechatNoList/*", "anon");
         filterChainDefinitionMap.put("/ruleGroup/*", "anon");
         filterChainDefinitionMap.put("/kuaishou/Ai/*", "anon");
+        filterChainDefinitionMap.put("/kuaishou/create/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -0,0 +1,130 @@
+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.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@Slf4j
+@Api(tags = "快手-批量工具")
+@RestController
+@RequestMapping("/kuaishou/create")
+public class KuaiShouCreateController {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+
+    /**
+     * 创建计划
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/campaignCreate")
+    public JSONObject campaignCreate(@RequestBody JSONObject requestJson) {
+        JSONObject result = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("account_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"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("day_budget_schedule"))) {
+                campaignJson.put("day_budget_schedule", requestJson.getJSONArray("day_budget_schedule"));
+            }
+            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);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.put("code", -1);
+            result.put("message", e.getMessage());
+            JSONObject data = new JSONObject();
+            data.put("account_id", requestJson.getLong("account_id"));
+            result.put("data", data);
+
+        }
+        return result;
+
+    }
+
+
+    /**
+     * 创建组 创意
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/createUnitAndCreative")
+    public JSONObject createUnitAndCreative(@RequestBody JSONObject requestJson) {
+        JSONObject result = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("account_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"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("day_budget_schedule"))) {
+                campaignJson.put("day_budget_schedule", requestJson.getJSONArray("day_budget_schedule"));
+            }
+            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);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.put("code", -1);
+            result.put("message", e.getMessage());
+            JSONObject data = new JSONObject();
+            data.put("account_id", requestJson.getLong("account_id"));
+            result.put("data", data);
+
+        }
+        return result;
+
+    }
+
+
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java

@@ -27,7 +27,7 @@ import java.util.Map;
 @Slf4j
 @Api(tags = "快手-批量工具")
 @RestController
-@RequestMapping("/kuaishou/Ai")
+@RequestMapping("/kuaishou/material")
 public class KuaiShouMaterialControer {
     @Autowired
     private ICtopOauthTokenService tokenService;