File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
eladmin-system/src/main/java/me/zhengjie/modules/system/rest Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -67,20 +67,23 @@ public ResponseEntity<PageResult<DeptDto>> queryDept(DeptQueryCriteria criteria)
67
67
@ ApiOperation ("查询部门:根据ID获取同级与上级数据" )
68
68
@ PostMapping ("/superior" )
69
69
@ PreAuthorize ("@el.check('user:list','dept:list')" )
70
- public ResponseEntity <Object > getDeptSuperior (@ RequestBody List <Long > ids ) {
70
+ public ResponseEntity <Object > getDeptSuperior (@ RequestBody List <Long > ids ,
71
+ @ RequestParam (defaultValue = "false" ) Boolean exclude ) {
71
72
Set <DeptDto > deptSet = new LinkedHashSet <>();
72
73
for (Long id : ids ) {
73
74
DeptDto deptDto = deptService .findById (id );
74
75
List <DeptDto > depts = deptService .getSuperior (deptDto , new ArrayList <>());
75
- for (DeptDto dept : depts ) {
76
- if (dept .getId ().equals (deptDto .getPid ())) {
77
- dept .setSubCount (dept .getSubCount () - 1 );
76
+ if (exclude ){
77
+ for (DeptDto dept : depts ) {
78
+ if (dept .getId ().equals (deptDto .getPid ())) {
79
+ dept .setSubCount (dept .getSubCount () - 1 );
80
+ }
78
81
}
82
+ // 编辑部门时不显示自己以及自己下级的数据,避免出现PID数据环形问题
83
+ depts = depts .stream ().filter (i -> !ids .contains (i .getId ())).collect (Collectors .toList ());
79
84
}
80
85
deptSet .addAll (depts );
81
86
}
82
- // 编辑部门时不显示自己以及自己下级的数据,避免出现PID数据环形问题
83
- deptSet = deptSet .stream ().filter (i -> !ids .contains (i .getId ())).collect (Collectors .toSet ());
84
87
return new ResponseEntity <>(deptService .buildTree (new ArrayList <>(deptSet )),HttpStatus .OK );
85
88
}
86
89
You can’t perform that action at this time.
0 commit comments