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

优化

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