发布时间:2023-06-09 11:00
分页查询某个角色所关联的用户信息。
UserMapper
IPage getByRoleId(Long roleId, IPage page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);
UserMapper.xml
1.不带wrapper参数查询
==> Preparing: select * from user u inner join user_role ur on u.id = ur.user_id and ur.role_id = ? LIMIT ?
==> Parameters: 2(Long), 10(Long)
2.带wrapper参数查询
==> Preparing: select * from user u inner join user_role ur on u.id = ur.user_id and ur.role_id = ? and (status = ?) LIMIT ?
==> Parameters: 2(Long), 1(Integer), 10(Long)
所以要if test=\"ew.sqlSegment!=null and ew.sqlSegment!=\'\'\"
判断一下。否则会导致sql错误,末尾多个and