delete删除的三种方法
一、根据 id 删除
@Test
void deleteById(Integer id) {
empMapper.deleteById(new Emp().getId());
empMapper.deleteById(id);
}
二、根据 id 多条删除
@Test
void deleteList(List<Integer> list) {
empMapper.deleteBatchIds(list);
}
三、条件构造器 删除
@Test
void delete(参数) {
LambdaQueryWrapper<Emp> queryWrapper = new LambdaQueryWrapper<>();
// 进行条件删除
queryWrapper.eq();
// 删除相关条件
empMapper.delete(queryWrapper);
}
四、多条件删除
@Test
void deleteMap(Map<String, Object> param) {
QueryWrapper<Emp> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name", param.getName);
empMapper.deleteByMap(param);
}
标签:queryWrapper,删除,void,empMapper,Plus,Test,MyBatis,id
From: https://www.cnblogs.com/wywbo/p/17472021.html