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
e444ff4a
Commit
e444ff4a
authored
Mar 05, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标签数每个节点添加子节点数量标识
parent
4bcb8658
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
TagService.java
...ain/java/com/keymobile/tagmanager/service/TagService.java
+10
-4
JsonTreeHelper.java
...in/java/com/keymobile/tagmanager/util/JsonTreeHelper.java
+12
-0
No files found.
src/main/java/com/keymobile/tagmanager/service/TagService.java
View file @
e444ff4a
...
@@ -144,7 +144,8 @@ public class TagService {
...
@@ -144,7 +144,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
(),
JsonNode
node
=
new
JsonNode
(
p
.
getPath
(),
p
.
getId
(),
p
.
getPath
(),
p
.
getIdPath
(),
p
.
getTagType
(),
p
.
getDimensionType
());
p
.
getPath
(),
p
.
getIdPath
(),
p
.
getTagType
(),
p
.
getDimensionType
(),
this
.
getChildCountByTagId
(
p
.
getId
()));
nodes
.
add
(
node
);
nodes
.
add
(
node
);
});
});
//自定拼接成树结构
//自定拼接成树结构
...
@@ -182,7 +183,7 @@ public class TagService {
...
@@ -182,7 +183,7 @@ 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
());
,
p
.
getTagType
(),
p
.
getDimensionType
()
,
this
.
getChildCountByTagId
(
p
.
getId
())
);
nodes
.
add
(
node
);
nodes
.
add
(
node
);
});
});
JsonNode
root
=
JsonTreeHelper
.
toJsonTree
(
nodes
,
Constants
.
TAG_PATH_SEPARATOR
);
JsonNode
root
=
JsonTreeHelper
.
toJsonTree
(
nodes
,
Constants
.
TAG_PATH_SEPARATOR
);
...
@@ -300,7 +301,7 @@ public class TagService {
...
@@ -300,7 +301,7 @@ 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
());
,
p
.
getTagType
(),
p
.
getDimensionType
()
,
this
.
getChildCountByTagId
(
p
.
getId
())
);
nodes
.
add
(
node
);
nodes
.
add
(
node
);
});
});
JsonNode
root
=
JsonTreeHelper
.
toJsonTree
(
nodes
,
Constants
.
TAG_PATH_SEPARATOR
);
JsonNode
root
=
JsonTreeHelper
.
toJsonTree
(
nodes
,
Constants
.
TAG_PATH_SEPARATOR
);
...
@@ -881,7 +882,12 @@ public class TagService {
...
@@ -881,7 +882,12 @@ public class TagService {
return
false
;
return
false
;
}
}
//author:zhangkb time:2020-3-5 desc:根据标签id获取标签子节点数量
public
int
getChildCountByTagId
(
String
tagId
)
{
List
<
Tag
>
dirs
=
mongoOperations
.
find
(
new
Query
().
addCriteria
(
Criteria
.
where
(
"idPath"
)
.
regex
(
"^"
+
tagId
+
Constants
.
TAG_PATH_SEPARATOR
)),
Tag
.
class
);
return
dirs
.
size
();
}
...
...
src/main/java/com/keymobile/tagmanager/util/JsonTreeHelper.java
View file @
e444ff4a
...
@@ -13,6 +13,7 @@ public class JsonTreeHelper {
...
@@ -13,6 +13,7 @@ public class JsonTreeHelper {
public
String
path
;
public
String
path
;
public
String
idPath
;
public
String
idPath
;
public
String
dimensionType
;
public
String
dimensionType
;
public
int
childCount
;
//author:zhangkb time:2020-3-5 desc:添加标签子标签数量字段
public
JsonNode
(
String
text
)
{
public
JsonNode
(
String
text
)
{
this
.
text
=
text
;
this
.
text
=
text
;
...
@@ -41,6 +42,17 @@ public class JsonTreeHelper {
...
@@ -41,6 +42,17 @@ public class JsonTreeHelper {
this
.
dimensionType
=
dimensionType
;
this
.
dimensionType
=
dimensionType
;
}
}
public
JsonNode
(
String
text
,
String
nodeId
,
String
path
,
String
idPath
,
String
tagType
,
String
dimensionType
,
int
childCount
)
{
this
.
text
=
text
;
this
.
path
=
path
;
this
.
nodeId
=
nodeId
;
this
.
idPath
=
idPath
;
this
.
tagType
=
tagType
;
this
.
dimensionType
=
dimensionType
;
this
.
childCount
=
childCount
;
}
public
void
addChild
(
JsonNode
child
)
{
public
void
addChild
(
JsonNode
child
)
{
if
(
children
==
null
)
{
if
(
children
==
null
)
{
children
=
new
JsonNode
[]
{
child
};
children
=
new
JsonNode
[]
{
child
};
...
...
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