From 37ea93e92306572b3e5f67b673a255906a473ba5 Mon Sep 17 00:00:00 2001 From: Wonder Date: Mon, 20 Oct 2025 20:44:27 +0800 Subject: [PATCH] =?UTF-8?q?=20=E2=99=BB=EF=B8=8FRefactor:=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=80=BC=E8=8E=B7=E5=8F=96=E7=9A=84=E5=88=A4=E7=A9=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/hezhaohui/thumb/service/impl/ThumbServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cn/hezhaohui/thumb/service/impl/ThumbServiceImpl.java b/src/main/java/cn/hezhaohui/thumb/service/impl/ThumbServiceImpl.java index 484ae10..79e9513 100644 --- a/src/main/java/cn/hezhaohui/thumb/service/impl/ThumbServiceImpl.java +++ b/src/main/java/cn/hezhaohui/thumb/service/impl/ThumbServiceImpl.java @@ -88,10 +88,10 @@ public class ThumbServiceImpl extends ServiceImpl Long blogId = doThumbRequest.getBlogId(); // 判断是否已点过赞 Object thumbIdObj = redisTemplate.opsForHash().get(ThumbConstant.USER_THUMB_KEY_PREFIX + loginUser.getId().toString(), blogId.toString()); - Long thumbId = thumbIdObj == null ? null : ((Number) thumbIdObj).longValue(); - if (thumbId == null) { + if (thumbIdObj == null) { throw new BusinessException(ErrorCode.OPERATION_ERROR, "用户未点赞"); } + Long thumbId = ((Number) thumbIdObj).longValue(); // 更新帖子点赞计数器 boolean update = blogService.lambdaUpdate() .eq(Blog::getId, blogId)