方法1:只需要查询出name和phone两个字段:使用queryWrapper的select()方法指定要查询的字段
public List selectByWrapper1(){
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.select("username");//指定查询某字段
List sysUsers=sysUserService.list(queryWrapper);
return sysUsers;
}
方法2:查询出除age和address外其它所有字段的数据:同样使用queryWrapper的select()方法
public List selectByWrapper2(){
QueryWrapper queryWrapper = new QueryWrapper<>();
//查询指定某字段以外的数据
queryWrapper.select(
SysUser.class, info ->!info.getColumn().equals("id") && !info.getColumn().equals("email")
);
List sysUsers=sysUserService.list(queryWrapper);
return sysUsers;
}