mybatis-plus分页请教
/*** 分页查询所有数据
*
* @Param page 分页对象
* @param tSysUser 查询实体
* @Return 所有数据
*/
@RequestMapping(value = "/test",method = RequestMethod.POST)
public PageResult<IPage<TSysUserEntity>> selectAll(PageReq req,@RequestBody @Validated TSysUserEntity tSysUser) {
Page<TSysUserEntity> page = new Page<>(req.getPage(),req.getPageSize());
QueryWrapper<TSysUserEntity> tSysUserEntityQueryWrapper = new QueryWrapper<>(tSysUser);
returnPageResult.success(this.TSysUserService.page(page, new QueryWrapper<>(tSysUser)));
}
如代码 改代码的条件是分页查询 条件是TSysUserEntity 类带过来的字段进行and处理 等于说是 select * from user where name = "123" and qq = "123"
也就是对传入的TSysUserEntity 进行了and处理 现在我想通过or 和 like处理我该怎么做呢?
比如orselect * from user where name = "123" or qq = "123"
比如like select * from user where name like "123" or qq like "123"
我得意思是 QueryWrapper里面有没有方法可以改变sql的条件 把原来的and 改成or 把原来的 = 改成 like xiaohuihui3 发表于 2022-12-2 22:53
https://blog.csdn.net/administratop/article/details/122512771
感谢指路{:301_975:} 可以自己拼querywrapper
select * from user where name = "123" or qq = "123"
可以这样写
tSysUserEntityQueryWrapper.eq("name",tSysUser.getName);
tSysUserEntityQueryWrapper.or(true,item->{
item.eq("qq",123)
});
具体的你可以参考mybatis puls 的官网
https://baomidou.com/pages/10c804/#eq
页:
[1]