|
@@ -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.IAppAdService;
|
|
import cn.com.ctop.kuaishou.modules.app.service.IAppVideoService;
|
|
import cn.com.ctop.kuaishou.modules.app.service.IAppVideoService;
|
|
import cn.com.ctop.kuaishou.modules.app.service.IKuaishouAppService;
|
|
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.core.type.TypeReference;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -73,9 +76,9 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
|
|
kuaishouAdAccount.setKsid(ad.getUserId());
|
|
kuaishouAdAccount.setKsid(ad.getUserId());
|
|
kuaishouAdAccount.setName(ad.getUserName());
|
|
kuaishouAdAccount.setName(ad.getUserName());
|
|
kuaishouAdAccountService.save(kuaishouAdAccount);
|
|
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();
|
|
// AppVideo video = new AppVideo();
|
|
// video.setShareInfo();
|
|
// video.setShareInfo();
|
|
@@ -95,10 +98,25 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
|
|
}
|
|
}
|
|
|
|
|
|
public void adAccountFetch(KuaishouAdAccount kuaishouAdAccount,String pcursor){
|
|
public void adAccountFetch(KuaishouAdAccount kuaishouAdAccount,String pcursor){
|
|
- String adAccountVideoFeeds = kuaishouCrawlerService.getAdAccountVideoFeeds(kuaishouAdAccount,pcursor);
|
|
|
|
|
|
+ String userProfileStr = kuaishouCrawlerService.getUserProfile(kuaishouAdAccount.getKsid());
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
+
|
|
|
|
+
|
|
try {
|
|
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);
|
|
JsonNode node = mapper.readTree(adAccountVideoFeeds);
|
|
List<AppVideo> list = mapper.readValue(node.get("feeds").toString(),new TypeReference<List<AppVideo>>(){});
|
|
List<AppVideo> list = mapper.readValue(node.get("feeds").toString(),new TypeReference<List<AppVideo>>(){});
|
|
pcursor = node.get("pcursor").asText();
|
|
pcursor = node.get("pcursor").asText();
|
|
@@ -162,7 +180,7 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
|
|
kuaishouAdAccount.setKsid(ad.getUserId());
|
|
kuaishouAdAccount.setKsid(ad.getUserId());
|
|
kuaishouAdAccount.setName(ad.getUserName());
|
|
kuaishouAdAccount.setName(ad.getUserName());
|
|
kuaishouAdAccountService.save(kuaishouAdAccount);
|
|
kuaishouAdAccountService.save(kuaishouAdAccount);
|
|
-// this.adAccountFetch(kuaishouAdAccount,"");
|
|
|
|
|
|
+ this.adAccountFetch(kuaishouAdAccount, "");
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|