提交 5ab04e81 authored 作者: zgy's avatar zgy

优化

上级 63af3d4c
......@@ -91,13 +91,10 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
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 + 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)) {
lastComment.setLike(true);
}
System.err.println("===>>>" + isLike);
map.put("score", score);
map.put("lastComment", lastComment);
result.setData(map).setMessage("success");
......@@ -130,8 +127,6 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
for (TbCfItemCommentEntity comment : comments) {
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)) {
comment.setLike(true);
}
......@@ -228,12 +223,13 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
if (!StringUtils.isBlank(give_like) && KeyConstant.YES.equals(give_like)) {
comment.setLikeNum(--likeNum);
redisCache.delete(KeyConstant.GIVE_LIKE + userId + itemId + commentId);
result.setMessage("Cancel the thumb up!");
} else {
comment.setLikeNum(++likeNum);
redisCache.set(KeyConstant.GIVE_LIKE + userId + itemId + commentId, KeyConstant.YES);
result.setMessage("Thumb up success!");
}
tbCfItemCommentDao.update(comment);
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
} catch (Exception e) {
result.setCode(ResultCodeEnum.SERVICE_ERROR.getCode()).setMessage(e.getMessage());
logger.error(e.getMessage());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论