Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-tool
Project
Project
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
tool
amos-tool
Commits
ac9ce01b
Commit
ac9ce01b
authored
Dec 08, 2023
by
Gwofoo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现:组件库一二三级的合并
parent
b9495f84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
32 deletions
+18
-32
ToolLibraryService.java
...eejoin/amos/api/tool/face/service/ToolLibraryService.java
+18
-32
No files found.
src/main/java/com/yeejoin/amos/api/tool/face/service/ToolLibraryService.java
View file @
ac9ce01b
...
...
@@ -2,7 +2,6 @@ package com.yeejoin.amos.api.tool.face.service;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryDetailModel
;
import
com.yeejoin.amos.api.tool.face.model.TemplateCategoryTreeModel
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryModel
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryTreeModel
;
import
com.yeejoin.amos.api.tool.face.orm.dao.ToolLibraryMapper
;
...
...
@@ -50,7 +49,15 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
model
.
setParentId
(
Long
.
valueOf
(
map
.
get
(
"parent"
).
toString
()));
displayLists
.
add
(
model
);
}
return
getChildren
(
displayLists
);
//新建一个用于接收数据的list
List
<
ToolLibraryTreeModel
>
resultList
=
new
ArrayList
<>();
for
(
ToolLibraryTreeModel
result
:
displayLists
)
{
if
(
result
.
getParentId
()
==
0
)
{
//调用方法给子类添加数据
resultList
.
add
(
getMenuTree
(
result
,
displayLists
));
}
}
return
resultList
;
}
public
Page
<
ToolLibraryDetailModel
>
queryForComponentListDetails
(
Page
<
ToolLibraryDetailModel
>
page
,
String
sequenceNbr
)
...
...
@@ -110,39 +117,18 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
return
page
;
}
p
ublic
List
<
ToolLibraryTreeModel
>
getChildren
(
List
<
ToolLibraryTreeModel
>
nodes
)
{
List
<
ToolLibraryTreeModel
>
resultList
=
new
ArrayList
<>();
for
(
ToolLibraryTreeModel
model1
:
nodes
)
{
for
(
ToolLibraryTreeModel
model2
:
nodes
)
{
if
(
model2
.
getParentId
().
equals
(
model1
.
getId
()))
{
result
List
.
add
(
model2
);
p
rivate
ToolLibraryTreeModel
getMenuTree
(
ToolLibraryTreeModel
result
,
List
<
ToolLibraryTreeModel
>
list
)
{
for
(
ToolLibraryTreeModel
treeModel
:
list
)
{
//如果父类主键等于传过来实体类的ID
if
(
treeModel
.
getParentId
().
equals
(
result
.
getId
())
)
{
if
(
result
.
getChildren
()
==
null
)
{
result
.
setChildren
(
new
ArrayList
<>()
);
}
// 递归调用
result
.
getChildren
().
add
(
getMenuTree
(
treeModel
,
list
));
}
model1
.
setChildren
(
resultList
);
resultList
=
new
ArrayList
<>();
}
nodes
.
removeIf
(
model
->
model
.
getChildren
()
==
null
||
model
.
getChildren
().
size
()
==
0
);
return
nodes
;
return
result
;
}
// /**
// * 获得模板分类子节点(递归)
// */
// public List<ToolLibraryTreeModel> getChildren(List<ToolLibraryTreeModel> nodes, String parent, Long id) {
// List<ToolLibraryTreeModel> treeModels = new ArrayList<>();
// for (ToolLibraryTreeModel node : nodes) {
// if (node.getParentId() == 0L && parent.equals("")) {
// node.setChildren(getChildren(nodes, node.getDesignerType(), node.getId()));
// treeModels.add(node);
// } else {
// if (parent.equals(node.getDesignerType()) && node.getParentId() != 0L) {
// node.setParentId(id);
// treeModels.add(node);
// }
// }
// }
// return treeModels;
// }
}
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