Commit aafc72e2 authored by 刘基明's avatar 刘基明

通知分页fix

parent b95d8a7a
...@@ -31,56 +31,60 @@ import com.tanpu.community.service.NotificationService; ...@@ -31,56 +31,60 @@ import com.tanpu.community.service.NotificationService;
import com.tanpu.community.service.ThemeService; import com.tanpu.community.service.ThemeService;
import com.tanpu.community.service.TopicService; import com.tanpu.community.service.TopicService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO; import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
@Service @Service
public class NotificationManager { public class NotificationManager {
@Autowired @Resource
private NotificationService notificationService; private NotificationService notificationService;
@Autowired @Resource
private TopicService topicService; private TopicService topicService;
@Autowired @Resource
private ThemeService themeService; private ThemeService themeService;
@Resource @Resource
private BatchFeignCallService batchFeignCallService; private BatchFeignCallService batchFeignCallService;
@Autowired @Resource
private FeignClientForFatools feignClientForFatools; private FeignClientForFatools feignClientForFatools;
@Autowired @Resource
private CommentService commentService; private CommentService commentService;
@Autowired @Resource
private FollowRelService followRelService; private FollowRelService followRelService;
@Autowired @Resource
private CollectionService collectionService; private CollectionService collectionService;
@Autowired @Resource
private RedisCache redisCache; private RedisCache redisCache;
public List<ThemeNotifyQo> queryList(NotifyQueryReq req, String userId) { public List<ThemeNotifyQo> queryList(NotifyQueryReq req, String userId) {
List<NotificationEntity> query = notificationService.query(userId, req.getType(), req.getLastId(), req.getPageSize()); List<NotificationEntity> query = notificationService.query(userId, req.getType(), req.getLastId(), req.getPageSize());
if (CollectionUtils.isEmpty(query)){
return Collections.emptyList();
}
List<ThemeNotifyQo> themeNotifyQos = ConvertUtil.notificationEntitiy2ThemeQos(query); List<ThemeNotifyQo> themeNotifyQos = ConvertUtil.notificationEntitiy2ThemeQos(query);
UserInfoResp currentUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId), UserInfoResp currentUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId),
60, () -> this.getUserInfo(userId), UserInfoResp.class); 60, () -> this.getUserInfo(userId), UserInfoResp.class);
Set<String> followUserIds = followRelService.queryIdolsByFansId(userId).stream().collect(Collectors.toSet()); Set<String> followUserIds = new HashSet<>(followRelService.queryIdolsByFansId(userId));
for (ThemeNotifyQo themeNotifyQo : themeNotifyQos) { for (ThemeNotifyQo themeNotifyQo : themeNotifyQos) {
// 用户信息 // 用户信息
......
...@@ -25,6 +25,7 @@ import java.util.Arrays; ...@@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -218,11 +219,11 @@ public class RankService { ...@@ -218,11 +219,11 @@ public class RankService {
.collect(Collectors.toList()); .collect(Collectors.toList());
//落库 //落库
if (redisCache.setIfAbsent("logTopicRank", "1", 60)) { int i = new Random().nextInt(3);
if (i==1 && redisCache.setIfAbsent("logTopicRank", "1", 60)) {
rankLogService.logTopicRank(rankList, start, TimeUtils.calMillisTillNow(start)); rankLogService.logTopicRank(rankList, start, TimeUtils.calMillisTillNow(start));
redisCache.evict("logTopicRank"); redisCache.evict("logTopicRank");
} }
return;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment