解释一下:乍一看标题可能有点懵~,其实就是想查询的时候过滤掉某些字段
例如: select name,email,password from user;
--改为-> select name,email from user;
去掉password这个敏感字段
MybatisPlus实现方式
- 查询所有的列
SysUser user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getId, id));
- 查询指定的列
SysUser user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().select(SysUser::getName).eq(SysUser::getId, id));
- 排除指定的列
SysUser user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().select(SysUser.class, e -> !Objects.equals(e.getColumn(), USER_PASSWORD_FIELD)).eq(SysUser::getId, id));
有多列需要排除,.select(SysUser.class, e -> !Objects.equals(e.getColumn() && !Objects.equals(xxx,xxx) && ......)继续往后排除即可
标签:MybatisPlus,查询,sysUserService,过滤,user,select,SysUser From: https://www.cnblogs.com/qbbit/p/17206662.html