//参数封装
String idStr = StrUtil.join(",", ids);
//手动指定排序规则,按照传入顺序返回,并收集数据到返回集合
List<UserDTO> userDTOS = userService.query()
.in("id", ids)
.last("ORDER BY FIELD(id," + idStr + ")")
.list()
.stream()
.map(user -> BeanUtil.copyProperties(user, UserDTO.class))
.collect(Collectors.toList());