【增强】用户、机构选择器优化

pull/124/head
徐玉祥 2023-06-29 23:36:26 +08:00
parent 43f1137d64
commit 5eb8ed8d1e
4 changed files with 63 additions and 8 deletions

View File

@ -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);
/** /**
* *
* *

View File

@ -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);

View File

@ -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<>();
} }

View File

@ -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<>();
} }