话不多说,直接上代码,and那句就对了
LambdaQueryWrapper<类> wrapper= new LambdaQueryWrapper<类>() .in(逻辑内容) .like(正常逻辑内容) .and(wrapperNew -> wrapperNew.like(StringUtils.isNotEmpty(filter.getLocation()), 类::getCountry, filter.getLocation()) .or() .like(StringUtils.isNotEmpty(filter.getLocation()), 类::getCity, filter.getLocation())) .like(StringUtils.isNotEmpty(filter.getIsp()), 类::getIp, filter.getIp())
这种写法就相当于是中间的或语句被当做子wrapper写了出来
补充一下写了wrapper后的分页调用
Page<类> agentInfoPage = mapper.selectPage(new Page<>(request.getPageNo(), request.getPageSize()), wrapper);
标签:getLocation,mybatisplus,like,isNotEmpty,wrapper,filter,字符串,写法,StringUtils From: https://www.cnblogs.com/immersed-in-the-deep-sea/p/18152836