瀏覽代碼

定向包~开发查询

zhaoxian 4 年之前
父節點
當前提交
728406d907

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

@@ -177,7 +177,7 @@ public class KuaishouDirectionalPackageController {
      * @throws
      * @author ZHAOXA
      */
-    @GetMapping(value = "/getHistory")
+    @GetMapping(value = "/getAccountByProjectId")
     public Result<Object> getAccountByProjectId(Long projectId,
                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java

@@ -1,8 +1,11 @@
 package cn.com.ctop.kuaishou.modules.ai.mapper;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 自动投放-定向包详情
  *
@@ -12,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaishouDirectionalPackageMapper extends BaseMapper<KuaishouDirectionalPackage> {
 
+    List<JSONObject> queryList(KuaishouDirectionalPackage directionalPackage);
+
+    Long queryListTotal(KuaishouDirectionalPackage directionalPackage);
 }

+ 49 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.xml

@@ -2,4 +2,53 @@
 <!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.ai.mapper.KuaishouDirectionalPackageMapper">
 
+    <select id="queryList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.template_id 'templateId',
+        t1.template_name 'templateName',
+        t3.project_name 'projectName',
+        CASE WHEN t1.platform_os =1 THEN 'Android' WHEN t1.platform_os =2 THEN 'iOS' ELSE '-' END 'platformOs',
+        t1.update_time 'updateTime',
+        IFNULL(t4.count,0) as 'accountCount',
+        '-' as 'unitCount'
+        FROM ctop_kuaishou_directional_package t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t3.id = t2.project_id
+        LEFT JOIN (
+        SELECT template_id,COUNT(1) 'count' FROM
+        ctop_kuaishou_template GROUP BY template_id
+        ) t4 ON t4.template_id = t1.template_id
+        where t1.data_status = 1
+        <if test="templateName !=null">
+            AND t1.template_name like concat('%',#{templateName},'%')
+        </if>
+        <if test="platformOs !=null">
+            AND t1.platform_os = #{platformOs}
+        </if>
+        <if test="projectId !=null">
+            AND t3.project_id = #{projectId}
+        </if>
+        GROUP BY t1.template_id
+    </select>
+    <select id="queryListTotal" resultType="java.lang.Long">
+        SELECT
+        IFNULL(count(1),0)
+        from(
+        select t1.template_id
+        FROM ctop_kuaishou_directional_package t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t3.id = t2.project_id
+        where t1.data_status = 1
+        <if test="templateName !=null">
+            AND t1.template_name like concat('%',#{templateName},'%')
+        </if>
+        <if test="platformOs !=null">
+            AND t1.platform_os = #{platformOs}
+        </if>
+        <if test="projectId !=null">
+            AND t3.project_id = #{projectId}
+        </if>
+        GROUP BY t1.template_id
+        ) t
+    </select>
 </mapper>

+ 9 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java

@@ -12,12 +12,14 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -33,6 +35,8 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
 
     @Autowired
     private IKuaishouTemplateService kuaishouTemplateService;
+    @Autowired
+    private KuaishouDirectionalPackageMapper packageMapper;
 
     @Override
     public Result<Object> createDirectionalPackage(String accessToken, JSONObject requestJson) {
@@ -374,11 +378,12 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
 
     @Override
     public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize) {
-
+        Long total = packageMapper.queryListTotal(directionalPackage);
         PageHelper.startPage(pageNo, pageSize, false);
-
-
-        return null;
+        List<JSONObject> list = packageMapper.queryList(directionalPackage);
+        PageInfo pageInfo = new PageInfo(list);
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
     }
 
     @Override

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

@@ -538,6 +538,13 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data").getJSONObject("behavior_interest");
+                    JSONArray interest = data.getJSONArray("interest");
+                    splicingId(interest);
+                    JSONArray behavior = data.getJSONArray("behavior");
+                    splicingId(behavior);
+                    data.put("interest", interest);
+                    data.put("behavior", behavior);
                     return Result.ok(resultJson.getJSONObject("data"));
                 } else {
                     log.info(" 获取行为与兴趣类目失败,accountId:{},返回信息:{}", accountId, resultJson);
@@ -550,6 +557,26 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
         return Result.error("获取行为与兴趣类目失败");
     }
 
+    private void splicingId(JSONArray interest) {
+        for (int i = 0; i < interest.size(); i++) {
+            JSONObject level1 = interest.getJSONObject(i);
+            JSONArray children1 = level1.getJSONArray("children");
+            if (!Check.isNull(children1)) {
+                for (int j = 0; j < children1.size(); j++) {
+                    JSONObject level2 = children1.getJSONObject(j);
+                    JSONArray children2 = level2.getJSONArray("children");
+                    if (!Check.isNull(children2)) {
+                        for (int k = 0; k < children2.size(); k++) {
+                            JSONObject level3 = children2.getJSONObject(k);
+                            level3.put("id", level1.getString("id").concat("-").concat(level2.getString("id")).concat("-").concat(level3.getString("id")));
+                        }
+                    }
+                    level2.put("id", level1.getString("id").concat("-").concat(level2.getString("id")));
+                }
+            }
+        }
+    }
+
     /**
      * 获取行为兴趣关键词
      *