|
@@ -13,9 +13,10 @@ import cn.reghao.tnb.content.app.vod.model.query.VideoQuery;
|
|
|
import cn.reghao.tnb.content.app.vod.service.ContentPermission;
|
|
import cn.reghao.tnb.content.app.vod.service.ContentPermission;
|
|
|
import cn.reghao.tnb.content.app.vod.service.RecommendService;
|
|
import cn.reghao.tnb.content.app.vod.service.RecommendService;
|
|
|
import cn.reghao.tnb.content.app.vod.service.VideoPostQuery;
|
|
import cn.reghao.tnb.content.app.vod.service.VideoPostQuery;
|
|
|
|
|
+import cn.reghao.tnb.content.app.vod.service.rcmd.RcmdData;
|
|
|
|
|
+import cn.reghao.tnb.content.app.vod.service.rcmd.RcmdProducer;
|
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.RedisKeys;
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.RedisKeys;
|
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.UserInterestBased;
|
|
import cn.reghao.tnb.content.app.vod.service.rcmd.UserInterestBased;
|
|
|
-import cn.reghao.tnb.content.app.vod.service.rcmd.task.RcmdTask;
|
|
|
|
|
import cn.reghao.tnb.content.app.util.redis.RedisKey;
|
|
import cn.reghao.tnb.content.app.util.redis.RedisKey;
|
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisHash;
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisHash;
|
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisSet;
|
|
import cn.reghao.tnb.content.app.util.redis.ds.RedisSet;
|
|
@@ -27,7 +28,6 @@ import org.springframework.stereotype.Service;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Future;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -49,10 +49,12 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
private final VideoPostQuery videoPostQuery;
|
|
private final VideoPostQuery videoPostQuery;
|
|
|
private final UserInterestBased userInterestBased;
|
|
private final UserInterestBased userInterestBased;
|
|
|
private final RedisSet redisSet;
|
|
private final RedisSet redisSet;
|
|
|
|
|
+ private final RcmdProducer rcmdProducer;
|
|
|
|
|
|
|
|
public RecommendServiceImpl(RedisSortedSet sortedSet, RedisHash<VideoCard> redisHash,
|
|
public RecommendServiceImpl(RedisSortedSet sortedSet, RedisHash<VideoCard> redisHash,
|
|
|
ContentPermission contentPermission, VideoPostMapper videoPostMapper,
|
|
ContentPermission contentPermission, VideoPostMapper videoPostMapper,
|
|
|
- VideoPostQuery videoPostQuery, UserInterestBased userInterestBased, RedisSet redisSet) {
|
|
|
|
|
|
|
+ VideoPostQuery videoPostQuery, UserInterestBased userInterestBased, RedisSet redisSet,
|
|
|
|
|
+ RcmdProducer rcmdProducer) {
|
|
|
this.sortedSet = sortedSet;
|
|
this.sortedSet = sortedSet;
|
|
|
this.redisHash = redisHash;
|
|
this.redisHash = redisHash;
|
|
|
this.contentPermission = contentPermission;
|
|
this.contentPermission = contentPermission;
|
|
@@ -60,6 +62,7 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
this.videoPostQuery = videoPostQuery;
|
|
this.videoPostQuery = videoPostQuery;
|
|
|
this.userInterestBased = userInterestBased;
|
|
this.userInterestBased = userInterestBased;
|
|
|
this.redisSet = redisSet;
|
|
this.redisSet = redisSet;
|
|
|
|
|
+ this.rcmdProducer = rcmdProducer;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<VideoCard> getRecommendVideos(long userId, String nextId) {
|
|
public List<VideoCard> getRecommendVideos(long userId, String nextId) {
|
|
@@ -77,8 +80,12 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void putRecommendVideos(long loginUser, int size) {
|
|
public void putRecommendVideos(long loginUser, int size) {
|
|
|
- RcmdTask rcmdTask = new RcmdTask(loginUser, videoPostQuery, userInterestBased, redisSet, contentPermission, size);
|
|
|
|
|
- Future<?> future = threadPool.submit(rcmdTask);
|
|
|
|
|
|
|
+ RcmdData rcmdData = new RcmdData(loginUser, pageSize*3);
|
|
|
|
|
+ try {
|
|
|
|
|
+ rcmdProducer.put(rcmdData);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<VideoCard> getRecommendVideos1(long userId, String nextId) {
|
|
public List<VideoCard> getRecommendVideos1(long userId, String nextId) {
|