Merge branch 'feature/REQ-1465' of axzsource.com:universal/infrastructure/backend/msg-center-plat into dev

This commit is contained in:
luofu 2023-10-18 20:06:26 +08:00
commit 78ec00bc80
3 changed files with 18 additions and 6 deletions

View File

@ -52,7 +52,12 @@ public class MessageGroupNodeStatisticDTO implements IBaseTree<MessageGroupNodeS
}
public MessageGroupNodeResponse toResponse() {
MessageGroupNodeResponse response = BeanConverter.convert(this, MessageGroupNodeResponse.class);
MessageGroupNodeResponse response = new MessageGroupNodeResponse();
response.setCategory(treeNode.getCategory());
response.setNodeCode(treeNode.getNodeCode());
response.setNodeName(treeNode.getNodeName());
response.setParentNodeCode(treeNode.getParentNodeCode());
response.setPendingCount(this.pendingCount);
List<MessageGroupNodeResponse> children = this.nodeChildren.stream()
.map(MessageGroupNodeStatisticDTO::toResponse).collect(Collectors.toList());
response.setNodeChildren(children);

View File

@ -28,19 +28,22 @@ public final class TreeHelperUtil {
AssertUtil.notNull(wrapperFunc, "wrapperFunc is null");
final Map<GroupTreeNodeDTO, T> convertMap = Maps.newHashMap();
T wrapper = wrapperFunc.apply(treeNode);
convertMap.put(treeNode, wrapper);
T root = wrapperFunc.apply(treeNode);
convertMap.put(treeNode, root);
LinkedList<GroupTreeNodeDTO> treeNodeStack = new LinkedList<>();
treeNodeStack.push(treeNode);
while (!treeNodeStack.isEmpty()) {
treeNode = treeNodeStack.pop();
List<GroupTreeNodeDTO> children = treeNode.getNodeChildren();
convertMap.get(treeNode).setNodeChildren(children.stream()
.map(e -> convertMap.put(e, wrapperFunc.apply(e)))
.collect(Collectors.toList()));
.map(e -> {
T wrapper = wrapperFunc.apply(e);
convertMap.put(e, wrapper);
return wrapper;
}).collect(Collectors.toList()));
treeNodeStack.addAll(children);
}
return wrapper;
return root;
}
public static boolean isLeafNodeCategory(MessageGroupNodeCategoryEnum category) {

View File

@ -62,6 +62,10 @@ public class GroupTreeNodeDTO implements IBaseTree<GroupTreeNodeDTO, String>, Se
@Builder.Default
private List<GroupTreeNodeDTO> nodeChildren = Collections.emptyList();
public void setNodeChildren(List<GroupTreeNodeDTO> nodeChildren) {
this.nodeChildren = Optional.ofNullable(nodeChildren).orElseGet(Collections::emptyList);
}
public MessageGroupTreeNodeResponse toMessageGroupTreeNodeResponse() {
List<MessageGroupTreeNodeResponse> children = Optional.ofNullable(nodeChildren)
.map(v -> v.stream().map(GroupTreeNodeDTO::toMessageGroupTreeNodeResponse).collect(Collectors.toList()))