Commit 4204b3c8 authored by 刘基明's avatar 刘基明

消息通知 fix

parent a095d0f4
...@@ -92,7 +92,7 @@ public class CommentManager { ...@@ -92,7 +92,7 @@ public class CommentManager {
// 消息通知 // 消息通知
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId()); ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
notificationService.insert(userId,themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT,req.getThemeId(),req.getComment()); notificationService.insert(userId,themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT,req.getThemeId(),req.getComment());
messageNotify(themeEntity.getAuthorId(),userId,NotificationTypeEnum.COMMENT); notificationService.putNotifyCache(themeEntity.getAuthorId(),userId,NotificationTypeEnum.COMMENT);
return commentQo; return commentQo;
} }
...@@ -173,11 +173,4 @@ public class CommentManager { ...@@ -173,11 +173,4 @@ public class CommentManager {
commentService.delete(commentId,userId); commentService.delete(commentId,userId);
} }
// 消息通知队列缓存
private void messageNotify(String notifyUserId,String operatorId, NotificationTypeEnum type){
UserInfoResp userInfo = getUserInfo(operatorId);
redisCache.incr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName()+type.getType()+"了你的内容", 60 * 60 * 24 * 30);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId, TimeUtils.format(LocalDateTime.now()), 60 * 60 * 24 * 30);
}
} }
...@@ -17,8 +17,12 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief; ...@@ -17,8 +17,12 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg; import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp; import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO; import com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO;
import com.tanpu.community.api.constants.RedisKeyConstant; import com.tanpu.community.api.enums.FundCompanyTypeEnum;
import com.tanpu.community.api.enums.*; import com.tanpu.community.api.enums.NotificationTypeEnum;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.api.enums.PersonalCenterTypeEnum;
import com.tanpu.community.api.enums.QueryFollowTypeEnum;
import com.tanpu.community.api.enums.ShowFollowStatusEnum;
import com.tanpu.community.cache.RedisCache; import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.FollowRelEntity; import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.mapper.community.FollowRelMapper; import com.tanpu.community.dao.mapper.community.FollowRelMapper;
...@@ -31,7 +35,6 @@ import com.tanpu.community.service.FollowRelService; ...@@ -31,7 +35,6 @@ import com.tanpu.community.service.FollowRelService;
import com.tanpu.community.service.NotificationService; import com.tanpu.community.service.NotificationService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.PageUtils; import com.tanpu.community.util.PageUtils;
import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -39,8 +42,14 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -39,8 +42,14 @@ 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.time.LocalDateTime; import java.util.ArrayList;
import java.util.*; import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -238,21 +247,13 @@ public class HomePageManager { ...@@ -238,21 +247,13 @@ public class HomePageManager {
// 第一次关注才有消息通知 // 第一次关注才有消息通知
if (followRelService.addFollowRel(req.getFollowUserId(), followerId)) { if (followRelService.addFollowRel(req.getFollowUserId(), followerId)) {
notificationService.insert(followerId, req.getFollowUserId(), NotificationTypeEnum.FOLLOW, req.getFollowUserId(), null); notificationService.insert(followerId, req.getFollowUserId(), NotificationTypeEnum.FOLLOW, req.getFollowUserId(), null);
messageFollowNotify(req.getFollowUserId(), followerId); notificationService.putNotifyCacheFollow(req.getFollowUserId(), followerId);
} }
} else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) { } else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
followRelService.deleteFollowRel(req.getFollowUserId(), followerId); followRelService.deleteFollowRel(req.getFollowUserId(), followerId);
} }
} }
// 消息通知队列缓存-关注
private void messageFollowNotify(String notifyUserId, String operatorId) {
UserInfoResp userInfo = getUserInfo(operatorId);
redisCache.incr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "关注了你", 60 * 60 * 24 * 30);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId, TimeUtils.format(LocalDateTime.now()), 60 * 60 * 24 * 30);
}
private UserInfoResp getUserInfo(String authorId) { private UserInfoResp getUserInfo(String authorId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId); CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
......
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