websocket获取关注数与粉丝数
This commit is contained in:
@@ -18,6 +18,8 @@ public interface MessageCenterService extends IService<Notification> {
|
|||||||
|
|
||||||
void prePushMessage(Notification notification);
|
void prePushMessage(Notification notification);
|
||||||
|
|
||||||
|
void pushMessage(String type, Long receiverId);
|
||||||
|
|
||||||
void cancelPushMessage(String type, Long senderId, Long receiverId, Long portfolioId, Long commentId);
|
void cancelPushMessage(String type, Long senderId, Long receiverId, Long portfolioId, Long commentId);
|
||||||
|
|
||||||
Boolean setReadStatus(List<Long> notificationIdList, String type);
|
Boolean setReadStatus(List<Long> notificationIdList, String type);
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
ArrayList<Map<String, Object>> resp = new ArrayList<>();
|
ArrayList<Map<String, Object>> resp = new ArrayList<>();
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
Long count;
|
Long count;
|
||||||
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
if (!type.equals("system")) {
|
if (!type.equals("system")) {
|
||||||
// 个人未读消息
|
// 个人未读消息
|
||||||
count = getUnreadCountByType(type, receiverId);
|
count = getUnreadCountByType(type, receiverId);
|
||||||
@@ -175,9 +176,19 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
// 系统未读消息
|
// 系统未读消息
|
||||||
count = getUnreadSystemNotification();
|
count = getUnreadSystemNotification();
|
||||||
}
|
}
|
||||||
|
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));
|
||||||
|
resp.add(followee);
|
||||||
|
resp.add(follower);
|
||||||
|
}
|
||||||
|
|
||||||
data.put(type, count);
|
data.put(type, count);
|
||||||
resp.add(data);
|
if (count != 0){
|
||||||
|
resp.add(data);
|
||||||
|
}
|
||||||
String jsonString = JSON.toJSONString(resp);
|
String jsonString = JSON.toJSONString(resp);
|
||||||
log.info("消息推送 : {}", jsonString);
|
log.info("消息推送 : {}", jsonString);
|
||||||
|
|
||||||
|
|||||||
@@ -1081,6 +1081,8 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
} else {
|
} else {
|
||||||
throw new BusinessException("you.have.not.followed.the.current.user", 1);
|
throw new BusinessException("you.have.not.followed.the.current.user", 1);
|
||||||
}
|
}
|
||||||
|
// 3、更新关注人数
|
||||||
|
messageCenterService.pushMessage("follow", accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getFolloweeCount(Long accountId) {
|
public Long getFolloweeCount(Long accountId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user