1、根据ID删除一个员工deleteById

1 /** 2 * 删除客户 3 * 4 * @throws SQLException 5 */ 6 @Test 7 public void deletedMethod() throws SQLException { 8 9 // 1.根据ID删除一个员工 10 Integer result = employeeMapper.deleteById(1); 11 12 if (result != null || result > 0) { 13 logger.info("++++++++++++++++删除成功+++++"); 14 } 15 16 }
2、根据多个ID删除多个员工

1 /** 2 * 删除客户 3 * 4 * @throws SQLException 5 */ 6 @Test 7 public void deletedMethod() throws SQLException { 8 9 10 // 2.多个ID删除 11 List<Integer> idList = new ArrayList<>(); 12 idList.add(21); 13 idList.add(20); 14 15 Integer result = employeeMapper.deleteBatchIds(idList); 16 17 18 if (result != null || result > 0) { 19 logger.info("++++++++++++++++删除成功+++++"); 20 } 21 22 }
3、根据map条件删除

1 /** 2 * 删除客户 3 * 4 * @throws SQLException 5 */ 6 @Test 7 public void deletedMethod() throws SQLException { 8 9 // 3.根据map条件删除 10 Employee employee = employeeMapper.selectById(19); 11 12 Map<String, Object> map = new HashMap<>(16); 13 map.put("email", employee.getEmail()); 14 map.put("age", employee.getAge()); 15 16 Integer result = employeeMapper.deleteByMap(map); 17 18 if (result != null || result > 0) { 19 logger.info("++++++++++++++++删除成功+++++"); 20 } 21 22 }
4、根据条件构造器删除

1 /** 2 * 删除客户 3 * 4 * @throws SQLException 5 */ 6 @Test 7 public void deletedMethod() throws SQLException { 8 9 // 4.根据条件构造器删除 10 Integer result = employeeMapper.delete(new QueryWrapper<Employee>() 11 .eq("gender", 1)); 12 13 if (result != null || result > 0) { 14 logger.info("++++++++++++++++删除成功+++++"); 15 }