|
|
@@ -1,11 +1,11 @@
|
|
|
package cn.reghao.tnb.content.app.vod.service.impl;
|
|
|
|
|
|
-import cn.reghao.jutil.jdk.db.PageBound;
|
|
|
import cn.reghao.jutil.web.WebResult;
|
|
|
import cn.reghao.jutil.jdk.thread.ThreadPoolWrapper;
|
|
|
import cn.reghao.tnb.common.db.PageScroll;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoCard;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoPostCard;
|
|
|
+import cn.reghao.tnb.content.app.util.redis.ds.RedisList;
|
|
|
import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
|
|
|
import cn.reghao.tnb.content.api.dto.BannerVideo;
|
|
|
@@ -49,12 +49,13 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
private final VideoPostQuery videoPostQuery;
|
|
|
private final UserInterestBased userInterestBased;
|
|
|
private final RedisSet redisSet;
|
|
|
+ private final RedisList redisList;
|
|
|
private final RcmdProducer rcmdProducer;
|
|
|
|
|
|
public RecommendServiceImpl(RedisSortedSet sortedSet, RedisHash<VideoCard> redisHash,
|
|
|
ContentPermission contentPermission, VideoPostMapper videoPostMapper,
|
|
|
- VideoPostQuery videoPostQuery, UserInterestBased userInterestBased, RedisSet redisSet,
|
|
|
- RcmdProducer rcmdProducer) {
|
|
|
+ VideoPostQuery videoPostQuery, UserInterestBased userInterestBased,
|
|
|
+ RedisSet redisSet, RedisList redisList, RcmdProducer rcmdProducer) {
|
|
|
this.sortedSet = sortedSet;
|
|
|
this.redisHash = redisHash;
|
|
|
this.contentPermission = contentPermission;
|
|
|
@@ -62,6 +63,7 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
this.videoPostQuery = videoPostQuery;
|
|
|
this.userInterestBased = userInterestBased;
|
|
|
this.redisSet = redisSet;
|
|
|
+ this.redisList = redisList;
|
|
|
this.rcmdProducer = rcmdProducer;
|
|
|
}
|
|
|
|
|
|
@@ -86,7 +88,7 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- RcmdData rcmdData = new RcmdData(loginUser, pageSize*3);
|
|
|
+ RcmdData rcmdData = new RcmdData(loginUser, size);
|
|
|
try {
|
|
|
rcmdProducer.put(rcmdData);
|
|
|
} catch (InterruptedException e) {
|
|
|
@@ -94,20 +96,16 @@ public class RecommendServiceImpl implements RecommendService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public List<VideoCard> getRecommendVideos1(long userId, String nextId) {
|
|
|
- Set<String> videoIds = userInterestBased.getUserInterestItems(userId);
|
|
|
- List<VideoCard> videoCards = videoPostQuery.getVideoCards(new ArrayList<>(videoIds));
|
|
|
-
|
|
|
- int pageNumber = Integer.parseInt(nextId)+1;
|
|
|
- if (pageNumber > 100) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void resetUserRcmd(long userId) {
|
|
|
+ String itemsKey = RedisKeys.getUserItemKey(userId);
|
|
|
+ redisSet.spop(itemsKey);
|
|
|
+ }
|
|
|
|
|
|
- long total = sortedSet.count(RedisKey.recommendZsetKey());
|
|
|
- PageBound pageBound = PageBound.get(pageNumber, pageSize, (int) total);
|
|
|
- Set<String> set = sortedSet.get(RedisKey.recommendZsetKey(), pageBound.getStart(), pageBound.getEnd()-1);
|
|
|
- List<VideoCard> list = redisHash.multiGet(RedisKey.recommendHashKey(), set);
|
|
|
- return list;
|
|
|
+ @Override
|
|
|
+ public void dislikeVideo(long userId, String videoId) {
|
|
|
+ String dislikeKey = RedisKeys.getUserDislikeKey(userId);
|
|
|
+ redisList.add(dislikeKey, videoId);
|
|
|
}
|
|
|
|
|
|
public String getSimilarVideos(String videoId) {
|