抖音评论实体添加了一个组信息

master
yqy 2 years ago
parent cef5338a74
commit be9cd4f02d

@ -35,6 +35,7 @@ public class CommentEntity {
private String address;
private String avatarUrl;
private String uniqueId;
private Long organizeId;
@TableField(exist = false)
private List<Map<String, Object>> typeMapList;

@ -346,6 +346,8 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
List<String> cidList = commentMapper.selectAllCid();
// 2.3、循环评论进行匹配
if (CollUtil.isNotEmpty(jsonArrayAll)) {
List<TiktokHotCommentScriptEntity> scriptEntityList = scriptMapper.selectList(new QueryWrapper<>());
Map<Long, List<TiktokHotCommentScriptEntity>> map = scriptEntityList.stream().collect(Collectors.groupingBy(TiktokHotCommentScriptEntity::getHotCommentId));
List<CommentEntity> saveList = new ArrayList<>();
for (Object obj : jsonArrayAll) {
JSONObject commentObj = JSONUtil.parseObj(obj);
@ -353,6 +355,7 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
if (cidList.contains(cid)) continue;
String text = commentObj.get(DefaultKeyConstants.TEXT) + "";
String videoId = commentObj.get(DefaultKeyConstants.AWEME_ID) + "";
String awemeId = commentObj.get(DefaultKeyConstants.AWEME_ID) + "";
JSONObject userObj = commentObj.getJSONObject(DefaultKeyConstants.USER);
// 3.1、匹配成功后添加信息
WordTree tree = dfaMap.get(videoSopIdMap.get(videoId));
@ -363,7 +366,7 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
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.setAwemeId(awemeId);
HashSet<String> wordSet = new HashSet<>(matchAll);
commentEntity.setMatchingWord(org.apache.commons.lang3.StringUtils.join(wordSet, ","));
commentEntity.setNickName(userObj.get(DefaultKeyConstants.NICK_NAME) + "");
@ -372,9 +375,13 @@ public class TiktokHotCommentSopServiceImpl extends ServiceImpl<TiktokHotComment
List<String> keyWordList = wordEntityList.stream().map(KeyWordEntity::getWord).collect(Collectors.toList());
commentEntity.setWord(org.apache.commons.lang3.StringUtils.join(keyWordList, ","));
commentEntity.setAddress(commentObj.get(DefaultKeyConstants.IP_LABEL) + "");
commentEntity.setUniqueId(commentObj.get(DefaultKeyConstants.UNIQUE_ID) + "");
commentEntity.setUniqueId(userObj.get("unique_id") + "");
String avatarUrl = (String) userObj.getJSONObject(DefaultKeyConstants.AVATAR_MEDIUM).getJSONArray(DefaultKeyConstants.URL_LIST).get(0);
commentEntity.setAvatarUrl(avatarUrl);
List<TiktokHotCommentScriptEntity> scriptEntities = map.get(videoSopIdMap.get(awemeId));
if (CollUtil.isNotEmpty(scriptEntities)){
commentEntity.setOrganizeId(scriptEntities.get(0).getFollowCommentOrganize());
}
saveList.add(commentEntity);
}
}

@ -8,11 +8,11 @@
</resultMap>
<insert id="insertAll">
insert into tb_comment (cid,text,aweme_id,status,user_id,nick_name,create_time,vendor_id,word,matching_word,address,avatar_url,unique_id)
insert into tb_comment (cid,text,aweme_id,status,user_id,nick_name,create_time,vendor_id,word,matching_word,address,avatar_url,unique_id,organize_id)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.cid}, #{item.text},#{item.awemeId},#{item.status},#{item.userId},#{item.nickName},#{item.createTime}
,#{item.vendorId},#{item.word},#{item.matchingWord},#{item.address},#{item.avatarUrl},#{item.uniqueId})
,#{item.vendorId},#{item.word},#{item.matchingWord},#{item.address},#{item.avatarUrl},#{item.uniqueId},#{item.organizeId})
</foreach>
</insert>

Loading…
Cancel
Save