Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -93,6 +93,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
}
|
||||
|
||||
QueryWrapper<Notification> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType())) {
|
||||
queryWrapper.eq("type", getNotificationDTO.getType());
|
||||
}
|
||||
@@ -107,7 +108,16 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
Account senderAccount = accountService.getById(notificationVO.getSenderId());
|
||||
notificationVO.setUserName(senderAccount.getUserName());
|
||||
// notificationVO.setSenderUserAvatar(StringUtils.isNullOrEmpty(senderAccount.getAvatar()) ? null : minioUtil.getPreSignedUrl(senderAccount.getAvatar(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
notificationVO.setPortfolioName(Objects.isNull(notificationVO.getPortfolioId()) ? null : portfolioService.getById(notificationVO.getPortfolioId()).getPortfolioName());
|
||||
if (Objects.isNull(notificationVO.getPortfolioId())){
|
||||
notificationVO.setPortfolioId(null);
|
||||
}else {
|
||||
Portfolio byId = portfolioService.getById(notificationVO.getPortfolioId());
|
||||
if (Objects.isNull(byId.getPortfolioName())){
|
||||
notificationVO.setPortfolioName(null);
|
||||
}else {
|
||||
notificationVO.setPortfolioName(byId.getPortfolioName());
|
||||
}
|
||||
}
|
||||
// 设置单个人 系统消息是否已读
|
||||
if (notificationVO.getType().equals("system")){
|
||||
if (unreadSysNotificationIds.contains(notificationVO.getId())){
|
||||
@@ -136,7 +146,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
save(notification);
|
||||
}
|
||||
// 推送消息
|
||||
pushMessage(notification.getType(), notification.getSenderId());
|
||||
pushMessage(notification.getType(), notification.getReceiverId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +178,6 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
ArrayList<Map<String, Object>> resp = new ArrayList<>();
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
Long count;
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (!type.equals("system")) {
|
||||
// 个人未读消息
|
||||
count = getUnreadCountByType(type, receiverId);
|
||||
@@ -179,21 +188,19 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
if (type.equals("follow")){
|
||||
HashMap<String, Object> followee = new HashMap<>();
|
||||
HashMap<String, Object> follower = new HashMap<>();
|
||||
follower.put("followerCount",portfolioService.getFollowerCount(accountId));
|
||||
followee.put("followeeCount",portfolioService.getFolloweeCount(accountId));
|
||||
follower.put("followerCount",portfolioService.getFollowerCount(receiverId));
|
||||
followee.put("followeeCount",portfolioService.getFolloweeCount(receiverId));
|
||||
resp.add(followee);
|
||||
resp.add(follower);
|
||||
}
|
||||
|
||||
data.put(type, count);
|
||||
if (count != 0){
|
||||
resp.add(data);
|
||||
}
|
||||
resp.add(data);
|
||||
String jsonString = JSON.toJSONString(resp);
|
||||
log.info("消息推送 : {}", jsonString);
|
||||
// log.info("消息推送 : {}", jsonString);
|
||||
|
||||
try {
|
||||
notificationConnection.sendMsg(jsonString);
|
||||
notificationConnection.sendMsg(jsonString, receiverId);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -1031,15 +1031,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
// 按 size 倒序排序
|
||||
portfolioSizes.sort((e1, e2) -> e2.getValue().compareTo(e1.getValue()));
|
||||
// 获取 size 最大的前三个
|
||||
List<Long> top3PortfolioIds = portfolioSizes.stream()
|
||||
// 去掉前缀,获取 portfolioId
|
||||
// 输出 top3PortfolioIds
|
||||
// top3PortfolioIds.forEach(System.out::println);
|
||||
return portfolioSizes.stream()
|
||||
.limit(3)
|
||||
.map(Map.Entry::getKey)
|
||||
.map(key -> key.replace(prefix, "")) // 去掉前缀,获取 portfolioId
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
// 输出 top3PortfolioIds
|
||||
top3PortfolioIds.forEach(System.out::println);
|
||||
return top3PortfolioIds;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1067,14 +1067,13 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
// Step 3: Find the top 3 portfolio IDs with the largest values
|
||||
if (!portfolioViews.isEmpty()){
|
||||
List<Long> top3PortfolioIds = portfolioViews.entrySet().stream()
|
||||
|
||||
// System.out.println("Top 3 Portfolio IDs after exclusion: " + top3PortfolioIds);
|
||||
return portfolioViews.entrySet().stream()
|
||||
.sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
|
||||
.limit(3)
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
System.out.println("Top 3 Portfolio IDs after exclusion: " + top3PortfolioIds);
|
||||
return top3PortfolioIds;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1098,6 +1097,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
userFollowMapper.insert(newFollower);
|
||||
// 4、推送消息
|
||||
messageCenterService.prePushMessage(new Notification("follow", accountId, followeeId));
|
||||
messageCenterService.pushMessage("follow", accountId);
|
||||
}
|
||||
|
||||
// 取消关注
|
||||
@@ -1117,6 +1117,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
}
|
||||
// 3、更新关注人数
|
||||
messageCenterService.pushMessage("follow", accountId);
|
||||
messageCenterService.pushMessage("follow", followeeId);
|
||||
}
|
||||
|
||||
public Long getFolloweeCount(Long accountId) {
|
||||
|
||||
Reference in New Issue
Block a user