소스 검색

直播脚本提交;定时任务刷新点赞数

yuhongqi 6 일 전
부모
커밋
ccb1a91be2
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 1
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java

+ 10 - 1
fs-service-system/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java

@@ -18,6 +18,8 @@ import com.fs.live.vo.ColumnsConfigVo;
 import com.fs.live.vo.DateRange;
 import com.fs.live.vo.RecentLiveDataVo;
 import com.fs.live.vo.TrendDataVO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -43,6 +45,7 @@ import static com.fs.common.constant.LiveKeysConstant.*;
 public class LiveDataServiceImpl implements ILiveDataService {
 
 
+    private static final Logger log = LoggerFactory.getLogger(LiveDataServiceImpl.class);
     @Autowired
     private LiveDataMapper liveDataMapper;
     private final RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
@@ -436,7 +439,7 @@ public class LiveDataServiceImpl implements ILiveDataService {
         //用户直播间第一次点赞
         if(firstLike) {
             //直播间总点赞数
-            redisCache.increment("live:like:" + liveId,1);
+
             liveUserLike = liveUserLikeService.selectLiveUserLikeByIds(liveId, userId);
             if (liveUserLike == null) {
                 liveUserLike = new LiveUserLike();
@@ -450,8 +453,14 @@ public class LiveDataServiceImpl implements ILiveDataService {
             //用户直播间点赞数
             redisCache.increment(key,1);
             //直播间总点赞数
+        }
+        try {
             redisCache.increment("live:like:" + liveId,1);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            redisCache.setCacheObject("live:like:" + liveId, 1L);
         }
+
         return R.ok().put("like",redisCache.getCacheObject(key));
     }