Jelajahi Sumber

修改详情页面报错

xuzuoyun 6 tahun lalu
induk
melakukan
a29e644506

+ 6 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdCoverController.java

@@ -59,7 +59,7 @@ public class AdCoverController {
         return result;
     }
 
-//    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    //    @RequestMapping(value = "/list", method = RequestMethod.GET)
 //    //@RequiresPermissions("sys:user:list")
 //    public Result<IPage<SysUser>> queryPageList(SysUser user, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 //                                                @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
@@ -71,13 +71,6 @@ public class AdCoverController {
 //        result.setResult(pageList);
 //        return result;
 //    }
-
-    /**
-     *
-     * @param photoId
-     * @param userId
-     * @return
-     */
     @ResponseBody
     @RequestMapping(value="/detail", method = RequestMethod.GET)
     public Result<Map<String,Object>> getDetail(@RequestParam(name="photoId") Long photoId, @RequestParam(name="userId") Long userId){
@@ -91,11 +84,14 @@ public class AdCoverController {
         if(kuaishouAdAccount == null){
             kuaishouAdAccount = new KuaishouAdAccount();
         }
+        ad = list.get(0);
         if(video == null){
             video = new AppVideo();
+            video.setMvUrl(ad.getMvUrl());
         }
-        kuaishouAdAccount.setUrl("https://live.kuaishou.com/profile/"+video.getShareInfo().substring(video.getShareInfo().indexOf("=")+1,video.getShareInfo().indexOf("&")));
-        video.setShareInfo("https://live.kuaishou.com/u/"+video.getShareInfo().replace("userId=","").replace("photoId=","").replace("&","/"));
+
+        kuaishouAdAccount.setUrl("https://live.kuaishou.com/profile/" + ad.getShareInfo().substring(ad.getShareInfo().indexOf("=") + 1, ad.getShareInfo().indexOf("&")));
+        video.setShareInfo("https://live.kuaishou.com/u/" + ad.getShareInfo().replace("userId=", "").replace("photoId=", "").replace("&", "/"));
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("adlist",list);
         map.put("user",kuaishouAdAccount);

+ 2 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/IKuaishouCrawlerService.java

@@ -9,4 +9,6 @@ public interface IKuaishouCrawlerService {
     public String getVideoFeeds(KuaishouIosAccount kuaishouIosAccount);
     public String getAdAccountVideoFeeds(KuaishouAdAccount kuaishouAdAccount,String pcursor);
     public String getAdFeeds();
+
+    public String getUserProfile(Long userId);
 }

File diff ditekan karena terlalu besar
+ 11 - 3
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/impl/KuaishouCrawlerServiceImpl.java


+ 22 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/impl/KuaishouAppServiceImpl.java

@@ -12,14 +12,17 @@ import cn.com.ctop.kuaishou.modules.app.entity.AppVideo;
 import cn.com.ctop.kuaishou.modules.app.service.IAppAdService;
 import cn.com.ctop.kuaishou.modules.app.service.IAppVideoService;
 import cn.com.ctop.kuaishou.modules.app.service.IKuaishouAppService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
 
 @Service
@@ -73,9 +76,9 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
                                 kuaishouAdAccount.setKsid(ad.getUserId());
                                 kuaishouAdAccount.setName(ad.getUserName());
                                 kuaishouAdAccountService.save(kuaishouAdAccount);
-//                                this.adAccountFetch(kuaishouAdAccount,"");
+                                this.adAccountFetch(kuaishouAdAccount, "");
                             }
-                            AppVideo video = appVideoService.getById(ad.getPhotoId());
+//                            AppVideo video = appVideoService.getById(ad.getPhotoId());
 
 //                            AppVideo video = new AppVideo();
 //                            video.setShareInfo();
@@ -95,10 +98,25 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
     }
 
     public void adAccountFetch(KuaishouAdAccount kuaishouAdAccount,String pcursor){
-        String adAccountVideoFeeds = kuaishouCrawlerService.getAdAccountVideoFeeds(kuaishouAdAccount,pcursor);
+        String userProfileStr = kuaishouCrawlerService.getUserProfile(kuaishouAdAccount.getKsid());
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+
         try {
+            JsonNode userProfileNode = mapper.readTree(userProfileStr);
+            System.out.println(userProfileStr);
+            int photoCount = userProfileNode.get("userProfile").get("ownerCount").get("photo").asInt();
+            AppVideo video = new AppVideo();
+            video.setUserId(kuaishouAdAccount.getKsid());
+            QueryWrapper<AppVideo> queryWrapper = QueryGenerator.initQueryWrapper(video, new HashMap());
+
+            int videoCount = appVideoService.count(queryWrapper);
+            if (photoCount <= videoCount) {
+                return;
+            }
+            String adAccountVideoFeeds = kuaishouCrawlerService.getAdAccountVideoFeeds(kuaishouAdAccount, pcursor);
+
             JsonNode node = mapper.readTree(adAccountVideoFeeds);
             List<AppVideo> list = mapper.readValue(node.get("feeds").toString(),new TypeReference<List<AppVideo>>(){});
             pcursor = node.get("pcursor").asText();
@@ -162,7 +180,7 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
                                 kuaishouAdAccount.setKsid(ad.getUserId());
                                 kuaishouAdAccount.setName(ad.getUserName());
                                 kuaishouAdAccountService.save(kuaishouAdAccount);
-//                                this.adAccountFetch(kuaishouAdAccount,"");
+                                this.adAccountFetch(kuaishouAdAccount, "");
                             }
                         } catch (Exception e) {
                             e.printStackTrace();