Service层
@Service
public class DDeptclassifyServiceImpl implements DDeptclassifyService {
@Autowired
private DDeptMapper mapper;
@Autowired
private DeptMapper deptMapper;
@Override
@Cacheable(value = "assistant-cache")
public PageUtils recursion(DDeptExample example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
DDeptExample.Criteria dec = example.createCriteria();
if(example.getDeptIdList() != null){
dec.andDeptIdIn(example.getDeptIdList());
}
if(example.getDeptId() != null){
dec.andDeptIdEqualTo(example.getDeptId());
}
if(example.getDeptIds() != null){
dec.andDeptIdsLike(example.getDeptIds() + "%");
}
if(example.getDeptName() != null){
dec.andDeptNameLike("%|" + example.getDeptName() + "|%");
}
if(example.getOrderNum() != null){
dec.andOrderNumEqualTo(example.getOrderNum());
}
dec.andDelFlagEqualTo(0);
List<DDeptTree> dDeptTreeList = mapper.selectTreeByExample(example);
List<Integer> total = new ArrayList<>();
int t = 0;
for (DDeptTree dDeptTree : dDeptTreeList) {
System.out.println(t++ + "---" + dDeptTree.getDeptId() + "----" + dDeptTree.getDeptIds());
}
System.out.println("**********");
int maxDeptId = mapper.findMaxDeptId();
Object data = listForTree(dDeptTreeList,maxDeptId,total,example.getLimit(),example.getOffset() == null ? null : example.getOffset().intValue());
List<DDeptTree> treeList = (List<DDeptTree>)data;
PageUtils pageUtils = new PageUtils(treeList,total.size() == 0 ? 0 : (long)total.get(0));
List<DDeptTree> dDeptTreeListNew = new ArrayList<>();
boolean hasFatherNode;
for (int i = dDeptTreeList.size() - 1; i >= 0 ; i--) {
hasFatherNode = false;
for(int j = dDeptTreeList.size() - 1; j >= 0; j--){
if(dDeptTreeList.get(j).getDeptId().equals(dDeptTreeList.get(i).getParentId())){
if(dDeptTreeList.get(j).