消息切换 BeanUtil 转换.

pull/84/head
chen.ma 3 years ago
parent 31cba738ed
commit 2340f7bc8b

@ -3,7 +3,6 @@ package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.monitor.AbstractMessage; import cn.hippo4j.common.monitor.AbstractMessage;
import cn.hippo4j.common.monitor.Message; import cn.hippo4j.common.monitor.Message;
import cn.hippo4j.common.monitor.MessageWrapper; import cn.hippo4j.common.monitor.MessageWrapper;
import cn.hutool.core.bean.BeanUtil;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import java.util.ArrayList; import java.util.ArrayList;
@ -31,7 +30,11 @@ public class MessageConvert {
List<Map<String, Object>> messageMapList = new ArrayList(); List<Map<String, Object>> messageMapList = new ArrayList();
List<Message> messages = message.getMessages(); List<Message> messages = message.getMessages();
messages.forEach(each -> messageMapList.add(BeanUtil.beanToMap(each))); messages.forEach(each -> {
String eachVal = JSONUtil.toJSONString(each);
Map mapObj = JSONUtil.parseObject(eachVal, Map.class);
messageMapList.add(mapObj);
});
wrapper.setContentParams(messageMapList); wrapper.setContentParams(messageMapList);
return wrapper; return wrapper;
@ -49,7 +52,11 @@ public class MessageConvert {
List<Map<String, Object>> contentParams = messageWrapper.getContentParams(); List<Map<String, Object>> contentParams = messageWrapper.getContentParams();
List<Message> messages = new ArrayList(); List<Message> messages = new ArrayList();
contentParams.forEach(each -> messages.add(BeanUtil.toBean(each, messageWrapper.getResponseClass()))); contentParams.forEach(each -> {
String eachVal = JSONUtil.toJSONString(each);
Message messageObj = JSONUtil.parseObject(eachVal, messageWrapper.getResponseClass());
messages.add(messageObj);
});
message.setMessages(messages); message.setMessages(messages);
message.setMessageType(messageWrapper.getMessageType()); message.setMessageType(messageWrapper.getMessageType());

Loading…
Cancel
Save