MyBatis Plus分页查询部分字段

QueryWrapper

查询指定某字段以外的数据

QueryWrapper<AssociationMember> queryWrapper = new QueryWrapper<>();
//查询指定某字段以外的数据
queryWrapper.select(AssociationMember.class, info ->!info.getColumn().equals("photo"));
IPage<AssociationMember> page = new Page<>();
page.setCurrent(getWorkerMemberInfoReqVo.getCurrentPage());
page.setSize(getWorkerMemberInfoReqVo.getPageSize());           
IPage<AssociationMember> iPage=associationMemberMapper.selectPage(page,queryWrapper);

查询指定字段的数据

QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
//查询指定字段的数据
queryWrapper.select("id","name").lambda().eq(StringUtils.isNotBlank(pageQueryMemberListReqVO.getOrgCoding()),Member::getOrgCoding,pageQueryMemberListReqVO.getOrgCoding());
List<Member> list=memberMapper.selectList(queryWrapper);

lambdaQuery

单个字段查询

myService.list(Wrappers.<Demo>lambdaQuery().select(Demo::getId));

多个字段查询

myService.list(Wrappers.<Demo>lambdaQuery().select(Demo::getId, Demo::getAge));

单个字段排除

// 对应实体类字段
myService.list(Wrappers.<Demo>lambdaQuery().select(Demo.class, i -> !"rName".equals(i.getProperty())));
// 对应数据库字段
myService.list(Wrappers.<Demo>lambdaQuery().select(Demo.class, i -> !"r_name".equals(i.getColumn())));

多个字段排除

// 对应实体类字段
myService.list(Wrappers.<Demo>lambdaQuery().select(Demo.class, i -> !"rName".equals(i.getProperty()) && !"age".equals(i.getProperty())));
// 对应数据库字段
myService.list(Wrappers.<Demo>lambdaQuery().select(Demo.class, i -> !"r_name".equals(i.getColumn()) && !"age".equals(i.getColumn())));

实体类使用注解排除

/**
 * 不返回字段的值,但单独查询该字段就可以返回值
 * myService.list(Wrappers.<Demo>lambdaQuery().select(Demo::getRName));
 */
@TableField(select = false)
private String rName;