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

通知分页fix

parent b95d8a7a
......@@ -31,56 +31,60 @@ import com.tanpu.community.service.NotificationService;
import com.tanpu.community.service.ThemeService;
import com.tanpu.community.service.TopicService;
import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
@Service
public class NotificationManager {
@Autowired
@Resource
private NotificationService notificationService;
@Autowired
@Resource
private TopicService topicService;
@Autowired
@Resource
private ThemeService themeService;
@Resource
private BatchFeignCallService batchFeignCallService;
@Autowired
@Resource
private FeignClientForFatools feignClientForFatools;
@Autowired
@Resource
private CommentService commentService;
@Autowired
@Resource
private FollowRelService followRelService;
@Autowired
@Resource
private CollectionService collectionService;
@Autowired
@Resource
private RedisCache redisCache;
public List<ThemeNotifyQo> queryList(NotifyQueryReq req, String userId) {
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);
UserInfoResp currentUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId),
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) {
// 用户信息
......
......@@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
@Service
......@@ -218,11 +219,11 @@ public class RankService {
.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));
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