LambdaQueryWrapper用法

简介: LambdaQueryWrapper用法


LambdaQueryWrapper 与QueryWrapper查询类似,不过使用的是Lambda语法

public Result queryById(Long id) {
        LambdaQueryWrapper<Comment> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Comment::getArticleId, id);
//        1. 其中Comment::getArticleId的意思就相当于:
//        1.1 实例化一个Comment对象
//        Comment comment = new comment;
//        1.2 调用对象Comment的get方法,这里调用的是getArticleId:
//        comment.getArticleId();
//        2.eq方法相当于赋值“=”
//        即将ArticleId的值为参数id,注意此时使用的是get方法而不是set方法
        queryWrapper.eq(Comment::getLevel, 1);
        queryWrapper.orderByDesc(Comment::getCreateDate);
        List<Comment> comments = commentMapper.selectList(queryWrapper);
        List<CommentVo> commentVoList = copyList(comments);
        return Result.success(commentVoList);
    }


相关文章
|
6月前
|
容器
SimpleMessageListenerContainer用法
SimpleMessageListenerContainer用法
|
9月前
/与%,%与/的用法
/与%,%与/的用法
140 0
|
11月前
|
Python
__name__的基本用法
__name__的基本用法
66 0
|
11月前
|
Java Spring
@ConditionalOnProperty的用法
@ConditionalOnProperty的用法
237 0
|
存储 API 索引
CImageList用法介绍
CImageList用法介绍
130 0
iTween的基本用法
Unity3D插件-iTween的基本用法 本文提供全流程,中文翻译。Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 —— 高分辨率用户请根据需求调整网页缩放比例...
1855 0