| | |
| | | @PreAuthorize("hasAuthority('system:dept:list')") |
| | | @PostMapping("/dept/tree") |
| | | public R tree(@RequestBody Map<String, Object> map) { |
| | | PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class); |
| | | List<Dept> deptList = deptService.list(param.buildWrapper(true)); |
| | | return R.ok().add(Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren)); |
| | | // PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class); |
| | | // QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); |
| | | List<Dept> deptList = deptService.list(new LambdaQueryWrapper<Dept>().orderByAsc(Dept::getSort)); |
| | | List<Dept> treeData = Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren); |
| | | Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren); |
| | | } |
| | | return R.ok().add(treeData); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dept:list')") |