use of com.ch999.haha.admin.document.redis.CommentZanBO in project haha by hahafreeasair666.
the class NewsServiceImpl method addNewsZan.
@Override
public Boolean addNewsZan(Integer id, Integer userId) {
News news = this.selectById(id);
if (news == null) {
return null;
}
CommentZanBO one = commentZanRepository.findOne(id.toString());
if (one != null) {
if (one.getZanUserList().stream().anyMatch(li -> li.equals(userId))) {
return false;
}
one.getZanUserList().add(userId);
} else {
one = new CommentZanBO();
one.setCommentId(id.toString());
List<Integer> list = new ArrayList<>();
list.add(userId);
one.setZanUserList(list);
}
news.setZan(one.getZanUserList().size());
this.updateById(news);
commentZanRepository.save(one);
return true;
}
Aggregations