一、selectMaps方法
应用场景一:表字段特别多,但是需求只要其中几个时,使用selectMaps更优雅
// SELECT id,name FROM user WHERE (name LIKE ? AND age < ?)
@Test
public void selectByWrapperMaps(){
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.select("id","name").like("name","J").lt("age",40);
List> userList = userMapper.selectMaps(queryWrapper);
userList.forEach(System.out::println);
}
应用场景二:统计查询中返回统计结果时
// SELECT avg(age) avg_age,min(age) min_age,max(age) max_age FROM user GROUP BY age HAVING sum(age) > ?
@Test
public void selectByWrapperMaps2(){
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.select("avg(age) avg_age","min(age) min_age","max(age) max_age")
.groupBy("