Commit 6d0d9613 authored by 刘基明's avatar 刘基明

删除评论时删除消息通知

parent 0cf557e3
...@@ -140,7 +140,7 @@ public class NotificationManager { ...@@ -140,7 +140,7 @@ public class NotificationManager {
redisCache.evict(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + userId); redisCache.evict(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + userId);
// 更新查询时间,用于删除评论 // 更新查询时间,用于删除评论
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_QUERY_TIME + userId, redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_QUERY_TIME + userId,
TimeUtils.format(LocalDateTime.now()),60 * 60 * 24 * 30); String.valueOf(TimeUtils.calMillisTillNow(LocalDateTime.now())),60 * 60 * 24 * 30);
return themeNotifyQos; return themeNotifyQos;
} }
......
...@@ -230,7 +230,7 @@ public class NotificationService { ...@@ -230,7 +230,7 @@ public class NotificationService {
} }
// 处理更新数量 // 处理更新数量
String lastQueryTime = redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_QUERY_TIME + notifyUserId); LocalDateTime lastQueryTime =JsonUtil.toBean(redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_QUERY_TIME + notifyUserId),LocalDateTime.class);
// 如果删除的评论时时间在红点提示时间内,则缓存数-1 // 如果删除的评论时时间在红点提示时间内,则缓存数-1
if (!TimeUtils.lessThan(lastQueryTime, commentTime)) { if (!TimeUtils.lessThan(lastQueryTime, commentTime)) {
redisCache.decr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId); redisCache.decr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId);
...@@ -245,7 +245,7 @@ public class NotificationService { ...@@ -245,7 +245,7 @@ public class NotificationService {
String cacheTime = redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId); String cacheTime = redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId);
if (StringUtils.isBlank(cacheTime) || TimeUtils.lessThan(cacheTime, updateTime)) { if (StringUtils.isBlank(cacheTime) || TimeUtils.lessThan(cacheTime, updateTime)) {
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);
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(updateTime), 60 * 60 * 24 * 30);
} }
} }
...@@ -256,7 +256,7 @@ public class NotificationService { ...@@ -256,7 +256,7 @@ public class NotificationService {
String cacheTime = redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId); String cacheTime = redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId);
if (StringUtils.isBlank(cacheTime) || TimeUtils.lessThan(cacheTime, updateTime)) { if (StringUtils.isBlank(cacheTime) || TimeUtils.lessThan(cacheTime, updateTime)) {
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);
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(updateTime), 60 * 60 * 24 * 30);
} }
} }
......
...@@ -99,10 +99,10 @@ public class TimeUtils { ...@@ -99,10 +99,10 @@ public class TimeUtils {
} }
public static boolean lessThan(String cacheTime, LocalDateTime updateTime) { public static boolean lessThan(String cacheTime, LocalDateTime updateTime) {
return calMillisTillNow(reFormat(cacheTime)) < calMillisTillNow(updateTime); return calMillisTillNow(reFormat(cacheTime)) > calMillisTillNow(updateTime);
} }
public static boolean lessThan(LocalDateTime before, LocalDateTime after) { public static boolean lessThan(LocalDateTime before, LocalDateTime after) {
return calMillisTillNow(before) < calMillisTillNow(after); return calMillisTillNow(before) > calMillisTillNow(after);
} }
} }
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