Bladeren bron

fix 评论点赞收藏

tjf 2 maanden geleden
bovenliggende
commit
ef7dd47d4b

+ 6 - 6
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommentLikesServiceImpl.java

@@ -203,7 +203,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
                     userIdListValue.add(Math.toIntExact(userId));
                     RedisUtils.setCacheList(likeOneKey, userIdListValue);
                     //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间  key=like_one_count_time:{文章id}#{数量}
-                    RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + 1, 1, Duration.ofSeconds(10));
+                    RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + 1, 1, Duration.ofSeconds(1));
                     //给该用户点赞文章的key添加值
                     communityIdList.add(Math.toIntExact(targetId));
                     RedisUtils.setCacheList(myLikeOneKey, communityIdList);
@@ -240,7 +240,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
                     userIdListValue.add(Math.toIntExact(userId));
                     RedisUtils.setCacheList(likeTwoKey, userIdListValue);
                     //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
-                    RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + 1, 1, Duration.ofSeconds(10));
+                    RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + 1, 1, Duration.ofSeconds(1));
                     //给该用户点赞回复的key添加值
                     communityIdList.add(Math.toIntExact(targetId));
                     RedisUtils.setCacheList(myLikeTwoKey, communityIdList);
@@ -288,7 +288,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             likeOneCount = likeOneCount + 1;
             RedisUtils.setCacheObject(likeOneCountKey, likeOneCount);
             //新增数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
-            RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + likeOneCount, likeOneCount, Duration.ofSeconds(10));
+            RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + likeOneCount, likeOneCount, Duration.ofSeconds(1));
             return R.ok();
         } else {
             // 社区资讯文章回复的人员集合的key key = TWO_LIKE:{targetId} value = [userId,userId];
@@ -314,7 +314,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             likeTwoCount = likeTwoCount + 1;
             RedisUtils.setCacheObject(likeTwoCountKey, likeTwoCount);
             //新增数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
-            RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + likeTwoCount, likeTwoCount, Duration.ofSeconds(10));
+            RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + likeTwoCount, likeTwoCount, Duration.ofSeconds(1));
             return R.ok();
         }
     }
@@ -367,7 +367,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             likeCount = likeCount -1;
             RedisUtils.setCacheObject(likeOneCountKey, Math.max(likeCount, 0));
             //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
-            RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + likeCount, likeCount, Duration.ofSeconds(10));
+            RedisUtils.setCacheObject(likeOneCountTimeKey + "#" + likeCount, likeCount, Duration.ofSeconds(1));
             return R.ok();
         } else {
             //评论的删除
@@ -405,7 +405,7 @@ public class CommentLikesServiceImpl implements ICommentLikesService {
             likeCount = likeCount - 1;
             RedisUtils.setCacheObject(likeTwoCountKey, Math.max(likeCount, 0));
             //给数据库同步数据在 redis中增加一个有过期时间的key 1分钟过期时间
-            RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + likeCount, likeCount, Duration.ofSeconds(10));
+            RedisUtils.setCacheObject(likeTwoCountTimeKey + "#" + likeCount, likeCount, Duration.ofSeconds(1));
             return R.ok();
         }
     }

+ 5 - 5
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/CommunityNewsServiceImpl.java

@@ -246,19 +246,19 @@ public class CommunityNewsServiceImpl implements ICommunityNewsService {
         //-------------------设置用户的未读资讯的id和该资讯下一共有多少未读互动数量----------------
         //key=comment_interaction_community_user_count:{userId} hkey = {community_id} value = 资讯下有多少个未读的互动(点赞,收藏,回复)
         String key = tenantId + ":" + COMMENT_INTERACTION_COMMUNITY_USER_COUNT + targetUserId;
-        String commentInteractionCommunityUserCount = RedisUtils.getCacheMapValue(key, communityId.toString());
+        Object commentInteractionCommunityUserCount = RedisUtils.getCacheMapValue(key, communityId.toString());
         //判断是删除还是新增
         if (ONE.equals(type)) {
             //新增
-            if (StringUtils.isNotBlank(commentInteractionCommunityUserCount)) {
-                RedisUtils.setCacheMapValue(key, communityId.toString(), String.valueOf(Integer.parseInt(commentInteractionCommunityUserCount) + 1));
+            if (ObjectUtils.isNotEmpty(commentInteractionCommunityUserCount)) {
+                RedisUtils.setCacheMapValue(key, communityId.toString(), String.valueOf(Integer.parseInt(commentInteractionCommunityUserCount.toString()) + 1));
             } else {
                 RedisUtils.setCacheMapValue(key, communityId.toString(), ONE);
             }
         } else {
             //删除
-            if (StringUtils.isNotBlank(commentInteractionCommunityUserCount)) {
-                int commentInteractionCommunityUserCountResult = Integer.parseInt(commentInteractionCommunityUserCount) - 1;
+            if (ObjectUtils.isNotEmpty(commentInteractionCommunityUserCount)) {
+                int commentInteractionCommunityUserCountResult = Integer.parseInt(commentInteractionCommunityUserCount.toString()) - 1;
                 if (commentInteractionCommunityUserCountResult <= 0) {
                     RedisUtils.delCacheMapValue(key, communityId.toString());
                 } else {