Commit 0936157e authored by 刘基明's avatar 刘基明

同步评论转发,评论点赞消息通知

parent 0c953467
...@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service; ...@@ -29,6 +29,7 @@ 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.time.LocalDateTime;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -71,6 +72,7 @@ public class CommentManager { ...@@ -71,6 +72,7 @@ public class CommentManager {
throw new IllegalArgumentException("评论内容不能超过500字"); throw new IllegalArgumentException("评论内容不能超过500字");
} }
LocalDateTime now = LocalDateTime.now();
CommentEntity commentEntity = CommentEntity.builder() CommentEntity commentEntity = CommentEntity.builder()
.themeId(req.getThemeId()) .themeId(req.getThemeId())
.parentId(req.getParentId()) .parentId(req.getParentId())
...@@ -78,6 +80,8 @@ public class CommentManager { ...@@ -78,6 +80,8 @@ public class CommentManager {
.authorId(userId) .authorId(userId)
.content(req.getComment()) .content(req.getComment())
.commentType(CommentTypeEnum.THEME.getCode()) .commentType(CommentTypeEnum.THEME.getCode())
.createTime(now)
.updateTime(now)
.build(); .build();
commentService.insertComment(commentEntity); commentService.insertComment(commentEntity);
...@@ -155,7 +159,13 @@ public class CommentManager { ...@@ -155,7 +159,13 @@ public class CommentManager {
//点赞评论/取消点赞 //点赞评论/取消点赞
public void likeComment(LikeCommentReq req, String userId) { public void likeComment(LikeCommentReq req, String userId) {
if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) { if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) {
collectionService.saveOrUpdate(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT); boolean b = collectionService.saveOrUpdate(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
if (b){
CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId());
ThemeEntity themeEntity = themeService.queryByThemeId(commentEntity.getThemeId());
notificationService.insert(userId, commentEntity.getAuthorId(), NotificationTypeEnum.COMMENT_LIKE, themeEntity.getThemeId(), req.getCommentId());
notificationService.putNotifyCache(commentEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT_LIKE);
}
} else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) { } else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
collectionService.delete(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT); collectionService.delete(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
......
...@@ -3,15 +3,11 @@ package com.tanpu.community.service; ...@@ -3,15 +3,11 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.biz.common.enums.community.CollectionTypeEnum; import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.NotificationTypeEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity; import com.tanpu.community.dao.entity.community.CollectionEntity;
import com.tanpu.community.dao.entity.community.CommentEntity;
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.mapper.community.CollectionMapper; import com.tanpu.community.dao.mapper.community.CollectionMapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -30,14 +26,6 @@ public class CollectionService { ...@@ -30,14 +26,6 @@ public class CollectionService {
@Resource @Resource
private CollectionMapper collectionMapper; private CollectionMapper collectionMapper;
@Autowired
private NotificationService notificationService;
@Autowired
private ThemeService themeService;
@Autowired
private CommentService commentService;
// 若不存在则新增,若存在则修改deleteTag // 若不存在则新增,若存在则修改deleteTag
...@@ -64,12 +52,6 @@ public class CollectionService { ...@@ -64,12 +52,6 @@ public class CollectionService {
collectionMapper.insert(entity); collectionMapper.insert(entity);
CommentEntity commentEntity = commentService.queryByCommentId(targetId);
ThemeEntity themeEntity = themeService.queryByThemeId(commentEntity.getThemeId());
notificationService.insert(userId, themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT_LIKE
, themeEntity.getThemeId(), targetId);
notificationService.putNotifyCache(themeEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT_LIKE);
return true; return true;
} }
} }
......
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