refactor(system): 优化用户相关接口的部门数据处理

-将 convertList 方法替换为 convertSet,以提高性能
-简化代码结构,提高可读性
This commit is contained in:
furongxin 2024-12-25 10:01:32 +08:00
parent 493e735a0c
commit cb568fb746

View File

@ -41,8 +41,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@ -181,8 +180,7 @@ public class UserController {
List<AdminUserDO> list = userService.getUserListByStatus(userType, deptId, status, roleCodes);
// 拼接数据
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(list, AdminUserDO::getDeptId));
Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertSet(list, AdminUserDO::getDeptId));
return success(UserConvert.INSTANCE.convertSimpleList(list, deptMap));
}
@ -193,7 +191,7 @@ public class UserController {
List<AdminUserDO> list = userService.getUserListByDepts(1, deptIds, CommonStatusEnum.ENABLE.getStatus());
// 拼接数据
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(list, AdminUserDO::getDeptId));
convertSet(list, AdminUserDO::getDeptId));
return success(UserConvert.INSTANCE.convertSimpleList(list, deptMap));
}