提交 63af3d4c authored 作者: zgy's avatar zgy

添加点赞标识

上级 01e67bc6
......@@ -90,11 +90,14 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
double totalScore = lastComment.getItemScore() + lastComment.getLogisticsScore() + lastComment.getPriceScore() + lastComment.getServiceScore();
BigDecimal total = new BigDecimal(totalScore);
double score = total.divide(new BigDecimal(4), 1, BigDecimal.ROUND_UP).doubleValue();
String give_like = (String) redisCache.get(KeyConstant.GIVE_LIKE + userId + itemId);
String give_like = (String) redisCache.get(KeyConstant.GIVE_LIKE + userId + itemId + lastComment.getId());
System.err.println(KeyConstant.GIVE_LIKE + userId + itemId + lastComment.getId());
System.err.println("===>>>" + give_like);
lastComment.setLike(false);
if (!StringUtils.isBlank(give_like) && KeyConstant.YES.equals(give_like)) {
isLike = true;
lastComment.setLike(true);
}
map.put("isLike", isLike);
System.err.println("===>>>" + isLike);
map.put("score", score);
map.put("lastComment", lastComment);
result.setData(map).setMessage("success");
......@@ -124,18 +127,16 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
try {
startPage(pageNum, pageSize);
List<TbCfItemCommentEntity> comments = tbCfItemCommentDao.querycomments(itemId);
List<TbCfItemCommentEntity> commentList = new ArrayList<>();
for (TbCfItemCommentEntity comment : comments) {
TbCfItemCommentEntity commentEntity = tbCfItemCommentDao.queryObject(comment.getId());
commentEntity.setLike(false);
System.err.println(comment.getUserId());
String give_like = (String) redisCache.get(KeyConstant.GIVE_LIKE + comment.getUserId() + comment.getItemId());
comment.setLike(false);
String give_like = (String) redisCache.get(KeyConstant.GIVE_LIKE + userId + comment.getItemId() + comment.getId());
System.err.println(KeyConstant.GIVE_LIKE + userId + itemId + comment.getId());
System.err.println("===>>>" + give_like);
if (!StringUtils.isBlank(give_like) && KeyConstant.YES.equals(give_like)) {
commentEntity.setLike(true);
comment.setLike(true);
}
commentList.add(commentEntity);
}
PageInfo<TbCfItemCommentEntity> pageInfo = new PageInfo<>(commentList);
PageInfo<TbCfItemCommentEntity> pageInfo = new PageInfo<>(comments);
result.setData(pageInfo);
} catch (Exception e) {
result.setCode(ResultCodeEnum.QUERY_ERROR.getCode()).setMessage(e.getMessage());
......@@ -220,15 +221,16 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
Result result = new Result();
try {
String give_like = (String) redisCache.get(KeyConstant.GIVE_LIKE + userId + itemId);
String give_like = (String) redisCache.get(KeyConstant.GIVE_LIKE + userId + itemId + commentId);
System.err.println(KeyConstant.GIVE_LIKE + userId + itemId + commentId);
TbCfItemCommentEntity comment = tbCfItemCommentDao.queryObject(commentId);
Long likeNum = comment.getLikeNum();
if (!StringUtils.isBlank(give_like) && KeyConstant.YES.equals(give_like)) {
comment.setLikeNum(--likeNum);
redisCache.delete(KeyConstant.GIVE_LIKE + userId + itemId);
redisCache.delete(KeyConstant.GIVE_LIKE + userId + itemId + commentId);
} else {
comment.setLikeNum(++likeNum);
redisCache.set(KeyConstant.GIVE_LIKE + userId + itemId, KeyConstant.YES);
redisCache.set(KeyConstant.GIVE_LIKE + userId + itemId + commentId, KeyConstant.YES);
}
tbCfItemCommentDao.update(comment);
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论