方法

1
2
3
4
5
6
7
8
// 根据 entity 条件,删除记录
int delete(@Param(Constants.WRAPPER) Wrapper<T> wrapper);
// 删除(根据ID 批量删除)
int deleteBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);
// 根据 ID 删除
int deleteById(Serializable id);
// 根据 columnMap 条件,删除记录
int deleteByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);

测试代码

delete

1
2
3
4
5
6
@Test
void delete() {
QueryWrapper<BlogType> blogTypeQueryWrapper = new QueryWrapper<>();
blogTypeQueryWrapper.eq("name", "spring");
blogTypeMapper.delete(blogTypeQueryWrapper);
}

deleteBatchIds

1
2
3
4
5
6
7
8
9
@Test
void deleteBatchIds() {
List<Integer> idList = new ArrayList<>();
idList.add(29);
idList.add(30);
idList.add(31);
int result = blogTypeMapper.deleteBatchIds(idList);
System.out.println(result);
}

deleteById

1
2
3
4
5
@Test
void deleteById() {
int result = blogTypeMapper.deleteById(32);
System.out.println(result);
}

deleteByMap

1
2
3
4
5
6
7
8
@Test
void deleteByMap() {
Map<String, Object> map = new HashMap<>(16);
map.put("name", 1);
map.put("sortNum", 2);
int result = blogTypeMapper.deleteByMap(map);
System.out.println(result);
}