refactor(system): 优化工作日志中部门信息获取逻辑
- 增加对 childDeptIds 是否为空的判断,提高代码健壮性 - 优化部门信息获取逻辑,提高代码可读性和性能
This commit is contained in:
parent
83b5f9a27c
commit
c3f2b8f9f5
@ -336,12 +336,22 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
||||
List<Long> startUserIds = convertList(logInstanceIds, LogReadDO::getStartUserId);
|
||||
List<AdminUserDO> adminUserDOS = adminUserService.getUserList(startUserIds);
|
||||
|
||||
// 获得部门信息
|
||||
List<Long> deptIds = adminUserDOS.stream()
|
||||
.map(AdminUserDO::getDeptId)
|
||||
.filter(deptId -> CollectionUtil.isNotEmpty(childDeptIds) && childDeptIds.contains(deptId))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<Long> deptIds;
|
||||
if (CollectionUtil.isNotEmpty(childDeptIds)) {
|
||||
|
||||
// 获得部门信息
|
||||
deptIds = adminUserDOS.stream()
|
||||
.map(AdminUserDO::getDeptId)
|
||||
.filter(childDeptIds::contains)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}else {
|
||||
// 获得部门信息
|
||||
deptIds = adminUserDOS.stream()
|
||||
.map(AdminUserDO::getDeptId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<DeptDO> deptDOS = deptService.getDeptList(deptIds);
|
||||
return BeanUtils.toBean(deptDOS, DeptRespVO.class);
|
||||
|
Loading…
Reference in New Issue
Block a user