/**

  • @author beth

  • @data 2019-10-17 00:30*/@RunWith(SpringRunner.class)@SpringBootTestpublic class DeleteTest {@Autowiredprivate UserInfoMapper userInfoMapper;

    /**

    • 根据id删除*/@Testpublic void deleteById() {int rows = userInfoMapper.deleteById(123455);System.out.println("影响记录数:"+rows);}

    /**

    • 根据条件删除*/@Testpublic void deleteBy() {Map<String,Object> coumnMap = new HashMap<>();coumnMap.put("username","肖娟");coumnMap.put("age",22);int rows = userInfoMapper.deleteByMap(coumnMap);System.out.println("影响记录数:"+rows);}

    /**

    • 批量删除*/@Testpublic void deleteBatchIds() {int rows = userInfoMapper.deleteBatchIds(Arrays.asList(123,335,54656));System.out.println("影响记录数:"+rows);}

    /**

    • 根据条件删除,使用lambda*/@Testpublic void deleteByWrapper() {LambdaUpdateWrapper<UserInfo> lambdaUpdateWrapper = Wrappers.<UserInfo> lambdaUpdate();lambdaUpdateWrapper.eq(UserInfo::getUsername,"肖姐").eq(UserInfo::getAge,30).set(UserInfo::getAge,11);int rows = userInfoMapper.delete(lambdaUpdateWrapper);System.out.println("影响记录数:"+rows);}

}

10-17 12:46