♻️Refactor: 优化值获取的判空逻辑
This commit is contained in:
@@ -88,10 +88,10 @@ public class ThumbServiceImpl extends ServiceImpl<ThumbMapper, Thumb>
|
|||||||
Long blogId = doThumbRequest.getBlogId();
|
Long blogId = doThumbRequest.getBlogId();
|
||||||
// 判断是否已点过赞
|
// 判断是否已点过赞
|
||||||
Object thumbIdObj = redisTemplate.opsForHash().get(ThumbConstant.USER_THUMB_KEY_PREFIX + loginUser.getId().toString(), blogId.toString());
|
Object thumbIdObj = redisTemplate.opsForHash().get(ThumbConstant.USER_THUMB_KEY_PREFIX + loginUser.getId().toString(), blogId.toString());
|
||||||
Long thumbId = thumbIdObj == null ? null : ((Number) thumbIdObj).longValue();
|
if (thumbIdObj == null) {
|
||||||
if (thumbId == null) {
|
|
||||||
throw new BusinessException(ErrorCode.OPERATION_ERROR, "用户未点赞");
|
throw new BusinessException(ErrorCode.OPERATION_ERROR, "用户未点赞");
|
||||||
}
|
}
|
||||||
|
Long thumbId = ((Number) thumbIdObj).longValue();
|
||||||
// 更新帖子点赞计数器
|
// 更新帖子点赞计数器
|
||||||
boolean update = blogService.lambdaUpdate()
|
boolean update = blogService.lambdaUpdate()
|
||||||
.eq(Blog::getId, blogId)
|
.eq(Blog::getId, blogId)
|
||||||
|
|||||||
Reference in New Issue
Block a user