|
|
@ -12,7 +12,6 @@ import com.baiye.core.base.api.Result;
|
|
|
|
import com.baiye.core.constant.DefaultNumberConstants;
|
|
|
|
import com.baiye.core.constant.DefaultNumberConstants;
|
|
|
|
import com.baiye.core.constant.HttpStatus;
|
|
|
|
import com.baiye.core.constant.HttpStatus;
|
|
|
|
import com.baiye.core.page.PageResult;
|
|
|
|
import com.baiye.core.page.PageResult;
|
|
|
|
import com.baiye.core.page.PageUtil;
|
|
|
|
|
|
|
|
import com.baiye.core.util.RedisUtils;
|
|
|
|
import com.baiye.core.util.RedisUtils;
|
|
|
|
import com.baiye.core.util.StringUtils;
|
|
|
|
import com.baiye.core.util.StringUtils;
|
|
|
|
import com.baiye.dao.*;
|
|
|
|
import com.baiye.dao.*;
|
|
|
@ -26,7 +25,6 @@ import com.baiye.service.TiktokHotCommentSopService;
|
|
|
|
import com.baiye.service.TiktokNumOrganizeService;
|
|
|
|
import com.baiye.service.TiktokNumOrganizeService;
|
|
|
|
import com.baiye.service.TiktokUserService;
|
|
|
|
import com.baiye.service.TiktokUserService;
|
|
|
|
import com.baiye.utils.TiktokControlUtil;
|
|
|
|
import com.baiye.utils.TiktokControlUtil;
|
|
|
|
import com.baiye.vo.CommentVo;
|
|
|
|
|
|
|
|
import com.baiye.vo.WriterInfoVo;
|
|
|
|
import com.baiye.vo.WriterInfoVo;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@ -60,6 +58,7 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
private final TiktokEquipmentService equipmentService;
|
|
|
|
private final TiktokEquipmentService equipmentService;
|
|
|
|
private final TiktokControlUtil controlUtil;
|
|
|
|
private final TiktokControlUtil controlUtil;
|
|
|
|
private final RedisUtils redisUtils;
|
|
|
|
private final RedisUtils redisUtils;
|
|
|
|
|
|
|
|
private final CommentMapper commentMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@ -202,46 +201,35 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PageResult commentPageList(VideoDto videoDto, Pageable pageable) {
|
|
|
|
public PageResult commentPageList(String videoId, Pageable pageable) {
|
|
|
|
List<CommentVo> commentVoList = new ArrayList<>();
|
|
|
|
Page<CommentEntity> page = new Page<>(pageable.getPageNumber(), pageable.getPageSize());
|
|
|
|
String videoId = videoDto.getVideoId();
|
|
|
|
QueryWrapper<CommentEntity> wrapper = new QueryWrapper<>();
|
|
|
|
List<KeyWordEntity> keyWordEntities = keyWordMapper.selectList(new QueryWrapper<KeyWordEntity>().eq("sop_id", videoDto.getHotCommentId()));
|
|
|
|
wrapper.eq("aweme_id", videoId);
|
|
|
|
JSONObject videoCommentList = requestTiktok.getVideoCommentList("83f268b5-52ed-470c-a6b2-5111ed0d6d11", videoId);
|
|
|
|
IPage<CommentEntity> iPage = commentMapper.selectPage(page, wrapper);
|
|
|
|
if (videoCommentList != null) {
|
|
|
|
for (CommentEntity record : iPage.getRecords()) {
|
|
|
|
JSONArray jsonArray = videoCommentList.getJSONArray(DefaultKeyConstants.COMMENTS);
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
if (CollUtil.isNotEmpty(jsonArray)) {
|
|
|
|
for (String str : record.getWord().split("\\s+")) {
|
|
|
|
for (Object obj : jsonArray) {
|
|
|
|
boolean flag = false;
|
|
|
|
JSONObject commentObj = JSONUtil.parseObj(obj);
|
|
|
|
for (String s : record.getMatchingWord().split("\\s+")) {
|
|
|
|
String text = commentObj.get(DefaultKeyConstants.TEXT) + "";
|
|
|
|
if (str.equals(s)) {
|
|
|
|
JSONObject userObj = commentObj.getJSONObject(DefaultKeyConstants.USER);
|
|
|
|
flag = true;
|
|
|
|
for (KeyWordEntity keyWordEntity : keyWordEntities) {
|
|
|
|
continue;
|
|
|
|
String[] arr = keyWordEntity.getWord().trim().split("\\s+");
|
|
|
|
}
|
|
|
|
WordTree tree = new WordTree();
|
|
|
|
}
|
|
|
|
for (String s : arr) {
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
tree.addWord(s);
|
|
|
|
map.put("type", 0);
|
|
|
|
}
|
|
|
|
map.put("word", str);
|
|
|
|
List<String> matchAll = tree.matchAll(text, -1, false, false);
|
|
|
|
if (flag) {
|
|
|
|
if (CollUtil.isNotEmpty(matchAll)) {
|
|
|
|
map.put("type", 1);
|
|
|
|
CommentVo commentVo = new CommentVo();
|
|
|
|
}
|
|
|
|
commentVo.setCommentId(commentObj.get(DefaultKeyConstants.CID) + "");
|
|
|
|
list.add(map);
|
|
|
|
long dateObj = Long.parseLong(commentObj.get(DefaultKeyConstants.CREATE_TIME) + "");
|
|
|
|
|
|
|
|
commentVo.setCommentTime(new Date(dateObj));
|
|
|
|
|
|
|
|
commentVo.setAddress(commentObj.get(DefaultKeyConstants.IP_LABEL) + "");
|
|
|
|
|
|
|
|
commentVo.setName(userObj.get(DefaultKeyConstants.NICK_NAME) + "");
|
|
|
|
|
|
|
|
commentVo.setText(text);
|
|
|
|
|
|
|
|
commentVo.setSpecificKeyWord(matchAll);
|
|
|
|
|
|
|
|
List<String> list = Arrays.asList(arr);
|
|
|
|
|
|
|
|
list.removeAll(matchAll);
|
|
|
|
|
|
|
|
commentVo.setKeyWord(list);
|
|
|
|
|
|
|
|
commentVoList.add(commentVo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
record.setTypeMapList(list);
|
|
|
|
|
|
|
|
record.setWord(null);
|
|
|
|
|
|
|
|
record.setMatchingWord(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<CommentVo> returnList = commentVoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
|
|
|
|
return PageResult.success(iPage.getTotal(), iPage.getPages(), iPage.getRecords());
|
|
|
|
() -> new TreeSet<>(Comparator.comparing(CommentVo::getCommentId))), ArrayList::new));
|
|
|
|
|
|
|
|
return PageResult.success((long) returnList.size(), PageUtil.toPage(pageable.getPageNumber() - 1, pageable.getPageSize(), returnList));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -283,9 +271,9 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
for (TiktokHotCommentVideoEntity videoEntity : videoEntityList) {
|
|
|
|
for (TiktokHotCommentVideoEntity videoEntity : videoEntityList) {
|
|
|
|
Result<Object> result = userService.awemeDetail(null, videoEntity.getVideoId());
|
|
|
|
Result<Object> result = userService.awemeDetail(null, videoEntity.getVideoId());
|
|
|
|
if (result.getCode() == HttpStatus.SUCCESS) {
|
|
|
|
if (result.getCode() == HttpStatus.SUCCESS) {
|
|
|
|
JSONObject awemeDetailObj = JSONUtil.parseObj(result.getData()).getJSONObject(DefaultKeyConstants.AWEME_DETAIL);
|
|
|
|
JSONObject videoDetailObj = JSONUtil.parseObj(result.getData()).getJSONObject(DefaultKeyConstants.AWEME_DETAIL);
|
|
|
|
if (awemeDetailObj != null) {
|
|
|
|
if (videoDetailObj != null) {
|
|
|
|
JSONObject statisticsObj = awemeDetailObj.getJSONObject(DefaultKeyConstants.STATISTICS);
|
|
|
|
JSONObject statisticsObj = videoDetailObj.getJSONObject(DefaultKeyConstants.STATISTICS);
|
|
|
|
videoEntity.setFabulousNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.ADMIRE_COUNT)));//?????
|
|
|
|
videoEntity.setFabulousNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.ADMIRE_COUNT)));//?????
|
|
|
|
videoEntity.setCollectionNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COLLECT_COUNT)));
|
|
|
|
videoEntity.setCollectionNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COLLECT_COUNT)));
|
|
|
|
videoEntity.setCommentNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COMMENT_COUNT)));
|
|
|
|
videoEntity.setCommentNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COMMENT_COUNT)));
|
|
|
@ -338,12 +326,12 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
for (TiktokHotCommentSearchEntity searchEntity : searchEntities) {
|
|
|
|
for (TiktokHotCommentSearchEntity searchEntity : searchEntities) {
|
|
|
|
Result<Object> result = userService.searchUser(searchEntity.getMatchingMedia());
|
|
|
|
Result<Object> result = userService.searchUser(searchEntity.getMatchingMedia());
|
|
|
|
if (result.getCode() != HttpStatus.SUCCESS) {
|
|
|
|
if (result.getCode() != HttpStatus.SUCCESS) {
|
|
|
|
log.error("========userId搜索失败:{}========", result.getMsg());
|
|
|
|
log.error("========搜索用户失败,错误信息:{}========", result.getMsg());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String userId = this.getUserId(result.getData());
|
|
|
|
String userId = this.getUserId(result.getData());
|
|
|
|
if (StringUtils.isBlank(userId)) {
|
|
|
|
if (StringUtils.isBlank(userId)) {
|
|
|
|
log.error("========userId搜索为空========");
|
|
|
|
log.error("========搜索用户为空========");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userIdList.add(userId);
|
|
|
|
userIdList.add(userId);
|
|
|
@ -358,7 +346,9 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
this.parseGetVideoList(result.getData(), type, sopEntity, newVideoList);
|
|
|
|
this.parseGetVideoList(result.getData(), type, sopEntity, newVideoList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 3、最新请求视频信息和数据库的视频信息“去重”,然后插入-执行脚本
|
|
|
|
// 3、关键词匹配评论操作跟评
|
|
|
|
|
|
|
|
this.commentList(newVideoList, sopEntity);
|
|
|
|
|
|
|
|
// 4、最新请求视频信息和数据库的视频信息“去重”,然后插入-执行脚本
|
|
|
|
if (CollUtil.isNotEmpty(newVideoList)) {
|
|
|
|
if (CollUtil.isNotEmpty(newVideoList)) {
|
|
|
|
// 求差集-执行脚本-插入
|
|
|
|
// 求差集-执行脚本-插入
|
|
|
|
List<TiktokHotCommentVideoEntity> videoEntityList = videoMapper.selectList(new QueryWrapper<>());
|
|
|
|
List<TiktokHotCommentVideoEntity> videoEntityList = videoMapper.selectList(new QueryWrapper<>());
|
|
|
@ -377,13 +367,148 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 解析JSON 获取用户的userId
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param data 请求接口后返回的信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String getUserId(Object data) {
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(data);
|
|
|
|
|
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(jsonObject.get(DefaultKeyConstants.USER_LIST));
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(jsonArray)) {
|
|
|
|
|
|
|
|
// 取user_list集合的第一个数据就是准确匹配的那一个人
|
|
|
|
|
|
|
|
Object obj = jsonArray.get(DefaultNumberConstants.ZERO_NUMBER);
|
|
|
|
|
|
|
|
JSONObject dynamicPatch = JSONUtil.parseObj(obj).getJSONObject(DefaultKeyConstants.DYNAMIC_PATCH);
|
|
|
|
|
|
|
|
JSONObject rawData = dynamicPatch.getJSONObject(DefaultKeyConstants.RAW_DATA);
|
|
|
|
|
|
|
|
JSONObject rawDataObj = JSONUtil.parseObj(JSONUtil.toJsonStr(rawData));
|
|
|
|
|
|
|
|
JSONObject userInfoObj = rawDataObj.getJSONObject(DefaultKeyConstants.USER_INFO);
|
|
|
|
|
|
|
|
return userInfoObj.get(DefaultKeyConstants.UID).toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 解析用户作品接口JSON,获取用户的最新一条视频集合
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param data JSON数据
|
|
|
|
|
|
|
|
* @param type 搜索用户的类型匹配
|
|
|
|
|
|
|
|
* @param hotCommentSopEntity sop实体信息
|
|
|
|
|
|
|
|
* @param newVideoList 用户的最新的一条视频的集合
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void parseGetVideoList(Object data, String type, TiktokHotCommentSopEntity hotCommentSopEntity, List<TiktokHotCommentVideoEntity> newVideoList) {
|
|
|
|
|
|
|
|
Object objList = JSONUtil.parseObj(data).get(DefaultKeyConstants.AWEME_LIST);
|
|
|
|
|
|
|
|
JSONArray array = JSONUtil.parseArray(objList);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(array)) {
|
|
|
|
|
|
|
|
List<TiktokHotCommentVideoEntity> videoEntityList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Object o : array) {
|
|
|
|
|
|
|
|
JSONObject obj = JSONUtil.parseObj(o);
|
|
|
|
|
|
|
|
TiktokHotCommentVideoEntity video = new TiktokHotCommentVideoEntity();
|
|
|
|
|
|
|
|
video.setVideoId(obj.get(DefaultKeyConstants.AWEME_ID) + "");
|
|
|
|
|
|
|
|
video.setHotCommentId(hotCommentSopEntity.getId());
|
|
|
|
|
|
|
|
video.setHotCommentName(hotCommentSopEntity.getName());
|
|
|
|
|
|
|
|
video.setVideoName(obj.get(DefaultKeyConstants.DESC) + "");
|
|
|
|
|
|
|
|
JSONObject authorObj = obj.getJSONObject(DefaultKeyConstants.AUTHOR);
|
|
|
|
|
|
|
|
video.setAuthorId(authorObj.get(DefaultKeyConstants.UID) + "");
|
|
|
|
|
|
|
|
video.setAuthorName(authorObj.get(DefaultKeyConstants.NICK_NAME) + "");
|
|
|
|
|
|
|
|
JSONObject statisticsObj = obj.getJSONObject(DefaultKeyConstants.STATISTICS);
|
|
|
|
|
|
|
|
video.setFabulousNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.ADMIRE_COUNT)));//?????
|
|
|
|
|
|
|
|
video.setCollectionNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COLLECT_COUNT)));
|
|
|
|
|
|
|
|
video.setCommentNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COMMENT_COUNT)));
|
|
|
|
|
|
|
|
video.setForwardNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.FORWARD_COUNT)));
|
|
|
|
|
|
|
|
video.setSortContent(type);
|
|
|
|
|
|
|
|
long dateObj = Long.parseLong(obj.get(DefaultKeyConstants.CREATE_TIME) + "");
|
|
|
|
|
|
|
|
video.setCreateTime(new Date(dateObj));
|
|
|
|
|
|
|
|
videoEntityList.add(video);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取此人的第一个视频
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(videoEntityList)) {
|
|
|
|
|
|
|
|
TiktokHotCommentVideoEntity videoEntity = videoEntityList.stream()
|
|
|
|
|
|
|
|
.sorted((TiktokHotCommentVideoEntity o1, TiktokHotCommentVideoEntity o2) -> Long.compare(o2.getCreateTime().getTime(), o1.getCreateTime().getTime()))
|
|
|
|
|
|
|
|
.collect(Collectors.toList()).get(DefaultNumberConstants.ZERO_NUMBER);
|
|
|
|
|
|
|
|
newVideoList.add(videoEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 关键词匹配评论操作跟评
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param videoEntityList
|
|
|
|
|
|
|
|
* @param sopEntity
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void commentList(List<TiktokHotCommentVideoEntity> videoEntityList, TiktokHotCommentSopEntity sopEntity) {
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(videoEntityList)) {
|
|
|
|
|
|
|
|
JSONArray jsonArrayAll = new JSONArray();
|
|
|
|
|
|
|
|
// 1、获取到所有视频的所有评论存入jsonArrayAll
|
|
|
|
|
|
|
|
for (TiktokHotCommentVideoEntity videoEntity : videoEntityList) {
|
|
|
|
|
|
|
|
JSONObject videoCommentList = requestTiktok.getVideoCommentList("83f268b5-52ed-470c-a6b2-5111ed0d6d11", videoEntity.getVideoId());
|
|
|
|
|
|
|
|
if (videoCommentList != null) {
|
|
|
|
|
|
|
|
JSONArray jsonArray = videoCommentList.getJSONArray(DefaultKeyConstants.COMMENTS);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(jsonArray)) {
|
|
|
|
|
|
|
|
jsonArrayAll.addAll(jsonArray);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2、取出一个sop中所有关键词加入到DFA查找中
|
|
|
|
|
|
|
|
WordTree tree = new WordTree();
|
|
|
|
|
|
|
|
for (KeyWordEntity keyWordEntity : sopEntity.getKeyWordList()) {
|
|
|
|
|
|
|
|
String[] arr = keyWordEntity.getWord().trim().split("\\s+");
|
|
|
|
|
|
|
|
for (String str : arr) {
|
|
|
|
|
|
|
|
tree.addWord(str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3、循环评论进行匹配
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(jsonArrayAll)) {
|
|
|
|
|
|
|
|
List<CommentEntity> saveList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Object obj : jsonArrayAll) {
|
|
|
|
|
|
|
|
JSONObject commentObj = JSONUtil.parseObj(obj);
|
|
|
|
|
|
|
|
String text = commentObj.get(DefaultKeyConstants.TEXT) + "";
|
|
|
|
|
|
|
|
JSONObject userObj = commentObj.getJSONObject(DefaultKeyConstants.USER);
|
|
|
|
|
|
|
|
// 3.1、匹配成功后添加信息
|
|
|
|
|
|
|
|
List<String> matchAll = tree.matchAll(text, -1, false, false);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(matchAll)) {
|
|
|
|
|
|
|
|
CommentEntity commentEntity = new CommentEntity();
|
|
|
|
|
|
|
|
commentEntity.setCid(commentObj.get(DefaultKeyConstants.CID) + "");
|
|
|
|
|
|
|
|
long dateObj = Long.parseLong(commentObj.get(DefaultKeyConstants.CREATE_TIME) + "");
|
|
|
|
|
|
|
|
commentEntity.setCreateTime(new Date(dateObj));
|
|
|
|
|
|
|
|
commentEntity.setText(text);
|
|
|
|
|
|
|
|
commentEntity.setAwemeId(commentObj.get(DefaultKeyConstants.AWEME_ID) + "");
|
|
|
|
|
|
|
|
commentEntity.setMatchingWord(StringUtils.join((CharSequence) matchAll, ","));
|
|
|
|
|
|
|
|
commentEntity.setNickName(userObj.get(DefaultKeyConstants.NICK_NAME) + "");
|
|
|
|
|
|
|
|
commentEntity.setUserId(userObj.get(DefaultKeyConstants.UID) + "");
|
|
|
|
|
|
|
|
List<KeyWordEntity> keyWordList = sopEntity.getKeyWordList();
|
|
|
|
|
|
|
|
commentEntity.setWord(StringUtils.join((CharSequence) keyWordList, "\\+s"));
|
|
|
|
|
|
|
|
commentEntity.setAddress(commentObj.get(DefaultKeyConstants.IP_LABEL) + "");
|
|
|
|
|
|
|
|
String avatarUrl = (String) userObj.getJSONObject(DefaultKeyConstants.AVATAR_MEDIUM).getJSONArray(DefaultKeyConstants.URL_LIST).get(0);
|
|
|
|
|
|
|
|
commentEntity.setAvatarUrl(avatarUrl);
|
|
|
|
|
|
|
|
saveList.add(commentEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3.2、插入信息
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(saveList)) {
|
|
|
|
|
|
|
|
// ArrayList<CommentEntity> insert = saveList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
|
|
|
|
|
|
|
|
// () -> new TreeSet<>(Comparator.comparing(CommentEntity::getCid))), ArrayList::new));
|
|
|
|
|
|
|
|
commentMapper.insertAll(saveList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//4、匹配到的评论进行跟评
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(saveList)){
|
|
|
|
|
|
|
|
for (CommentEntity comment : saveList) {
|
|
|
|
|
|
|
|
requestTiktok.optCommentVideoComment("", comment.getAwemeId(), comment.getCid(),"小可爱");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 执行脚本
|
|
|
|
* 执行脚本
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param videoEntityList 要执行的视频集合
|
|
|
|
* @param videoEntityList 要执行的视频集合
|
|
|
|
* @param searchVendorId 进行搜索的用户标识
|
|
|
|
* @param searchVendorId 进行搜索的用户标识
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void implementScript(List<TiktokHotCommentVideoEntity> videoEntityList, String searchVendorId, TiktokHotCommentSopEntity sopEntity) {
|
|
|
|
public void implementScript(List<TiktokHotCommentVideoEntity> videoEntityList, String
|
|
|
|
|
|
|
|
searchVendorId, TiktokHotCommentSopEntity sopEntity) {
|
|
|
|
List<TiktokHotCommentScriptEntity> scriptEntityList = scriptMapper.selectList(
|
|
|
|
List<TiktokHotCommentScriptEntity> scriptEntityList = scriptMapper.selectList(
|
|
|
|
new QueryWrapper<TiktokHotCommentScriptEntity>().eq("hot_comment_id", sopEntity.getId()));
|
|
|
|
new QueryWrapper<TiktokHotCommentScriptEntity>().eq("hot_comment_id", sopEntity.getId()));
|
|
|
|
Map<String, List<TiktokHotCommentVideoEntity>> videoMap = videoEntityList.stream().collect(Collectors.groupingBy(TiktokHotCommentVideoEntity::getSortContent));
|
|
|
|
Map<String, List<TiktokHotCommentVideoEntity>> videoMap = videoEntityList.stream().collect(Collectors.groupingBy(TiktokHotCommentVideoEntity::getSortContent));
|
|
|
@ -452,69 +577,6 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 解析JSON 获取用户的userId
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param data 请求接口后返回的信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String getUserId(Object data) {
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(data);
|
|
|
|
|
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(jsonObject.get(DefaultKeyConstants.USER_LIST));
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(jsonArray)) {
|
|
|
|
|
|
|
|
// 取user_list集合的第一个数据就是准确匹配的那一个人
|
|
|
|
|
|
|
|
Object obj = jsonArray.get(DefaultNumberConstants.ZERO_NUMBER);
|
|
|
|
|
|
|
|
JSONObject dynamicPatch = JSONUtil.parseObj(obj).getJSONObject(DefaultKeyConstants.DYNAMIC_PATCH);
|
|
|
|
|
|
|
|
JSONObject rawData = dynamicPatch.getJSONObject(DefaultKeyConstants.RAW_DATA);
|
|
|
|
|
|
|
|
JSONObject rawDataObj = JSONUtil.parseObj(JSONUtil.toJsonStr(rawData));
|
|
|
|
|
|
|
|
JSONObject userInfoObj = rawDataObj.getJSONObject(DefaultKeyConstants.USER_INFO);
|
|
|
|
|
|
|
|
return userInfoObj.get(DefaultKeyConstants.UID).toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 解析用户作品接口JSON,获取用户的最新一条视频集合
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param data JSON数据
|
|
|
|
|
|
|
|
* @param type 搜索用户的类型匹配
|
|
|
|
|
|
|
|
* @param hotCommentSopEntity sop实体信息
|
|
|
|
|
|
|
|
* @param newVideoList 用户的最新的一条视频的集合
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void parseGetVideoList(Object data, String type, TiktokHotCommentSopEntity hotCommentSopEntity, List<TiktokHotCommentVideoEntity> newVideoList) {
|
|
|
|
|
|
|
|
Object objList = JSONUtil.parseObj(data).get(DefaultKeyConstants.AWEME_LIST);
|
|
|
|
|
|
|
|
JSONArray array = JSONUtil.parseArray(objList);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(array)) {
|
|
|
|
|
|
|
|
List<TiktokHotCommentVideoEntity> videoEntityList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Object o : array) {
|
|
|
|
|
|
|
|
JSONObject obj = JSONUtil.parseObj(o);
|
|
|
|
|
|
|
|
TiktokHotCommentVideoEntity video = new TiktokHotCommentVideoEntity();
|
|
|
|
|
|
|
|
video.setVideoId(obj.get(DefaultKeyConstants.AWEME_ID) + "");
|
|
|
|
|
|
|
|
video.setHotCommentId(hotCommentSopEntity.getId());
|
|
|
|
|
|
|
|
video.setHotCommentName(hotCommentSopEntity.getName());
|
|
|
|
|
|
|
|
video.setVideoName(obj.get(DefaultKeyConstants.DESC) + "");
|
|
|
|
|
|
|
|
JSONObject authorObj = obj.getJSONObject(DefaultKeyConstants.AUTHOR);
|
|
|
|
|
|
|
|
video.setAuthorId(authorObj.get(DefaultKeyConstants.UID) + "");
|
|
|
|
|
|
|
|
video.setAuthorName(authorObj.get(DefaultKeyConstants.NICK_NAME) + "");
|
|
|
|
|
|
|
|
JSONObject statisticsObj = obj.getJSONObject(DefaultKeyConstants.STATISTICS);
|
|
|
|
|
|
|
|
video.setFabulousNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.ADMIRE_COUNT)));//?????
|
|
|
|
|
|
|
|
video.setCollectionNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COLLECT_COUNT)));
|
|
|
|
|
|
|
|
video.setCommentNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.COMMENT_COUNT)));
|
|
|
|
|
|
|
|
video.setForwardNum(Convert.toInt(statisticsObj.get(DefaultKeyConstants.FORWARD_COUNT)));
|
|
|
|
|
|
|
|
video.setSortContent(type);
|
|
|
|
|
|
|
|
long dateObj = Long.parseLong(obj.get(DefaultKeyConstants.CREATE_TIME) + "");
|
|
|
|
|
|
|
|
video.setCreateTime(new Date(dateObj));
|
|
|
|
|
|
|
|
videoEntityList.add(video);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取此人的第一个视频
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(videoEntityList)) {
|
|
|
|
|
|
|
|
TiktokHotCommentVideoEntity videoEntity = videoEntityList.stream()
|
|
|
|
|
|
|
|
.sorted((TiktokHotCommentVideoEntity o1, TiktokHotCommentVideoEntity o2) -> Long.compare(o2.getCreateTime().getTime(), o1.getCreateTime().getTime()))
|
|
|
|
|
|
|
|
.collect(Collectors.toList()).get(DefaultNumberConstants.ZERO_NUMBER);
|
|
|
|
|
|
|
|
newVideoList.add(videoEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 根据封控规则 取号
|
|
|
|
* 根据封控规则 取号
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -522,7 +584,8 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
|
|
|
|
* @param hotCommentSopEntity sop封控规则
|
|
|
|
* @param hotCommentSopEntity sop封控规则
|
|
|
|
* @return key:小组ID val:抖号
|
|
|
|
* @return key:小组ID val:抖号
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Map<Long, String> getVendorId(List<TiktokHotCommentScriptEntity> scriptEntityList, TiktokHotCommentSopEntity hotCommentSopEntity) {
|
|
|
|
public Map<Long, String> getVendorId
|
|
|
|
|
|
|
|
(List<TiktokHotCommentScriptEntity> scriptEntityList, TiktokHotCommentSopEntity hotCommentSopEntity) {
|
|
|
|
Map<Long, Integer> dataMap = new HashMap<>();
|
|
|
|
Map<Long, Integer> dataMap = new HashMap<>();
|
|
|
|
for (TiktokHotCommentScriptEntity scriptEntity : scriptEntityList) {
|
|
|
|
for (TiktokHotCommentScriptEntity scriptEntity : scriptEntityList) {
|
|
|
|
Long preemptCommentOrganize = scriptEntity.getPreemptCommentOrganize();
|
|
|
|
Long preemptCommentOrganize = scriptEntity.getPreemptCommentOrganize();
|
|
|
|