|
@@ -1,6 +1,9 @@
|
|
|
package com.jzg.organization.service.impl;
|
|
package com.jzg.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.lang.tree.Tree;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jzg.core.page.HttpResult;
|
|
import com.jzg.core.page.HttpResult;
|
|
|
import com.jzg.exception.SystemException;
|
|
import com.jzg.exception.SystemException;
|
|
@@ -9,6 +12,7 @@ import com.jzg.organization.entity.vo.SysDeptVo;
|
|
|
import com.jzg.organization.mapper.SysDeptMapper;
|
|
import com.jzg.organization.mapper.SysDeptMapper;
|
|
|
import com.jzg.organization.service.DeptService;
|
|
import com.jzg.organization.service.DeptService;
|
|
|
import com.jzg.util.AssertionUtils;
|
|
import com.jzg.util.AssertionUtils;
|
|
|
|
|
+import com.jzg.util.TreeBuildUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -254,4 +258,38 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
sysDeptList.forEach(i -> i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>())));
|
|
sysDeptList.forEach(i -> i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>())));
|
|
|
return map.get(sysDept.getParentId());
|
|
return map.get(sysDept.getParentId());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Tree<String>> selectDeptTreeList(String systemCode) {
|
|
|
|
|
+ LambdaQueryWrapper<SysDept> lqw = buildQueryWrapper(systemCode);
|
|
|
|
|
+ List<SysDept> depts = baseMapper.selectDeptList(lqw);
|
|
|
|
|
+ return buildDeptTreeSelect(depts);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建前端所需要下拉树结构
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param depts 机构列表
|
|
|
|
|
+ * @return 下拉树结构列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Tree<String>> buildDeptTreeSelect(List<SysDept> depts) {
|
|
|
|
|
+ if (CollUtil.isEmpty(depts)) {
|
|
|
|
|
+ return CollUtil.newArrayList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return TreeBuildUtils.build(depts, (dept, tree) ->
|
|
|
|
|
+ tree.setId(dept.getId())
|
|
|
|
|
+ .setParentId(dept.getParentId())
|
|
|
|
|
+ .setName(dept.getName())
|
|
|
|
|
+ .setWeight(dept.getOrderNum()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private LambdaQueryWrapper<SysDept> buildQueryWrapper(String systemCode) {
|
|
|
|
|
+ LambdaQueryWrapper<SysDept> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(SysDept::getSystemCode, systemCode);
|
|
|
|
|
+ lqw.eq(SysDept::getDelFlag, 0);
|
|
|
|
|
+ lqw.orderByAsc(SysDept::getParentId);
|
|
|
|
|
+ lqw.orderByAsc(SysDept::getOrderNum);
|
|
|
|
|
+ return lqw;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|