1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| @Test void select(){
userMapper.selectList(null).forEach(System.out::println);
QueryWrapper queryWrapper = new QueryWrapper();
Map<String,Object> map = new HashMap<>(); map.put("age",21); map.put("name","xiaobo"); queryWrapper.allEq(map); queryWrapper.likeLeft("name","x"); queryWrapper.likeRight("name","x"); queryWrapper.eq("age",21);
queryWrapper.inSql("id","SELECT id FROM user WHERE id < 12"); queryWrapper.inSql("age","SELECT age FROM user WHERE age < 30");
queryWrapper.orderByAsc("age"); queryWrapper.orderByDesc("id");
userMapper.selectList(queryWrapper).forEach(System.out::println);
根据Id查询 userMapper.selectBatchIds(Arrays.asList(1,2,3,4)).forEach(System.out::println);
Map<String,Object> map = new HashMap<>(); map.put("name","xiaobo"); userMapper.selectByMap(map).forEach(System.out::println);
QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("age",21); System.out.println(userMapper.selectCount(queryWrapper));
Page<User> page = new Page<>(1,3); Page<User> result = userMapper.selectPage(page, null); System.out.println(result.getSize()); System.out.println(result.getTotal()); System.out.println(result.getCurrent());
result.getRecords().forEach(System.out::println);
Page<Map<String,Object>> page = new Page<>(1,4); userMapper.selectMapsPage(page,null).getRecords().forEach(System.out::println); userMapper.selectObjs(null).forEach(System.out::println);
}
|