File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
eladmin-system/src/main/java/me/zhengjie/modules/system/rest Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 34
34
import org .springframework .web .bind .annotation .*;
35
35
import javax .servlet .http .HttpServletResponse ;
36
36
import java .util .*;
37
+ import java .util .stream .Collectors ;
37
38
38
39
/**
39
40
* @author Zheng Jie
@@ -71,8 +72,15 @@ public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids) {
71
72
for (Long id : ids ) {
72
73
DeptDto deptDto = deptService .findById (id );
73
74
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 );
78
+ }
79
+ }
74
80
deptSet .addAll (depts );
75
81
}
82
+ // 编辑部门时不显示自己以及自己下级的数据,避免出现PID数据环形问题
83
+ deptSet = deptSet .stream ().filter (i -> !ids .contains (i .getId ())).collect (Collectors .toSet ());
76
84
return new ResponseEntity <>(deptService .buildTree (new ArrayList <>(deptSet )),HttpStatus .OK );
77
85
}
78
86
Original file line number Diff line number Diff line change 24
24
import me .zhengjie .exception .BadRequestException ;
25
25
import me .zhengjie .modules .system .domain .vo .MenuVo ;
26
26
import me .zhengjie .modules .system .service .MenuService ;
27
+ import me .zhengjie .modules .system .service .dto .DeptDto ;
27
28
import me .zhengjie .modules .system .service .dto .MenuDto ;
28
29
import me .zhengjie .modules .system .service .dto .MenuQueryCriteria ;
29
30
import me .zhengjie .modules .system .service .mapstruct .MenuMapper ;
43
44
* @author Zheng Jie
44
45
* @date 2018-12-03
45
46
*/
46
-
47
47
@ RestController
48
48
@ RequiredArgsConstructor
49
49
@ Api (tags = "系统:菜单管理" )
@@ -104,8 +104,16 @@ public ResponseEntity<List<MenuDto>> getMenuSuperior(@RequestBody List<Long> ids
104
104
if (CollectionUtil .isNotEmpty (ids )){
105
105
for (Long id : ids ) {
106
106
MenuDto menuDto = menuService .findById (id );
107
- menuDtos .addAll (menuService .getSuperior (menuDto , new ArrayList <>()));
107
+ List <MenuDto > menuDtoList = menuService .getSuperior (menuDto , new ArrayList <>());
108
+ for (MenuDto menu : menuDtoList ) {
109
+ if (menu .getId ().equals (menuDto .getPid ())) {
110
+ menu .setSubCount (menu .getSubCount () - 1 );
111
+ }
112
+ }
113
+ menuDtos .addAll (menuDtoList );
108
114
}
115
+ // 编辑菜单时不显示自己以及自己下级的数据,避免出现PID数据环形问题
116
+ menuDtos = menuDtos .stream ().filter (i -> !ids .contains (i .getId ())).collect (Collectors .toSet ());
109
117
return new ResponseEntity <>(menuService .buildTree (new ArrayList <>(menuDtos )),HttpStatus .OK );
110
118
}
111
119
return new ResponseEntity <>(menuService .getMenus (null ),HttpStatus .OK );
You can’t perform that action at this time.
0 commit comments