QueryWrapper Left Join 查询

管理员 148次浏览

摘要:QueryWrapper连表查询、多表查询、or and查询

正文:

					
					    
QueryWrapper<SysUser> query = new QueryWrapper<>();
if (StringUtils.isNotBlank(sysUser.getTelephone())) {
query.like("u.telephone", sysUser.getTelephone());
}
query.and(qw -> qw.eq("u.department", "一部门").or().eq("u.department", "二部门").or().eq("u.department", "三部门"));
return baseMapper.queryUserPage(new Page(page, limit), query);


Mapper:

@Select("SELECT u.*,r.name as rolesName from user u LEFT JOIN roles r on u.roles = r.rid ${ew.customSqlSegment}")

IPage<SysUser> queryUserPage(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper);

表情

共0条评论