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
| T selectById(Serializable id);
T selectOne(@Param("ew") Wrapper<T> queryWrapper);
List<T> selectBatchIds(@Param("coll") Collection<? extends Serializable> idList);
List<T> selectByMap(@Param("cm") Map<String, Object> columnMap);
<E extends IPage<T>> E selectPage(E page, @Param("ew") Wrapper<T> queryWrapper);
@Test public void selectTest() { User user = userMapper.selectById(1); System.out.println(user);
User user1 = new User(); user1.setId(6); user1.setName("C酱"); User user2 = userMapper.selectOne(new QueryWrapper<>(user1)); System.out.println(user2);
List<Integer> ids = new ArrayList<>(); ids.add(1); ids.add(2); List<User> users = userMapper.selectBatchIds(ids); users.forEach(System.out::println);
Map<String, Object> columnMap = new HashMap<>(); columnMap.put("name", "C酱"); columnMap.put("age", 18); List<User> users1 = userMapper.selectByMap(columnMap); users1.forEach(System.out::println);
Page<User> page = new Page<>(1, 2); Page<User> userIPage = userMapper.selectPage(page, null); List<User> records = userIPage.getRecords(); records.forEach(System.out::println); }
|