mybatisPlus-更新和删除数据
根据id更新
@Test public void updateUser(){ User user = new User(); user.setId(2L); user.setName("jackson"); int update = userMapper.updateById(user); System.out.println(update); }
@Test public void updateUser(){ User user = new User(); user.setName("jack"); QueryWrapper<User> queryWrapper = new QueryWrapper<>(); queryWrapper.like("NAME","ck");//模糊匹配%xx% int update = userMapper.update(user,queryWrapper); System.out.println(update); }
删除数据
@Test public void delBatchUser(){ int i = userMapper.deleteById(3L); System.out.println(i); }