|
|
package com.yoho.datasync.consumer.handler.listener;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yoho.datasync.consumer.common.EventEnum;
|
|
|
import com.yoho.datasync.consumer.common.ServiceConstant;
|
|
|
import com.yoho.datasync.consumer.handler.helper.AnnotationClassFactory;
|
...
|
...
|
@@ -14,8 +15,11 @@ import com.yoho.datasync.core.base.model.yh_pcms.PublicUserPraise; |
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
@MqConsumerListerner(dbName = "yh_grass",tableName = "grass_article_comment")
|
...
|
...
|
@@ -66,6 +70,44 @@ public class PublicUserCommentListener extends AbstractMqListener<GrassArticleCo |
|
|
if(publicArticle != null){
|
|
|
publicUserComment.setArticleId(publicArticle.getId());
|
|
|
}
|
|
|
//查询当前评论被回复的id,即GrassArticleComment中的parentId对应的评论ID
|
|
|
PublicUserComment publicUserCommentToComment = publicUserCommentService.getPublicUserCommentByUniqueKey
|
|
|
(sourceObject.getParentId(), ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
|
|
|
if(publicUserCommentToComment != null){
|
|
|
publicUserComment.setToCommentId(publicUserCommentToComment.getId());
|
|
|
}
|
|
|
//rootId设置:select id from public_user_comment where relate_id = #{grass_article_comment.root_id} and
|
|
|
// src_channel = 1;
|
|
|
PublicUserComment rootpublicUserComment = publicUserCommentService.getPublicUserCommentByUniqueKey
|
|
|
(sourceObject.getRootId() , ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
|
|
|
if(rootpublicUserComment != null){
|
|
|
publicUserComment.setRootId(rootpublicUserComment.getId());
|
|
|
}
|
|
|
//将grass_article_comment.content的文本格式转换成public_user_comment.content_data的json格式
|
|
|
if(!StringUtils.isEmpty(sourceObject.getContent())){
|
|
|
Map<String , String> contentMap = new HashMap<>();
|
|
|
contentMap.put("type" , "text");
|
|
|
contentMap.put("content" , sourceObject.getContent());
|
|
|
publicUserComment.setContentData(JSON.toJSONString(contentMap));
|
|
|
}
|
|
|
//grass_article_comment.status>0时,public_user_comment.audit_time =grass_article_comment.update_time
|
|
|
//grass_article_comment.status(0 待审核,1通过,2未通过)和public_user_comment.audit_status
|
|
|
// (1-未审核 2-审核通过 3-审核未通过)转换
|
|
|
if(sourceObject.getStatus() != null){
|
|
|
if(sourceObject.getStatus() > 0){
|
|
|
publicUserComment.setAuditTime(Long.valueOf(sourceObject.getUpdateTime()));
|
|
|
}
|
|
|
switch (sourceObject.getStatus()){
|
|
|
case ServiceConstant.Grass_Article_Comment.TO_AUDIT_Status :
|
|
|
publicUserComment.setAuditStatus(ServiceConstant.Public_User_Comment.TO_AUDIT_Status);
|
|
|
break;
|
|
|
case ServiceConstant.Grass_Article_Comment.PASS_AUDIT_STATUS :
|
|
|
publicUserComment.setAuditStatus(ServiceConstant.Public_User_Comment.PASS_AUDIT_STATUS);
|
|
|
break;
|
|
|
case ServiceConstant.Grass_Article_Comment.NOPASS_AUDIT_STATUS :
|
|
|
publicUserComment.setAuditStatus(ServiceConstant.Public_User_Comment.NOPASS_AUDIT_STATUS);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
publicUserCommentService.saveOrUpdatePublicUserComment(publicUserComment);
|
...
|
...
|
|