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

消息通知异常捕获

parent 5b1c203d
...@@ -66,6 +66,15 @@ public class RedisCache { ...@@ -66,6 +66,15 @@ public class RedisCache {
} }
} }
public void set(String key, String value, Integer expireSeconds) {
key = cacheName + ":" + key;
if (expireSeconds == 0) {
redisHelper.set(key, value);
} else {
redisHelper.set(key, value, Duration.ofSeconds(expireSeconds));
}
}
private void delete(String key) { private void delete(String key) {
redisHelper.delete(key); redisHelper.delete(key);
} }
......
...@@ -3,6 +3,7 @@ package com.tanpu.community.util; ...@@ -3,6 +3,7 @@ package com.tanpu.community.util;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.biz.common.enums.RelTypeEnum; import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.community.TopicStatusEnum; import com.tanpu.biz.common.enums.community.TopicStatusEnum;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.*; import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq; import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
...@@ -252,18 +253,30 @@ public class ConvertUtil { ...@@ -252,18 +253,30 @@ public class ConvertUtil {
if (entity.getMessageType().equals(NotificationTypeEnum.FORWARD.getCode())) { if (entity.getMessageType().equals(NotificationTypeEnum.FORWARD.getCode())) {
themeNotifyQo.setFormerThemeId(entity.getTargetId()); themeNotifyQo.setFormerThemeId(entity.getTargetId());
if (!StringUtils.isEmpty(entity.getContent())) { if (!StringUtils.isEmpty(entity.getContent())) {
try{
NotificationForwardDO forwardDO = JsonUtil.toBean(entity.getContent(), NotificationForwardDO.class); NotificationForwardDO forwardDO = JsonUtil.toBean(entity.getContent(), NotificationForwardDO.class);
themeNotifyQo.setContent(forwardDO.getContent()); themeNotifyQo.setContent(forwardDO.getContent());
themeNotifyQo.setTopicId(forwardDO.getTopicId()); themeNotifyQo.setTopicId(forwardDO.getTopicId());
}catch (Exception e){
throw new BizException("消息通知-转发类型-反序列化异常:"+ entity.getContent());
}
} }
} }
// 点赞需要聚合头像和人数 // 点赞需要聚合头像和人数
if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode())) { if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode())) {
if (!StringUtils.isEmpty(entity.getContent())) { if (!StringUtils.isEmpty(entity.getContent())) {
try {
NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class); NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class);
themeNotifyQo.setLikeUserCount(notificationLikeDO.getCount()); themeNotifyQo.setLikeUserCount(notificationLikeDO.getCount());
themeNotifyQo.setLikeUserIds(new ArrayList<>(notificationLikeDO.getSet())); themeNotifyQo.setLikeUserIds(new ArrayList<>(notificationLikeDO.getSet()));
}catch (Exception e){
throw new BizException("消息通知-点赞类型-反序列化异常:"+ entity.getContent());
}
} }
} }
......
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