Commit 51b6c63c authored by 刘基明's avatar 刘基明

点赞评论消息通知

parent 250e1051
package com.tanpu.community.api.beans.req.notification; package com.tanpu.community.api.beans.req.notification;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -14,7 +13,7 @@ import lombok.NoArgsConstructor; ...@@ -14,7 +13,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor @AllArgsConstructor
public class NotifyQueryReq { public class NotifyQueryReq {
@ApiModelProperty(value = "1:转发 2:点赞 3:评论 4:关注 0:全部") @ApiModelProperty(value = "1:转发 2:点赞(主题点赞+评论点赞) 3:评论 4:关注 0:全部")
private Integer type; private Integer type;
@ApiModelProperty(value = "最后一条通知") @ApiModelProperty(value = "最后一条通知")
......
...@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Service @Service
...@@ -164,8 +165,12 @@ public class NotificationService { ...@@ -164,8 +165,12 @@ public class NotificationService {
.eq(NotificationEntity::getNotificationId, lastId)); .eq(NotificationEntity::getNotificationId, lastId));
queryWrapper.lt(NotificationEntity::getUpdateTime, lastOne.getCreateTime()); queryWrapper.lt(NotificationEntity::getUpdateTime, lastOne.getCreateTime());
} }
if (!NotificationTypeEnum.ALL.getCode().equals(type)) { if (!NotificationTypeEnum.ALL.getCode().equals(type) && !NotificationTypeEnum.LIKE.getCode().equals(type)) {
queryWrapper.eq(NotificationEntity::getMessageType, type); queryWrapper.eq(NotificationEntity::getMessageType, type);
} else if (NotificationTypeEnum.LIKE.getCode().equals(type)) {
// 类型2点赞返回评论点赞和主题点赞
queryWrapper.in(NotificationEntity::getMessageType,
Arrays.asList(NotificationTypeEnum.LIKE.getCode(), NotificationTypeEnum.COMMENT_LIKE.getCode()));
} }
return notificationMapper.selectList(queryWrapper); return notificationMapper.selectList(queryWrapper);
} }
...@@ -213,7 +218,7 @@ public class NotificationService { ...@@ -213,7 +218,7 @@ public class NotificationService {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId, TimeUtils.format(LocalDateTime.now()), 60 * 60 * 24 * 30); redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId, TimeUtils.format(LocalDateTime.now()), 60 * 60 * 24 * 30);
if (NotificationTypeEnum.COMMENT_LIKE.equals(type)) { if (NotificationTypeEnum.COMMENT_LIKE.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.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 { } 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);
...@@ -221,7 +226,6 @@ public class NotificationService { ...@@ -221,7 +226,6 @@ public class NotificationService {
} }
// 删除评论及缓存 // 删除评论及缓存
public void deleteCommentNotify(String notifyUserId, String operatorId, String commentId, LocalDateTime commentTime) { public void deleteCommentNotify(String notifyUserId, String operatorId, String commentId, LocalDateTime commentTime) {
// 物理删除 // 物理删除
......
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