Browse Source

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

yangzian 3 years ago
parent
commit
3e891a24b4

+ 10 - 7
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/KuaishouController.java

@@ -3,15 +3,15 @@ package cn.com.ctop.job.kuaishou.controller;
 import cn.com.ctop.job.kuaishou.data.service.IKuaishouVideoListService;
 import cn.com.ctop.job.kuaishou.data.service.IKuaishouVideoListService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
 import cn.com.ctop.job.kuaishou.data.utils.Check;
 import cn.com.ctop.job.kuaishou.data.utils.Check;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -33,10 +33,13 @@ public class KuaishouController {
 
 
 
 
     @ApiOperation(value="根据账户获取视频素材-账户下全部视频素材", notes="根据账户获取视频素材-账户下全部视频素材")
     @ApiOperation(value="根据账户获取视频素材-账户下全部视频素材", notes="根据账户获取视频素材-账户下全部视频素材")
-    @GetMapping(value = "/getKuaishouVideoByAccountId")
-    public Map<String,String> getKuaishouVideoByAccountId(@RequestParam(name="accountId") Long accountId) {
+    @PostMapping(value = "/getKuaishouVideoByAccountId")
+    public Map<String,String> getKuaishouVideoByAccountId(@RequestBody JSONObject jsonObject) {
+        Long accountId = jsonObject.getLong("accountId");
+        JSONArray dataList = jsonObject.getJSONArray("photoIds");
+        List<String> materialIds = Check.isNull(dataList) ? null : JSONArray.parseObject(dataList.toJSONString(), List.class);
         String token = tokenService.getByAccountId(accountId);
         String token = tokenService.getByAccountId(accountId);
-       return videoListService.getKuaishouVideoByAccountId(accountId, token, 1);
+       return videoListService.getKuaishouVideoByAccountId(accountId, token,materialIds, 1);
     }
     }
 
 
 
 

+ 2 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IKuaishouVideoListService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.job.kuaishou.data.service;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouVideoList;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouVideoList;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -15,5 +16,5 @@ import java.util.Map;
 public interface IKuaishouVideoListService extends IService<KuaishouVideoList> {
 public interface IKuaishouVideoListService extends IService<KuaishouVideoList> {
     void getVideoList(Long advertiserId, String accessToken, String startDate, String endDate, int page);
     void getVideoList(Long advertiserId, String accessToken, String startDate, String endDate, int page);
 
 
-    Map<String,String> getKuaishouVideoByAccountId(Long advertiserId, String accessToken, int page);
+    Map<String,String> getKuaishouVideoByAccountId(Long advertiserId, String accessToken, List<String> materialIds, int page);
 }
 }

+ 6 - 2
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaishouVideoListServiceImpl.java

@@ -133,7 +133,7 @@ public class KuaishouVideoListServiceImpl extends ServiceImpl<KuaishouVideoListM
      * @time: 2022/2/9
      * @time: 2022/2/9
      */
      */
     @Override
     @Override
-    public Map<String,String> getKuaishouVideoByAccountId(Long advertiserId, String accessToken, int page) {
+    public Map<String,String> getKuaishouVideoByAccountId(Long advertiserId, String accessToken,List<String> materialIds, int page) {
         log.info("调用接口------getKuaishouVideoByAccountId----根据账户获取视频素材---账户--{}===第{}页===》》》",advertiserId,page);
         log.info("调用接口------getKuaishouVideoByAccountId----根据账户获取视频素材---账户--{}===第{}页===》》》",advertiserId,page);
         Map<String,String> resultMap = new HashMap<>();
         Map<String,String> resultMap = new HashMap<>();
         String url = postUrl + KuaishouConstant.VIDEO_LIST;
         String url = postUrl + KuaishouConstant.VIDEO_LIST;
@@ -148,6 +148,10 @@ public class KuaishouVideoListServiceImpl extends ServiceImpl<KuaishouVideoListM
             param.put("start_date", startDate);
             param.put("start_date", startDate);
             param.put("end_date", endDate);
             param.put("end_date", endDate);
         }*/
         }*/
+
+        if (!Check.isNull(materialIds)){
+            param.put("photo_ids", materialIds);
+        }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         JSONObject resultJson = JSONObject.parseObject(result);
         if (Check.isNull(resultJson)) {
         if (Check.isNull(resultJson)) {
@@ -216,7 +220,7 @@ public class KuaishouVideoListServiceImpl extends ServiceImpl<KuaishouVideoListM
             videoListMapper.replaceBatch(videoGetList);
             videoListMapper.replaceBatch(videoGetList);
         }
         }
         if (toGet) {
         if (toGet) {
-            getKuaishouVideoByAccountId(advertiserId, accessToken, page + 1);
+            getKuaishouVideoByAccountId(advertiserId, accessToken, materialIds,page + 1);
         } else {
         } else {
             log.info("视频列表数据获取完成:accountId:{}", advertiserId);
             log.info("视频列表数据获取完成:accountId:{}", advertiserId);
         }
         }