提交 cec2ee03 作者: 张开石

1、修改根据userId向上获取部门列表逻辑的问题

父级 0ce1d2e9
......@@ -13,6 +13,7 @@ import com.cmeeting.constant.RecordTemplateConstant;
import com.cmeeting.constant.UserTypeConstant;
import com.cmeeting.dto.PermissionCheckedDTO;
import com.cmeeting.dto.SysUserSyncDTO;
import com.cmeeting.mapper.secondary.SysUserSyncCategoryMapper;
import com.cmeeting.mapper.secondary.SysUserSysMapper;
import com.cmeeting.pojo.ModulePermission;
import com.cmeeting.pojo.SysUserSyncCategory;
......@@ -25,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
......@@ -43,6 +45,8 @@ public class SysUserSyncServiceImpl extends ServiceImpl<SysUserSysMapper, SysUse
@Resource
private ISysUserSyncCategoryService iSysUserSyncCategoryService;
@Resource
private SysUserSyncCategoryMapper sysUserSyncCategoryMapper;
@Resource
private ModulePermissionService modulePermissionService;
@Override
......@@ -77,30 +81,22 @@ public class SysUserSyncServiceImpl extends ServiceImpl<SysUserSysMapper, SysUse
String deptId = sysUserSync.getDeptId();
// 获取当前租户所有部门
// 查询当前租户下所有部门
List<SysUserSyncCategory> allDeptList = iSysUserSyncCategoryService.list(new LambdaQueryWrapper<SysUserSyncCategory>().eq(SysUserSyncCategory::getTenantId, perTenantId));
// 从所有部门中向上递归查找父级部门
List<SysUserSyncCategory> parentDeptList = new ArrayList<>();
SysUserSyncCategory currentDept = allDeptList.stream()
.filter(dept -> dept.getDeptId().equals(deptId))
.findFirst()
.orElse(null);
while (currentDept != null && !currentDept.getDeptId().equals(CategoryConstant.ROOT_ID)) {
parentDeptList.add(currentDept);
SysUserSyncCategory finalCurrentDept = currentDept;
currentDept = allDeptList.stream()
.filter(dept -> dept.getDeptId().equals(finalCurrentDept.getParentId()))
.findFirst()
.orElse(null);
}
return parentDeptList;
List<SysUserSyncCategory> categoryList = new ArrayList<>();
getParentCategoryList(deptId, categoryList);
return categoryList;
}
private void getParentCategoryList(String deptId, List<SysUserSyncCategory> categoryList) {
if (CategoryConstant.ROOT_ID.equals(deptId)) {
return;
}
SysUserSyncCategory category = sysUserSyncCategoryMapper.selectOne(new LambdaQueryWrapper<SysUserSyncCategory>().eq(SysUserSyncCategory::getDeptId, deptId));
if (ObjectUtils.isEmpty(category)) {
return;
}
categoryList.add(category);
getParentCategoryList(category.getParentId(), categoryList);
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论