|  |  | 
 |  |  | package com.zy.asrs.wcs.system.controller; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | import com.zy.asrs.framework.common.Cools; | 
 |  |  | import com.zy.asrs.framework.common.R; | 
 |  |  | 
 |  |  |     @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); | 
 |  |  |         QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); | 
 |  |  |         List<Dept> deptList = deptService.list(wrapper); | 
 |  |  |         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')") |