Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
435df318
Commit
435df318
authored
Jul 07, 2023
by
Zheng Jie
Browse files
Merge branch 'master' into deploy
parents
e67300e9
00f7f250
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java
View file @
435df318
...
...
@@ -67,20 +67,23 @@ public class DeptController {
@ApiOperation
(
"查询部门:根据ID获取同级与上级数据"
)
@PostMapping
(
"/superior"
)
@PreAuthorize
(
"@el.check('user:list','dept:list')"
)
public
ResponseEntity
<
Object
>
getDeptSuperior
(
@RequestBody
List
<
Long
>
ids
)
{
public
ResponseEntity
<
Object
>
getDeptSuperior
(
@RequestBody
List
<
Long
>
ids
,
@RequestParam
(
defaultValue
=
"false"
)
Boolean
exclude
)
{
Set
<
DeptDto
>
deptSet
=
new
LinkedHashSet
<>();
for
(
Long
id
:
ids
)
{
DeptDto
deptDto
=
deptService
.
findById
(
id
);
List
<
DeptDto
>
depts
=
deptService
.
getSuperior
(
deptDto
,
new
ArrayList
<>());
for
(
DeptDto
dept
:
depts
)
{
if
(
dept
.
getId
().
equals
(
deptDto
.
getPid
()))
{
dept
.
setSubCount
(
dept
.
getSubCount
()
-
1
);
if
(
exclude
){
for
(
DeptDto
dept
:
depts
)
{
if
(
dept
.
getId
().
equals
(
deptDto
.
getPid
()))
{
dept
.
setSubCount
(
dept
.
getSubCount
()
-
1
);
}
}
// 编辑部门时不显示自己以及自己下级的数据,避免出现PID数据环形问题
depts
=
depts
.
stream
().
filter
(
i
->
!
ids
.
contains
(
i
.
getId
())).
collect
(
Collectors
.
toList
());
}
deptSet
.
addAll
(
depts
);
}
// 编辑部门时不显示自己以及自己下级的数据,避免出现PID数据环形问题
deptSet
=
deptSet
.
stream
().
filter
(
i
->
!
ids
.
contains
(
i
.
getId
())).
collect
(
Collectors
.
toSet
());
return
new
ResponseEntity
<>(
deptService
.
buildTree
(
new
ArrayList
<>(
deptSet
)),
HttpStatus
.
OK
);
}
...
...
Write
Preview
Supports
Markdown
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