mirror of https://github.com/elunez/eladmin
parent
3aab1567c4
commit
484785c222
|
@ -34,6 +34,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
|
@ -71,8 +72,15 @@ public class DeptController {
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
DeptDto deptDto = deptService.findById(id);
|
DeptDto deptDto = deptService.findById(id);
|
||||||
List<DeptDto> depts = deptService.getSuperior(deptDto, new ArrayList<>());
|
List<DeptDto> depts = deptService.getSuperior(deptDto, new ArrayList<>());
|
||||||
|
for (DeptDto dept : depts) {
|
||||||
|
if(dept.getId().equals(deptDto.getPid())) {
|
||||||
|
dept.setSubCount(dept.getSubCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
deptSet.addAll(depts);
|
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);
|
return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptSet)),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import me.zhengjie.modules.system.domain.Menu;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.domain.vo.MenuVo;
|
import me.zhengjie.modules.system.domain.vo.MenuVo;
|
||||||
import me.zhengjie.modules.system.service.MenuService;
|
import me.zhengjie.modules.system.service.MenuService;
|
||||||
|
import me.zhengjie.modules.system.service.dto.DeptDto;
|
||||||
import me.zhengjie.modules.system.service.dto.MenuDto;
|
import me.zhengjie.modules.system.service.dto.MenuDto;
|
||||||
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
|
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.mapstruct.MenuMapper;
|
import me.zhengjie.modules.system.service.mapstruct.MenuMapper;
|
||||||
|
@ -43,7 +44,6 @@ import java.util.stream.Collectors;
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-03
|
* @date 2018-12-03
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Api(tags = "系统:菜单管理")
|
@Api(tags = "系统:菜单管理")
|
||||||
|
@ -104,8 +104,16 @@ public class MenuController {
|
||||||
if(CollectionUtil.isNotEmpty(ids)){
|
if(CollectionUtil.isNotEmpty(ids)){
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
MenuDto menuDto = menuService.findById(id);
|
MenuDto menuDto = menuService.findById(id);
|
||||||
menuDtos.addAll(menuService.getSuperior(menuDto, new ArrayList<>()));
|
List<MenuDto> menuDtoList = menuService.getSuperior(menuDto, new ArrayList<>());
|
||||||
|
for (MenuDto menu : menuDtoList) {
|
||||||
|
if(menu.getId().equals(menuDto.getPid())) {
|
||||||
|
menu.setSubCount(menu.getSubCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menuDtos.addAll(menuDtoList);
|
||||||
}
|
}
|
||||||
|
// 编辑菜单时不显示自己以及自己下级的数据,避免出现PID数据环形问题
|
||||||
|
menuDtos = menuDtos.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
||||||
return new ResponseEntity<>(menuService.buildTree(new ArrayList<>(menuDtos)),HttpStatus.OK);
|
return new ResponseEntity<>(menuService.buildTree(new ArrayList<>(menuDtos)),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(menuService.getMenus(null),HttpStatus.OK);
|
return new ResponseEntity<>(menuService.getMenus(null),HttpStatus.OK);
|
||||||
|
|
Loading…
Reference in New Issue