Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tagManager
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanmw
tagManager
Commits
cfb8c8c0
Commit
cfb8c8c0
authored
Jan 15, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
维度树节点添加tagType和dimensionType值返回
parent
c54e3f6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
82 deletions
+94
-82
TagService.java
...ain/java/com/keymobile/tagmanager/service/TagService.java
+2
-1
JsonTreeHelper.java
...in/java/com/keymobile/tagmanager/util/JsonTreeHelper.java
+92
-81
No files found.
src/main/java/com/keymobile/tagmanager/service/TagService.java
View file @
cfb8c8c0
...
@@ -133,7 +133,8 @@ public class TagService {
...
@@ -133,7 +133,8 @@ public class TagService {
}
}
List
<
JsonNode
>
nodes
=
new
ArrayList
<>();
List
<
JsonNode
>
nodes
=
new
ArrayList
<>();
tags
.
forEach
(
p
->
{
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
);
nodes
.
add
(
node
);
});
});
//自定拼接成树结构
//自定拼接成树结构
...
...
src/main/java/com/keymobile/tagmanager/util/JsonTreeHelper.java
View file @
cfb8c8c0
package
com
.
keymobile
.
tagmanager
.
util
;
package
com
.
keymobile
.
tagmanager
.
util
;
import
java.util.List
;
import
java.util.List
;
public
class
JsonTreeHelper
{
public
class
JsonTreeHelper
{
public
static
class
JsonNode
{
public
static
class
JsonNode
{
public
String
text
;
public
String
text
;
public
JsonNode
[]
children
;
public
JsonNode
[]
children
;
public
String
nodeId
;
public
String
nodeId
;
public
String
tagType
;
public
String
tagType
;
public
String
path
;
public
String
path
;
public
String
idPath
;
public
String
idPath
;
public
String
dimensionType
;
public
JsonNode
(
String
text
)
{
this
.
text
=
text
;
public
JsonNode
(
String
text
)
{
}
this
.
text
=
text
;
}
public
JsonNode
(
String
text
,
String
nodeId
,
String
path
)
{
this
.
text
=
text
;
public
JsonNode
(
String
text
,
String
nodeId
,
String
path
)
{
this
.
path
=
path
;
this
.
text
=
text
;
this
.
nodeId
=
nodeId
;
this
.
path
=
path
;
}
this
.
nodeId
=
nodeId
;
}
public
JsonNode
(
String
text
,
String
nodeId
,
String
path
,
String
idPath
)
{
this
.
text
=
text
;
public
JsonNode
(
String
text
,
String
nodeId
,
String
path
,
String
idPath
)
{
this
.
path
=
path
;
this
.
text
=
text
;
this
.
nodeId
=
nodeId
;
this
.
path
=
path
;
this
.
idPath
=
idPath
;
this
.
nodeId
=
nodeId
;
}
this
.
idPath
=
idPath
;
}
public
void
addChild
(
JsonNode
child
)
{
if
(
children
==
null
)
{
public
JsonNode
(
String
text
,
String
nodeId
,
String
path
,
children
=
new
JsonNode
[]
{
child
};
String
idPath
,
String
tagType
,
String
dimensionType
)
{
}
else
{
this
.
text
=
text
;
JsonNode
[]
origin
=
children
;
this
.
path
=
path
;
children
=
new
JsonNode
[
origin
.
length
+
1
];
this
.
nodeId
=
nodeId
;
for
(
int
i
=
0
;
i
<
origin
.
length
;
i
++)
{
this
.
idPath
=
idPath
;
children
[
i
]
=
origin
[
i
];
this
.
tagType
=
tagType
;
}
this
.
dimensionType
=
dimensionType
;
children
[
origin
.
length
]
=
child
;
}
}
}
public
void
addChild
(
JsonNode
child
)
{
if
(
children
==
null
)
{
public
int
getChildSize
()
{
children
=
new
JsonNode
[]
{
child
};
if
(
children
==
null
)
}
else
{
return
0
;
JsonNode
[]
origin
=
children
;
else
children
=
new
JsonNode
[
origin
.
length
+
1
];
return
children
.
length
;
for
(
int
i
=
0
;
i
<
origin
.
length
;
i
++)
{
}
children
[
i
]
=
origin
[
i
];
}
}
children
[
origin
.
length
]
=
child
;
public
static
JsonNode
toJsonTree
(
List
<
JsonNode
>
jsonNodes
,
String
separator
)
{
}
JsonNode
root
=
new
JsonNode
(
"root"
);
}
for
(
JsonNode
jsonNode
:
jsonNodes
)
{
JsonNode
current
=
root
;
public
int
getChildSize
()
{
String
[]
parts
=
jsonNode
.
text
.
split
(
separator
);
if
(
children
==
null
)
for
(
String
part
:
parts
)
{
return
0
;
JsonNode
subNode
=
null
;
else
if
(
current
.
getChildSize
()
==
0
)
{
return
children
.
length
;
subNode
=
new
JsonNode
(
part
,
jsonNode
.
nodeId
,
jsonNode
.
path
,
jsonNode
.
idPath
);
}
current
.
addChild
(
subNode
);
}
}
else
{
for
(
JsonNode
node
:
current
.
children
)
{
public
static
JsonNode
toJsonTree
(
List
<
JsonNode
>
jsonNodes
,
String
separator
)
{
if
(
node
.
text
.
equals
(
part
))
JsonNode
root
=
new
JsonNode
(
"root"
);
subNode
=
node
;
for
(
JsonNode
jsonNode
:
jsonNodes
)
{
}
JsonNode
current
=
root
;
if
(
subNode
==
null
)
{
String
[]
parts
=
jsonNode
.
text
.
split
(
separator
);
subNode
=
new
JsonNode
(
part
,
jsonNode
.
nodeId
,
jsonNode
.
path
,
jsonNode
.
idPath
);
for
(
String
part
:
parts
)
{
current
.
addChild
(
subNode
);
JsonNode
subNode
=
null
;
}
if
(
current
.
getChildSize
()
==
0
)
{
}
subNode
=
new
JsonNode
(
part
,
jsonNode
.
nodeId
,
jsonNode
.
path
,
jsonNode
.
idPath
);
current
=
subNode
;
current
.
addChild
(
subNode
);
}
}
else
{
}
for
(
JsonNode
node
:
current
.
children
)
{
return
root
;
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment