Authored by mlge

Merge branch 'test6.8.9' of http://git.yoho.cn/platform/platform-cms into test6.8.9

... ... @@ -7,12 +7,16 @@ import com.yoho.service.model.social.request.UicUserReqBO;
import com.yoho.service.model.social.response.UserInfoRspBO;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassArticleCommentDao;
import com.yohobuy.platform.dal.grass.IGrassArticleDao;
import com.yohobuy.platform.dal.grass.model.GrassArticle;
import com.yohobuy.platform.dal.grass.model.GrassArticleComment;
import com.yohobuy.platform.dal.grass.model.GrassArticleCommentQueryDo;
import com.yohobuy.platform.grass.service.IGrassArticleCommentService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq;
import com.yohobuy.platform.model.grass.request.GrassInBoxAddReq;
import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
... ... @@ -35,6 +39,8 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
@Autowired
private IGrassArticleCommentDao grassArticleCommentDao;
@Autowired
private IGrassArticleDao grassArticleDao;
@Autowired
private ServiceCaller serviceCaller;
@Value("${uic.service.url:http://uic.yohoops.org/uic}")
private String uicUrl;
... ... @@ -128,5 +134,50 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
@Override
public void modifyStatus(ArticleCommentModifyStatusReq req) {
grassArticleCommentDao.updateStatus(req.getIds(),req.getStatus(),req.getReviewer(), DateUtil.currentTimeSeconds());
if(req.getStatus() == GrassArticleComment.Status.SUCCESS.getValue()){
sendInBoxMessage(req.getIds());
}
}
private void sendInBoxMessage(List<Integer> commentIds){
logger.info("enter sendInBoxMessage.commentIds is {}",commentIds);
List<GrassArticleComment> commentList = grassArticleCommentDao.selectByIds(commentIds);
//只推送文章消息
commentList = commentList.stream().filter(com->com.getDestId()!=null && com.getColumnType() == GrassArticleComment.ColumnType.ARTICLE.getValue()).collect(Collectors.toList());
if(commentList.isEmpty()){
return;
}
List<Integer> parentIds = commentList.stream().filter(com->com.getParentId()!=null).map(GrassArticleComment::getParentId).collect(Collectors.toList());
Map<Integer,GrassArticleComment> parentCommentMap = CollectionUtils.isEmpty(parentIds)?new HashMap<>():grassArticleCommentDao.selectMapByIds(parentIds);
List<Integer> articleIds = commentList.stream().map(GrassArticleComment::getDestId).collect(Collectors.toList());
Map<Integer,GrassArticle> articleMap = CollectionUtils.isEmpty(articleIds)?new HashMap<>():grassArticleDao.selectMapByIds(articleIds);
List<GrassInBoxAddReq> addReqList = new ArrayList<>();
for(GrassArticleComment comment : commentList){
GrassArticle article = articleMap.get(comment.getDestId());
GrassInBoxAddReq addReq = new GrassInBoxAddReq();
addReq.setAttachValue(comment.getId().toString());
addReq.setOptUid(comment.getUid());
if(comment.getRootId() == null){
if(article.getAuthorType() == GrassArticle.AUTHORTYPE_EDITOR){
continue;//小编用户不发消息
}
addReq.setBusinessType(1002);
addReq.setUid(article.getAuthorUid());
}else{
GrassArticleComment parent = parentCommentMap.get(comment.getParentId());
addReq.setBusinessType(1003);
addReq.setUid(parent.getUid());
}
addReqList.add(addReq);
}
if(CollectionUtils.isEmpty(addReqList)){
return;
}
try{
logger.info("before sns.addBatchInBox.addReqList size is {}",addReqList.size());
serviceCaller.call("sns.addBatchInBox", addReqList, String.class);
}catch (Exception e){
logger.info("failed addBatchInBox, commentIds are {}, error is {}",commentIds, e);
}
}
}
... ...