【添加】添加接口 1、根据部门id查询部门所有的父级(不包含自己)2、根据部门id查询部门所有的子级(不包含自己)
This commit is contained in:
+18
@@ -281,4 +281,22 @@ public interface ISysBaseAPI extends CommonAPI {
|
||||
*/
|
||||
void sendEmailMsg(String email,String title,String content);
|
||||
|
||||
/**
|
||||
* 41根据部门id查询部门所有的父级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 8:50
|
||||
* @param departId 部门id
|
||||
* @return JSONObject
|
||||
*/
|
||||
List<JSONObject> listParentDepartsByDepId(String departId);
|
||||
|
||||
/**
|
||||
* 42根据部门id查询部门所有的子级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 8:54
|
||||
* @param departId 部门id
|
||||
* @return JSONObject
|
||||
*/
|
||||
List<JSONObject> listSonDepartsByDepId(String departId);
|
||||
|
||||
}
|
||||
|
||||
+16
@@ -107,4 +107,20 @@ public interface ISysDepartService extends IService<SysDepart>{
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeModel> queryTreeByKeyWord(String keyWord);
|
||||
|
||||
/**
|
||||
* 根据部门id查询部门所有的父级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 8:50
|
||||
* @param departId 部门id
|
||||
*/
|
||||
List<SysDepartTreeModel> listParentDepartsByDepId(String departId);
|
||||
|
||||
/**
|
||||
* 根据部门id查询部门所有的子级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 8:54
|
||||
* @param departId 部门id
|
||||
*/
|
||||
List<SysDepartTreeModel> listSonDepartsByDepId(String departId);
|
||||
}
|
||||
|
||||
+28
-2
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.jero.modules.system.model.SysDepartTreeModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -846,7 +847,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
|
||||
/**
|
||||
* 36根据多个用户账号(逗号分隔),查询返回多个用户信息
|
||||
* @param orgCodes
|
||||
* @param usernames
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -865,7 +866,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
|
||||
/**
|
||||
* 37根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
* @param usernames
|
||||
* @param orgCodes
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -991,4 +992,29 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
emailHandle.SendMsg(email, title, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门id查询部门所有的父级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 8:50
|
||||
* @param departId 部门id
|
||||
* @return JSONObject
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> listParentDepartsByDepId(String departId) {
|
||||
List<SysDepartTreeModel> sysDepartTreeModels = sysDepartService.listParentDepartsByDepId(departId);
|
||||
return JSON.parseArray(JSON.toJSONString(sysDepartTreeModels)).toJavaList(JSONObject.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 42根据部门id查询部门所有的子级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 8:54
|
||||
* @param departId 部门id
|
||||
* @return JSONObject
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> listSonDepartsByDepId(String departId) {
|
||||
List<SysDepartTreeModel> sysDepartTreeModels = sysDepartService.listSonDepartsByDepId(departId);
|
||||
return JSON.parseArray(JSON.toJSONString(sysDepartTreeModels)).toJavaList(JSONObject.class);
|
||||
}
|
||||
}
|
||||
+57
-1
@@ -454,7 +454,8 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
return treelist;
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* 根据关键字筛选部门信息
|
||||
* @param keyWord
|
||||
* @return
|
||||
@@ -469,4 +470,59 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据部门id查询部门所有的父级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 9:10
|
||||
* @param departId 部门id
|
||||
* @return java.util.List<com.jero.modules.system.entity.SysDepart>
|
||||
*/
|
||||
@Override
|
||||
public List<SysDepartTreeModel> listParentDepartsByDepId(String departId) {
|
||||
List<SysDepart> list = new ArrayList<>();
|
||||
SysDepart depart = this.getById(departId);
|
||||
String parentId = depart.getParentId();
|
||||
// 查询父部门
|
||||
SysDepart parentDepart = this.getById(parentId);
|
||||
while (parentDepart != null){
|
||||
list.add(parentDepart);
|
||||
parentId = parentDepart.getParentId();
|
||||
parentDepart = this.getById(parentId);
|
||||
}
|
||||
Collections.reverse(list);
|
||||
// 调用wrapTreeDataToTreeList方法生成树状数据
|
||||
return FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门id查询部门所有的子级(不包含自己)
|
||||
* @author 马志朝
|
||||
* @date 2021/3/24 9:11
|
||||
* @param departId 部门id
|
||||
* @return java.util.List<com.jero.modules.system.entity.SysDepart>
|
||||
*/
|
||||
@Override
|
||||
public List<SysDepartTreeModel> listSonDepartsByDepId(String departId) {
|
||||
List<SysDepartTreeModel> realResult = new ArrayList<>();
|
||||
LambdaQueryWrapper<SysDepart> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//获取直接子节点
|
||||
List<SysDepart> sonDepartList = this.list(queryWrapper.eq(SysDepart::getParentId, departId));
|
||||
for(SysDepart depart : sonDepartList){
|
||||
String tempId = depart.getId();
|
||||
List<SysDepart> listResult = new ArrayList<>();
|
||||
// 将每个直接子节点的parentId设为空来构成树的头节点
|
||||
depart.setParentId(null);
|
||||
listResult.add(depart);
|
||||
List<String> idListTemp = new ArrayList<>();
|
||||
this.checkChildrenExists(tempId, idListTemp);
|
||||
idListTemp.forEach(id -> {
|
||||
SysDepart sysDepartTemp = this.getById(id);
|
||||
listResult.add(sysDepartTemp);
|
||||
});
|
||||
List<SysDepartTreeModel> sysDepartTreeModels = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(listResult);
|
||||
realResult.addAll(sysDepartTreeModels);
|
||||
}
|
||||
|
||||
return realResult;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user