【8.1.4】【sysUser】更新批量获取用户的信息带头像url

dev-8.1.9
fengshuonan 2024-04-02 22:56:47 +08:00
parent 4a489f74c8
commit c298027905
2 changed files with 50 additions and 0 deletions

View File

@ -171,4 +171,12 @@ public interface SysUserServiceApi {
*/
Set<Long> getUserComprehensiveIdentitySummary();
/**
*
*
* @author fengshuonan
* @since 2024/4/2 22:48
*/
List<SimpleUserDTO> batchGetUserSimpleInfoList(Set<Long> userIdList);
}

View File

@ -752,6 +752,48 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return comprehensiveIdentity;
}
@Override
public List<SimpleUserDTO> batchGetUserSimpleInfoList(Set<Long> userIdList) {
if (ObjectUtil.isEmpty(userIdList)) {
return new ArrayList<>();
}
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
wrapper.in(SysUser::getUserId, userIdList);
wrapper.select(SysUser::getRealName, SysUser::getAccount, SysUser::getAvatar, SysUser::getUserId);
List<SysUser> list = this.list(wrapper);
if (ObjectUtil.isEmpty(list)) {
return new ArrayList<>();
}
// 排序
List<SysUser> sortUsers = SortUtils.sortListByObjectKey(list, new LinkedList<>(userIdList));
// 初始化返回结果
List<SimpleUserDTO> simpleUserDTOS = new ArrayList<>();
for (SysUser sysUser : sortUsers) {
SimpleUserDTO simpleUserDTO = new SimpleUserDTO();
simpleUserDTO.setAccount(sysUser.getAccount());
simpleUserDTO.setRealName(sysUser.getRealName());
simpleUserDTO.setUserId(sysUser.getUserId());
// 获取头像的访问地址
Long avatar = sysUser.getAvatar();
String fileAuthUrl = null;
try {
fileAuthUrl = fileInfoApi.getFileAuthUrl(avatar);
} catch (Exception e) {
continue;
}
simpleUserDTO.setAvatarUrl(fileAuthUrl);
simpleUserDTOS.add(simpleUserDTO);
}
return simpleUserDTOS;
}
/**
*
*