美文网首页
2020-09-02

2020-09-02

作者: cmeizu | 来源:发表于2020-09-02 12:49 被阅读0次
 @Override
    public List<UserDTO> getUserDTO(Integer userId) {
        List<User> users = list(Wrappers.lambdaQuery(User.class)
                .select(User::getId, User::getName, User::getAge, User::getSex)
                .orderByDesc(User::getId)
                .last("limit 3"));
        return users.stream().map(u->{
            UserDTO dto = new UserDTO();
            BeanUtils.copyProperties(u, dto);
            return dto;
        }).collect(Collectors.toList());
    }
==>  Preparing: SELECT id,name,age,sex FROM user ORDER BY id DESC limit 3 
==> Parameters: 
<==    Columns: id, name, age, sex
<==        Row: 10, test1, 10, F
<==        Row: 9, test3, 40, M
<==        Row: 8, test, 18, M
<==      Total: 3

补充上一篇文章列表也是可以的.https://www.jianshu.com/p/4d6e7090fafd

相关文章

网友评论

      本文标题:2020-09-02

      本文链接:https://www.haomeiwen.com/subject/qwaisktx.html