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

回复评论推送

parent dba5d746
...@@ -13,6 +13,7 @@ public enum NotificationTypeEnum { ...@@ -13,6 +13,7 @@ public enum NotificationTypeEnum {
COMMENT(3,"评论"), COMMENT(3,"评论"),
FOLLOW(4,"关注"), FOLLOW(4,"关注"),
COMMENT_LIKE(5,"点赞评论"), COMMENT_LIKE(5,"点赞评论"),
COMMENT_REPLY(6,"回复评论"),
ALL(0,"全部"); ALL(0,"全部");
private Integer code; private Integer code;
......
...@@ -104,6 +104,14 @@ public class CommentManager { ...@@ -104,6 +104,14 @@ public class CommentManager {
notificationService.insert(userId, themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT, commentEntity.getCommentId(), req.getComment()); notificationService.insert(userId, themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT, commentEntity.getCommentId(), req.getComment());
notificationService.putNotifyCache(themeEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT); notificationService.putNotifyCache(themeEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT);
// 回复提醒
if (StringUtils.isNotBlank(req.getReplyId())){
notificationService.insert(userId, themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT_REPLY, commentEntity.getReplyId(), req.getComment());
notificationService.putNotifyCache(themeEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT_REPLY);
}
// 评论同步转发并消息通知 // 评论同步转发并消息通知
if (req.getSyncForward() == BizConstant.SyncForwardType.SYNC_FORWARD) { if (req.getSyncForward() == BizConstant.SyncForwardType.SYNC_FORWARD) {
String themeId = themeService.commentSyncForward(req, userId); String themeId = themeService.commentSyncForward(req, userId);
......
...@@ -96,7 +96,8 @@ public class NotificationManager { ...@@ -96,7 +96,8 @@ public class NotificationManager {
// 评论根据commentEntity找到ThemeId // 评论根据commentEntity找到ThemeId
if (NotificationTypeEnum.COMMENT.getCode().equals(themeNotifyQo.getMessageType()) || if (NotificationTypeEnum.COMMENT.getCode().equals(themeNotifyQo.getMessageType()) ||
NotificationTypeEnum.COMMENT_LIKE.getCode().equals(themeNotifyQo.getMessageType())) { NotificationTypeEnum.COMMENT_LIKE.getCode().equals(themeNotifyQo.getMessageType())||
NotificationTypeEnum.COMMENT_REPLY.getCode().equals(themeNotifyQo.getMessageType())) {
// 评论类型将commentId替换为themeId // 评论类型将commentId替换为themeId
CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getCommentId()); CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getCommentId());
if (commentEntity != null) { if (commentEntity != null) {
......
...@@ -415,6 +415,9 @@ public class ThemeManager { ...@@ -415,6 +415,9 @@ public class ThemeManager {
// 转发主题 // 转发主题
public CreateThemeResp forward(ForwardThemeReq req, String userId) { public CreateThemeResp forward(ForwardThemeReq req, String userId) {
// 校验
themeService.checkForwardSpecialPermission(req.getFormerThemeId());
ThemeEntity themeEntity = ThemeEntity.builder() ThemeEntity themeEntity = ThemeEntity.builder()
.content(JsonUtil.toJson(req.getContent())) .content(JsonUtil.toJson(req.getContent()))
.topicId(req.getTopicId()) .topicId(req.getTopicId())
......
...@@ -220,6 +220,8 @@ public class NotificationService { ...@@ -220,6 +220,8 @@ public class NotificationService {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "点赞了你的评论", 60 * 60 * 24 * 30); redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "点赞了你的评论", 60 * 60 * 24 * 30);
} else if (NotificationTypeEnum.FOLLOW.equals(type)) { } else if (NotificationTypeEnum.FOLLOW.equals(type)) {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "关注了你", 60 * 60 * 24 * 30); redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "关注了你", 60 * 60 * 24 * 30);
} else if (NotificationTypeEnum.COMMENT_REPLY.equals(type)) {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, "您有一条评论被回复啦,快去看看吧~", 60 * 60 * 24 * 30);
} else { } else {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + type.getType() + "了你的内容", 60 * 60 * 24 * 30); redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + type.getType() + "了你的内容", 60 * 60 * 24 * 30);
} }
......
...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.biz.common.enums.RelTypeEnum; import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.community.ReportStatusEnum; import com.tanpu.biz.common.enums.community.ReportStatusEnum;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.common.exception.BizException; import com.tanpu.common.exception.BizException;
import com.tanpu.common.redis.RedisHelper;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
import com.tanpu.common.uuid.UuidGenHelper; import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.beans.qo.ThemeQo; import com.tanpu.community.api.beans.qo.ThemeQo;
...@@ -18,8 +18,10 @@ import com.tanpu.community.api.enums.StatusEnum; ...@@ -18,8 +18,10 @@ import com.tanpu.community.api.enums.StatusEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum; import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TimesCountEntity; import com.tanpu.community.dao.entity.community.TimesCountEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.community.VisitLogEntity; import com.tanpu.community.dao.entity.community.VisitLogEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper; import com.tanpu.community.dao.mapper.community.ThemeMapper;
import com.tanpu.community.dao.mapper.community.TopicMapper;
import com.tanpu.community.dao.mapper.community.VisitLogMapper; import com.tanpu.community.dao.mapper.community.VisitLogMapper;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.TimeUtils; import com.tanpu.community.util.TimeUtils;
...@@ -29,7 +31,14 @@ import org.springframework.stereotype.Service; ...@@ -29,7 +31,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -42,7 +51,7 @@ public class ThemeService { ...@@ -42,7 +51,7 @@ public class ThemeService {
private UuidGenHelper uuidGenHelper; private UuidGenHelper uuidGenHelper;
@Resource @Resource
private RedisHelper redisHelper; private TopicMapper topicMapper;
@Resource @Resource
private VisitLogMapper visitLogMapper; private VisitLogMapper visitLogMapper;
@Resource @Resource
...@@ -310,6 +319,8 @@ public class ThemeService { ...@@ -310,6 +319,8 @@ public class ThemeService {
} }
public String commentSyncForward(CreateCommentReq req, String userId) { public String commentSyncForward(CreateCommentReq req, String userId) {
checkForwardSpecialPermission(req.getThemeId());
// 评论构造theme content // 评论构造theme content
List<ThemeContentReq> themeContentReqs = Arrays.asList(ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build()); List<ThemeContentReq> themeContentReqs = Arrays.asList(ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build());
ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build(); ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build();
...@@ -324,6 +335,19 @@ public class ThemeService { ...@@ -324,6 +335,19 @@ public class ThemeService {
return themeEntity.getThemeId(); return themeEntity.getThemeId();
} }
/**
* 专属话题不允许转发
*/
public void checkForwardSpecialPermission(String themeId) {
ThemeEntity themeEntity = queryByThemeId(themeId);
if (themeEntity!=null && StringUtils.isNotBlank(themeEntity.getTopicId())){
TopicEntity topicEntity = topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId, themeEntity.getTopicId()));
if (topicEntity!=null && topicEntity.getSpecialPermission()==1){
throw new BizException(ErrorCodeConstant.TOPIC_FORWARD_ABORT.getCode(),"专属话题不允许转发");
}
}
}
public void queryCommentForTopic(List<TopicFollowQo> topicQos, String userId) { public void queryCommentForTopic(List<TopicFollowQo> topicQos, String userId) {
......
...@@ -301,7 +301,8 @@ public class ConvertUtil { ...@@ -301,7 +301,8 @@ public class ConvertUtil {
} }
// 评、点赞评论 评论Id // 评、点赞评论 评论Id
if (entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode()) || if (entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode()) ||
entity.getMessageType().equals(NotificationTypeEnum.COMMENT.getCode()) entity.getMessageType().equals(NotificationTypeEnum.COMMENT.getCode()) ||
entity.getMessageType().equals(NotificationTypeEnum.COMMENT_REPLY.getCode())
) { ) {
themeNotifyQo.setCommentId(entity.getTargetId()); themeNotifyQo.setCommentId(entity.getTargetId());
} }
......
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