1.层级关系
请添加图片描述
2.LambdaQueryWrapper :与QueryWrapper查询类似,不过使用的是Lambda语法。
举例如下:

package com.mszlu.blog.dao.pojo;

import lombok.Data;

@Data
public class Comment {

    private Long id;

    private String content;

    private Long createDate;

    private Long articleId;

    private Long authorId;

    private Long parentId;

    private Long toUid;

    private Integer level;
}

 public Result commentsByArticleId(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);
    }

QueryWrapper其他方法参考下图:
请添加图片描述


版权声明:本文为weixin_41629964原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_41629964/article/details/122836988