|
|
@@ -3,6 +3,8 @@ package com.fs.live.service.impl;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.config.cloud.CloudHostProper;
|
|
|
+import com.fs.hisStore.enums.LiveEnum;
|
|
|
import com.fs.live.domain.LiveVideo;
|
|
|
import com.fs.live.mapper.LiveVideoMapper;
|
|
|
import com.fs.live.service.ILiveVideoService;
|
|
|
@@ -31,10 +33,11 @@ public class LiveVideoServiceImpl implements ILiveVideoService
|
|
|
{
|
|
|
@Autowired
|
|
|
private LiveVideoMapper liveVideoMapper;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private CloudHostProper cloudHostProper;
|
|
|
/**
|
|
|
* 查询直播视频
|
|
|
*
|
|
|
@@ -81,8 +84,14 @@ public class LiveVideoServiceImpl implements ILiveVideoService
|
|
|
@Override
|
|
|
public int insertLiveVideo(LiveVideo liveVideo)
|
|
|
{
|
|
|
- // 直播ID为-1,则新增 直播视频库
|
|
|
- liveVideo.setFinishStatus(0);
|
|
|
+ if (LiveEnum.contains(cloudHostProper.getCompanyName())) {
|
|
|
+ liveVideo.setVideoUrl(liveVideo.getLineOne());
|
|
|
+ liveVideo.setFinishStatus(1);
|
|
|
+ }else {
|
|
|
+ // 直播ID为-1,则新增 直播视频库
|
|
|
+ liveVideo.setFinishStatus(0);
|
|
|
+ }
|
|
|
+
|
|
|
if (liveVideo.getLiveId() == -1) {
|
|
|
liveVideo.setCreateTime(DateUtils.getNowDate());
|
|
|
return liveVideoMapper.insertLiveVideo(liveVideo);
|
|
|
@@ -189,21 +198,21 @@ public class LiveVideoServiceImpl implements ILiveVideoService
|
|
|
public List<LiveVideo> listByLiveIdWithCache(Long liveId, Integer type) {
|
|
|
// Redis缓存键
|
|
|
String cacheKey = "live:video:list:" + liveId + ":" + type;
|
|
|
-
|
|
|
+
|
|
|
// 先从缓存中获取
|
|
|
List<LiveVideo> cachedVideos = redisCache.getCacheObject(cacheKey);
|
|
|
if (cachedVideos != null && !cachedVideos.isEmpty()) {
|
|
|
return cachedVideos;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 缓存未命中,从数据库查询
|
|
|
List<LiveVideo> videos = liveVideoMapper.selectByIdAndType(liveId, type);
|
|
|
-
|
|
|
+
|
|
|
// 将查询结果存入缓存,缓存时间1小时
|
|
|
if (videos != null) {
|
|
|
redisCache.setCacheObject(cacheKey, videos, 1, TimeUnit.HOURS);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return videos;
|
|
|
}
|
|
|
|