mirror of https://gitee.com/xiaonuobase/snowy
【增强】用户、机构选择器优化
parent
43f1137d64
commit
5eb8ed8d1e
|
@ -94,13 +94,61 @@ public interface BizOrgService extends IService<BizOrg> {
|
||||||
List<BizOrg> getAllOrgList();
|
List<BizOrg> getAllOrgList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据机构全名称获取机构id,有则返回,无则创建
|
* 根据组织全名称获取组织id,有则返回,无则创建
|
||||||
*
|
*
|
||||||
* @author xuyuxiang
|
* @author xuyuxiang
|
||||||
* @date 2023/3/7 15:44
|
* @date 2023/3/7 15:44
|
||||||
**/
|
**/
|
||||||
String getOrgIdByOrgFullNameWithCreate(String orgFullName);
|
String getOrgIdByOrgFullNameWithCreate(String orgFullName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取父子数据列表
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/8/15 14:55
|
||||||
|
**/
|
||||||
|
List<BizOrg> getParentAndChildListById(List<BizOrg> originDataList, String id, boolean includeSelf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取所有的子数据列表
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/8/15 14:55
|
||||||
|
**/
|
||||||
|
List<BizOrg> getChildListById(List<BizOrg> originDataList, String id, boolean includeSelf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取所有的父数据列表
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/8/15 14:55
|
||||||
|
**/
|
||||||
|
List<BizOrg> getParentListById(List<BizOrg> originDataList, String id, boolean includeSelf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取数据
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/8/15 14:55
|
||||||
|
**/
|
||||||
|
BizOrg getById(List<BizOrg> originDataList, String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取父数据
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/8/15 14:55
|
||||||
|
**/
|
||||||
|
BizOrg getParentById(List<BizOrg> originDataList, String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取子数据
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/8/15 14:55
|
||||||
|
**/
|
||||||
|
BizOrg getChildById(List<BizOrg> originDataList, String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取机构树选择器
|
* 获取机构树选择器
|
||||||
*
|
*
|
||||||
|
|
|
@ -389,6 +389,7 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
|
||||||
|
|
||||||
/* ====以下为各种递归方法==== */
|
/* ====以下为各种递归方法==== */
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<BizOrg> getParentAndChildListById(List<BizOrg> originDataList, String id, boolean includeSelf) {
|
public List<BizOrg> getParentAndChildListById(List<BizOrg> originDataList, String id, boolean includeSelf) {
|
||||||
List<BizOrg> parentListById = this.getParentListById(originDataList, id, false);
|
List<BizOrg> parentListById = this.getParentListById(originDataList, id, false);
|
||||||
List<BizOrg> childListById = this.getChildListById(originDataList, id, true);
|
List<BizOrg> childListById = this.getChildListById(originDataList, id, true);
|
||||||
|
@ -396,6 +397,7 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
|
||||||
return parentListById;
|
return parentListById;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<BizOrg> getChildListById(List<BizOrg> originDataList, String id, boolean includeSelf) {
|
public List<BizOrg> getChildListById(List<BizOrg> originDataList, String id, boolean includeSelf) {
|
||||||
List<BizOrg> resultList = CollectionUtil.newArrayList();
|
List<BizOrg> resultList = CollectionUtil.newArrayList();
|
||||||
execRecursionFindChild(originDataList, id, resultList);
|
execRecursionFindChild(originDataList, id, resultList);
|
||||||
|
@ -408,6 +410,7 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<BizOrg> getParentListById(List<BizOrg> originDataList, String id, boolean includeSelf) {
|
public List<BizOrg> getParentListById(List<BizOrg> originDataList, String id, boolean includeSelf) {
|
||||||
List<BizOrg> resultList = CollectionUtil.newArrayList();
|
List<BizOrg> resultList = CollectionUtil.newArrayList();
|
||||||
execRecursionFindParent(originDataList, id, resultList);
|
execRecursionFindParent(originDataList, id, resultList);
|
||||||
|
@ -420,6 +423,7 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void execRecursionFindChild(List<BizOrg> originDataList, String id, List<BizOrg> resultList) {
|
public void execRecursionFindChild(List<BizOrg> originDataList, String id, List<BizOrg> resultList) {
|
||||||
originDataList.forEach(item -> {
|
originDataList.forEach(item -> {
|
||||||
if(item.getParentId().equals(id)) {
|
if(item.getParentId().equals(id)) {
|
||||||
|
@ -441,16 +445,19 @@ public class BizOrgServiceImpl extends ServiceImpl<BizOrgMapper, BizOrg> impleme
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BizOrg getById(List<BizOrg> originDataList, String id) {
|
public BizOrg getById(List<BizOrg> originDataList, String id) {
|
||||||
int index = CollStreamUtil.toList(originDataList, BizOrg::getId).indexOf(id);
|
int index = CollStreamUtil.toList(originDataList, BizOrg::getId).indexOf(id);
|
||||||
return index == -1?null:originDataList.get(index);
|
return index == -1?null:originDataList.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BizOrg getParentById(List<BizOrg> originDataList, String id) {
|
public BizOrg getParentById(List<BizOrg> originDataList, String id) {
|
||||||
BizOrg self = this.getById(originDataList, id);
|
BizOrg self = this.getById(originDataList, id);
|
||||||
return ObjectUtil.isNotEmpty(self)?self:this.getById(originDataList, self.getParentId());
|
return ObjectUtil.isNotEmpty(self)?self:this.getById(originDataList, self.getParentId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BizOrg getChildById(List<BizOrg> originDataList, String id) {
|
public BizOrg getChildById(List<BizOrg> originDataList, String id) {
|
||||||
int index = CollStreamUtil.toList(originDataList, BizOrg::getParentId).indexOf(id);
|
int index = CollStreamUtil.toList(originDataList, BizOrg::getParentId).indexOf(id);
|
||||||
return index == -1?null:originDataList.get(index);
|
return index == -1?null:originDataList.get(index);
|
||||||
|
|
|
@ -314,11 +314,11 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
||||||
return sysUserService.getAllUserSelectorList();
|
return sysUserService.getAllUserSelectorList();
|
||||||
} else {
|
} else {
|
||||||
if(ObjectUtil.isNotEmpty(sysOrgSelectorUserParam.getOrgId())) {
|
if(ObjectUtil.isNotEmpty(sysOrgSelectorUserParam.getOrgId())) {
|
||||||
// 如果组织id不为空,则查询该组织所在顶级组织下的所有人
|
// 如果组织id不为空,则查询该组织及其子组织下的所有人
|
||||||
List<String> parentAndChildOrgIdList = CollStreamUtil.toList(this.getParentAndChildListById(this
|
List<String> childOrgIdList = CollStreamUtil.toList(this.getChildListById(this
|
||||||
.getCachedAllOrgList(), sysOrgSelectorUserParam.getOrgId(), true), SysOrg::getId);
|
.getCachedAllOrgList(), sysOrgSelectorUserParam.getOrgId(), true), SysOrg::getId);
|
||||||
if (ObjectUtil.isNotEmpty(parentAndChildOrgIdList)) {
|
if (ObjectUtil.isNotEmpty(childOrgIdList)) {
|
||||||
lambdaQueryWrapper.in(SysUser::getOrgId, parentAndChildOrgIdList);
|
lambdaQueryWrapper.in(SysUser::getOrgId, childOrgIdList);
|
||||||
} else {
|
} else {
|
||||||
return new Page<>();
|
return new Page<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,8 +463,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
// 如果组织id不为空,则查询该组织及其子极其子下的所有人
|
// 如果组织id不为空,则查询该组织及其子极其子下的所有人
|
||||||
List<String> childOrgIdList = CollStreamUtil.toList(sysOrgService.getChildListById(sysOrgService
|
List<String> childOrgIdList = CollStreamUtil.toList(sysOrgService.getChildListById(sysOrgService
|
||||||
.getCachedAllOrgList(), sysRoleSelectorUserParam.getOrgId(), true), SysOrg::getId);
|
.getCachedAllOrgList(), sysRoleSelectorUserParam.getOrgId(), true), SysOrg::getId);
|
||||||
if (ObjectUtil.isNotEmpty(parentAndChildOrgIdList)) {
|
if (ObjectUtil.isNotEmpty(childOrgIdList)) {
|
||||||
lambdaQueryWrapper.in(SysUser::getOrgId, parentAndChildOrgIdList);
|
lambdaQueryWrapper.in(SysUser::getOrgId, childOrgIdList);
|
||||||
} else {
|
} else {
|
||||||
return new Page<>();
|
return new Page<>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue