Bladeren bron

程序化创意推荐封面

yumeng 5 jaren geleden
bovenliggende
commit
2077da1f33

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialCutFrameMapper.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,4 +19,6 @@ import java.util.List;
 public interface MaterialCutFrameMapper extends BaseMapper<MaterialCutFrame> {
 
     List<MaterialCutFrame> getListByVideoSignature(@Param(value = "videoSignature") String signature);
+
+    List<JSONObject> getProgramCreativeCover(@Param("signature") String signature);
 }

+ 12 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialCutFrameMapper.xml

@@ -19,8 +19,19 @@
         where frame.signature = a.signature
         order by id desc
         limit 1) as 'id'
-from (select distinct signature
+       from (select distinct signature
       from ctop_material_cut_frame
       where video_signature = #{videoSignature}) a;
     </select>
+
+
+    <select id="getProgramCreativeCover" resultType="com.alibaba.fastjson.JSONObject">
+      SELECT
+      signature as 'signature',
+      url as 'url'
+      FROM ctop_material_cut_frame
+      WHERE video_signature = #{signature}
+      ORDER BY RAND() LIMIT 4;
+    </select>
+
 </mapper>

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.service;
 
 
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.io.IOException;
@@ -25,10 +26,11 @@ public interface IMaterialCutFrameService extends IService<MaterialCutFrame> {
 
     void loadCosCutFrame(String jobId, String videoSignature);  //腾讯云抽帧任务状态查询以及数据入库
 
-    void getTencentCutFrame(String videoUrl,String materialId,String coveUrl);
+    void getTencentCutFrame(String videoUrl, String materialId, String coveUrl);
 
     boolean updateTencentCutFrame(String videoMD5);
 
     MaterialCutFrame getCutFrameByCode(String code);
 
+    List<JSONObject> getProgramCreativeCover(String signature);
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java

@@ -423,5 +423,10 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
         return this.getOne(queryWrapper);
     }
 
+    @Override
+    public  List<JSONObject>  getProgramCreativeCover(String signature) {
+        return materialCutFrameMapper.getProgramCreativeCover(signature);
+    }
+
 
 }

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

@@ -2388,4 +2388,5 @@ public class BatchController {
 
 
 
+
 }

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

@@ -7,6 +7,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProgramCreativeService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -136,6 +137,37 @@ public class KuaishouProgramCreativeController {
 
 
     /**
+     * 创意分类
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/getProgramCreativeCover")
+    public Result<JSONArray> getCreativeCategory(@RequestBody JSONObject jsonObject) {
+        Result<JSONArray> result = new Result<>();
+        try {
+
+             JSONArray md5Arr = jsonObject.getJSONArray("md5Arr");
+
+            if (Check.isNull(md5Arr)) {
+                throw new Exception("请选择视频");
+            }
+
+            JSONArray data = kuaishouProgramCreativeService.getProgramCreativeCover(md5Arr);
+            result.setSuccess(true);
+            result.setResult(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(null);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    /**
      * 添加
      *
      * @param kuaishouProgramCreative

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -15,4 +16,6 @@ public interface IKuaishouProgramCreativeService extends IService<KuaishouProgra
     void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page);
 
     JSONObject createProgramCreative(CtopOauthToken oauthToken, JSONObject requestJson);
+
+    JSONArray getProgramCreativeCover(JSONArray md5Arr);
 }

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
@@ -41,6 +42,9 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
     @Autowired
     private IKuaiShouMaterialUploadService uploadService;
 
+    @Autowired
+    private IMaterialCutFrameService materialCutFrameService;
+
 
     @Override
     public void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page) {
@@ -220,4 +224,30 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 
         return returnJson;
     }
+
+    @Override
+    public JSONArray getProgramCreativeCover(JSONArray md5Arr) {
+
+        JSONArray returnArr = new JSONArray();
+        for (int i = 0; i < md5Arr.size(); i++) {
+            String signature = md5Arr.getString(i);
+            if (Check.isNull(signature)) {
+                continue;
+            }
+            List<JSONObject> coverArr = materialCutFrameService.getProgramCreativeCover(signature);
+            if (!Check.isNull(coverArr)) {
+                for (int j = 0; j < coverArr.size(); j++) {
+                    JSONObject jsonObject = JSONObject.parseObject(coverArr.get(j).toJSONString());
+                    if (!Check.isNull(jsonObject)) {
+                        returnArr.add(jsonObject);
+                    }
+                }
+
+            }
+
+        }
+        return returnArr;
+    }
+
+
 }