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

实时同步行动号召按钮

yumeng преди 5 години
родител
ревизия
1c485481cd

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

@@ -10,6 +10,7 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouActionBarTextService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
@@ -66,11 +67,16 @@ public class SampleTest {
     private IWechatUserListService wechatUserInfoService;
     @Autowired
     private IWechatCheckinDataService wechatCheckinDataService;
+    @Autowired
+    private IKuaiShouActionBarTextService kuaiShouActionBarTextService;
 
 
     @Test
     public void getDepartment() {
-        wechatCheckinDataService.getCheckinData();
+       // wechatCheckinDataService.getCheckinData();
+
+        kuaiShouActionBarTextService.getActionBarText();
+
         //  wechatUserInfoService.getUserList();
         // wechatDepartment.getDepartment();
         // kuaishouInterfaceService.getSuZaoList("a34853c230e1b949eddbe569023dbc40", 7022550L, 1, "2020-09-15", "2020-09-16");
@@ -83,10 +89,10 @@ public class SampleTest {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", 2);
         List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-       // for (CtopOauthToken token : list) {
-            kuaiShouHistoryReportTaskService.createTask(1872430L, "9cd4d43ea697ad9f2aa91fc0f4b921e5", "2020-03-15", "2020-09-15", "history");
+        // for (CtopOauthToken token : list) {
+        kuaiShouHistoryReportTaskService.createTask(1872430L, "9cd4d43ea697ad9f2aa91fc0f4b921e5", "2020-03-15", "2020-09-15", "history");
 
-       // }
+        // }
 
     }
 

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

@@ -123,6 +123,7 @@ public class KuaishouInterfaceConstant {
      * 获取可选的动态词包
      */
     public static final String CREATIVE_WORD = "/rest/openapi/v1/tool/creative_word/list";
+    public static final String ACTION_BAR_TEXT_LIST = "/rest/openapi/v1/creative/action_bar_text/list";
 
 
     /**

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouActionBarText.java

@@ -30,9 +30,9 @@ public class KuaiShouActionBarText {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
-    private Integer id;
+    private Long id;
     /**
      * 类型
      */

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouActionBarTextMapper.java

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaiShouActionBarTextMapper extends BaseMapper<KuaiShouActionBarText> {
 
+    void insertSelective(KuaiShouActionBarText kuaiShouActionBarText);
 }

+ 40 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouActionBarTextMapper.xml

@@ -2,4 +2,44 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouActionBarTextMapper">
 
+    <insert id="insertSelective" parameterType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouActionBarText">
+        replace into ctop_kuaishou_action_bar_text
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="type != null">
+                type,
+            </if>
+
+            <if test="actionBarText != null">
+                action_bar_text,
+            </if>
+
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="type != null">
+                #{type},
+            </if>
+            <if test="actionBarText != null">
+                #{actionBarText},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+
 </mapper>

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouActionBarTextService extends IService<KuaiShouActionBarText> {
 
+    void getActionBarText();
 }

+ 67 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java

@@ -1,11 +1,27 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+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.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouActionBarText;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouActionBarTextMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouActionBarTextService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @Description: 快手-行动号召文案
  * @Author: jeecg-boot
@@ -13,6 +29,57 @@ import org.springframework.stereotype.Service;
  * @Version: V1.0
  */
 @Service
+@Slf4j
 public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouActionBarTextMapper, KuaiShouActionBarText> implements IKuaiShouActionBarTextService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private KuaiShouActionBarTextMapper actionBarTextMapper;
+
+    @Override
+    public void getActionBarText() {
+
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("media_id", 2);
+        queryWrapper.orderByDesc("update_time");
+        queryWrapper.last("limit 1");
+        CtopOauthToken token = tokenService.getOne(queryWrapper);
+        List list = new ArrayList();
+        list.add(2);
+        list.add(3);
+        list.add(4);
+        list.add(5);
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACTION_BAR_TEXT_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token.getAccessToken());
+        headers.put("Content-Type", "application/json");
+        JSONObject requestJson = new JSONObject();
+        requestJson.put("advertiser_id", token.getAccountId());
+        for (int i = 0; i < list.size(); i++) {
+            requestJson.remove("campaign_type");
+            requestJson.put("campaign_type", list.get(i));
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    Integer campaign_type = data.getInteger("campaign_type");
+                    JSONArray action_bar_text = data.getJSONArray("action_bar_text");
+                    if (!Check.isNull(action_bar_text)) {
+                        for (int j = 0; j < action_bar_text.size(); j++) {
+                            String actionBarText = action_bar_text.getString(j);
+                            KuaiShouActionBarText kuaiShouActionBarText = new KuaiShouActionBarText();
+                            kuaiShouActionBarText.setActionBarText(actionBarText);
+                            kuaiShouActionBarText.setType(campaign_type);
+                            actionBarTextMapper.insertSelective(kuaiShouActionBarText);
+                        }
+                    }
+                }
+
+            }
+        }
+
 
+    }
 }