Commit cfb8c8c0 by zhangkb

维度树节点添加tagType和dimensionType值返回

parent c54e3f6e
......@@ -133,7 +133,8 @@ public class TagService {
}
List<JsonNode> nodes = new ArrayList<>();
tags.forEach(p -> {
JsonNode node = new JsonNode(p.getPath(), p.getId(), p.getPath(), p.getIdPath());
JsonNode node = new JsonNode(p.getPath(), p.getId(),
p.getPath(), p.getIdPath(),p.getTagType(),p.getDimensionType());
nodes.add(node);
});
//自定拼接成树结构
......
package com.keymobile.tagmanager.util;
import java.util.List;
public class JsonTreeHelper {
public static class JsonNode {
public String text;
public JsonNode[] children;
public String nodeId;
public String tagType;
public String path;
public String idPath;
public JsonNode(String text) {
this.text = text;
}
public JsonNode(String text, String nodeId, String path) {
this.text = text;
this.path = path;
this.nodeId = nodeId;
}
public JsonNode(String text, String nodeId, String path, String idPath) {
this.text = text;
this.path = path;
this.nodeId = nodeId;
this.idPath = idPath;
}
public void addChild(JsonNode child) {
if (children == null) {
children = new JsonNode[] { child };
} else {
JsonNode[] origin = children;
children = new JsonNode[origin.length + 1];
for (int i = 0; i < origin.length; i++) {
children[i] = origin[i];
}
children[origin.length] = child;
}
}
public int getChildSize() {
if (children == null)
return 0;
else
return children.length;
}
}
public static JsonNode toJsonTree(List<JsonNode> jsonNodes, String separator) {
JsonNode root = new JsonNode("root");
for (JsonNode jsonNode : jsonNodes) {
JsonNode current = root;
String[] parts = jsonNode.text.split(separator);
for (String part : parts) {
JsonNode subNode = null;
if (current.getChildSize() == 0) {
subNode = new JsonNode(part, jsonNode.nodeId, jsonNode.path, jsonNode.idPath);
current.addChild(subNode);
} else {
for (JsonNode node : current.children) {
if (node.text.equals(part))
subNode = node;
}
if (subNode == null) {
subNode = new JsonNode(part, jsonNode.nodeId, jsonNode.path, jsonNode.idPath);
current.addChild(subNode);
}
}
current = subNode;
}
}
return root;
}
}
package com.keymobile.tagmanager.util;
import java.util.List;
public class JsonTreeHelper {
public static class JsonNode {
public String text;
public JsonNode[] children;
public String nodeId;
public String tagType;
public String path;
public String idPath;
public String dimensionType;
public JsonNode(String text) {
this.text = text;
}
public JsonNode(String text, String nodeId, String path) {
this.text = text;
this.path = path;
this.nodeId = nodeId;
}
public JsonNode(String text, String nodeId, String path, String idPath) {
this.text = text;
this.path = path;
this.nodeId = nodeId;
this.idPath = idPath;
}
public JsonNode(String text, String nodeId, String path,
String idPath,String tagType,String dimensionType) {
this.text = text;
this.path = path;
this.nodeId = nodeId;
this.idPath = idPath;
this.tagType = tagType;
this.dimensionType = dimensionType;
}
public void addChild(JsonNode child) {
if (children == null) {
children = new JsonNode[] { child };
} else {
JsonNode[] origin = children;
children = new JsonNode[origin.length + 1];
for (int i = 0; i < origin.length; i++) {
children[i] = origin[i];
}
children[origin.length] = child;
}
}
public int getChildSize() {
if (children == null)
return 0;
else
return children.length;
}
}
public static JsonNode toJsonTree(List<JsonNode> jsonNodes, String separator) {
JsonNode root = new JsonNode("root");
for (JsonNode jsonNode : jsonNodes) {
JsonNode current = root;
String[] parts = jsonNode.text.split(separator);
for (String part : parts) {
JsonNode subNode = null;
if (current.getChildSize() == 0) {
subNode = new JsonNode(part, jsonNode.nodeId, jsonNode.path, jsonNode.idPath);
current.addChild(subNode);
} else {
for (JsonNode node : current.children) {
if (node.text.equals(part))
subNode = node;
}
if (subNode == null) {
subNode = new JsonNode(part, jsonNode.nodeId, jsonNode.path, jsonNode.idPath);
current.addChild(subNode);
}
}
current = subNode;
}
}
return root;
}
}
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