Skip to content

分页查询

Mapper 内置方法

  • paging(Pager,Where):动态条件,分页查询

动态where查询

java
public class Demo {
    @Autowired
    private SysUserMapper sysUserMapper;
    
    public void list() {
        Pager<SysUser> pager= sysUserMapper.paging(Pager.of(1),where->{
           where.like(SysUser::getUserName,"abc");
       });
    }
}

基于QueryChain(强大)

可构建复杂的场景, 更多操作前往 链路查询 - QueryChain

java
public class Demo {
    @Autowired
    private SysUserMapper sysUserMapper;

    public void list() {
        Pager<SysUser> pager= QueryChain.of(sysUserMapper)
                .like(SysUser::getUserName,"abc")
                .paging(Pager.of(1));
    }
}