فهرست منبع

根据账户获取视频素材-账户(视频id)视频素材

yangzian 3 سال پیش
والد
کامیت
d889608a7a

+ 11 - 4
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -3,6 +3,9 @@ package cn.com.ctop.job.bytedance.controller;
 import cn.com.ctop.job.bytedance.data.entity.OauthToken;
 import cn.com.ctop.job.bytedance.data.service.IBytedanceFileVideoGetService;
 import cn.com.ctop.job.bytedance.data.service.IOauthTokenService;
+import cn.com.ctop.job.bytedance.data.utils.Check;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -32,14 +35,18 @@ public class BytedanceController {
 
 
 
-    @ApiOperation(value="根据账户获取视频素材-账户下全部视频素材", notes="根据账户获取视频素材-账户下全部视频素材")
-    @GetMapping(value = "/getBytedanceVideoByAccountId")
-    public Map<String,String> getBytedanceVideoByAccountId(@RequestParam(name="accountId") Long accountId) {
+    @ApiOperation(value="根据账户获取视频素材-账户/素材id 下全部视频素材", notes="根据账户获取视频素材-账户/素材id 下全部视频素材")
+    @PostMapping(value = "/getBytedanceVideoByAccountId")
+    public Map<String,String> getBytedanceVideoByAccountId(@RequestBody JSONObject jsonObject) {
+        Long accountId = jsonObject.getLong("accountId");
+        JSONArray dataList = jsonObject.getJSONArray("materialIds");
+        List<Long> materialIds = Check.isNull(dataList) ? null : JSONArray.parseObject(dataList.toJSONString(),List.class);
+
         String token = tokenService.getByAccountId(accountId);
         OauthToken oauthToken = new OauthToken();
         oauthToken.setAccessToken(token);
         oauthToken.setAccountId(accountId);
-        return fileVideoService.getBytedanceVideoByAccountId(oauthToken, 1, 100);
+        return fileVideoService.getBytedanceVideoByAccountId(oauthToken, materialIds,1, 100);
     }
 
 

+ 2 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedanceFileVideoGetService.java

@@ -4,6 +4,7 @@ import cn.com.ctop.job.bytedance.data.entity.BytedanceFileVideoGet;
 import cn.com.ctop.job.bytedance.data.entity.OauthToken;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -16,5 +17,5 @@ public interface IBytedanceFileVideoGetService  {
 
     void getFileVideoData(OauthToken oauthToken, String startDate,String endDate,int i, int i1);
 
-    Map<String,String>getBytedanceVideoByAccountId(OauthToken oauthToken,int i, int j);
+    Map<String,String>getBytedanceVideoByAccountId(OauthToken oauthToken, List<Long> materialIds,int i, int j);
 }

+ 10 - 6
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceFileVideoGetServiceImpl.java

@@ -87,7 +87,7 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
 
     /**
      *
-     * @description: 根据账户获取视频素材-账户下全部视频素材
+     * @description: 根据账户获取视频素材-账户/素材id 下全部视频素材
      *
      * @param oauthToken
      * @param page
@@ -97,7 +97,7 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
      * @time: 2022/2/9
      */
     @Override
-    public Map<String,String> getBytedanceVideoByAccountId(OauthToken oauthToken,int page, int pageSize) {
+    public Map<String,String> getBytedanceVideoByAccountId(OauthToken oauthToken,List<Long> materialIds,int page, int pageSize) {
         Map<String,String> resultMap = new HashMap<>();
         log.info("调用接口------getBytedanceVideoByAccountId----根据账户获取视频素材---账户--{}===第{}页===》》》",oauthToken.getAccountId(),page);
         // 请求地址
@@ -106,16 +106,20 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
         param.put("advertiser_id", oauthToken.getAccountId());
         param.put("page", page);
         param.put("page_size", pageSize);
-        /*
+
         JSONObject param2 = new JSONObject();
-       if (!Check.isNull(startDate)){
+        if (!Check.isNull(materialIds)){
+            param2.put("material_ids",materialIds);
+        }
+     /*  if (!Check.isNull(startDate)){
             param2.put("start_time",startDate);
         }
         if (!Check.isNull(endDate)){
             param2.put("end_time",endDate);
         }
-        param.put("filtering",param2);
         */
+        param.put("filtering",param2);
+
         JSONObject resultObject = HttpUtils.bytedanceGetRequest(oauthToken.getAccessToken(), url, param);
         Integer code = resultObject.getInteger("code");
         if (null == code || !code.equals(0)) {
@@ -149,7 +153,7 @@ public class BytedanceFileVideoGetServiceImpl implements IBytedanceFileVideoGetS
         page++;
         int totalPage = resultObject.getJSONObject("data").getJSONObject("page_info").getInteger("total_page");
         if (page <= totalPage) {
-            getBytedanceVideoByAccountId(oauthToken,page, 100);
+            getBytedanceVideoByAccountId(oauthToken,materialIds,page, 100);
         }
         resultMap.put("code","0");
         resultMap.put("message","success");