Mybatis Plus刪除

/**app

  • @author beth.net

  • @data 2019-10-17 00:30 */ @RunWith(SpringRunner.class) @SpringBootTest public class DeleteTest { @Autowired private UserInfoMapper userInfoMapper;get

    /**it

    • 根據id刪除 */ @Test public void deleteById() { int rows = userInfoMapper.deleteById(123455); System.out.println("影響記錄數:"+rows); }

    /**class

    • 根據條件刪除 */ @Test public void deleteBy() { Map<String,Object> coumnMap = new HashMap<>(); coumnMap.put("username","肖娟"); coumnMap.put("age",22); int rows = userInfoMapper.deleteByMap(coumnMap); System.out.println("影響記錄數:"+rows); }

    /**lambda

    • 批量刪除 */ @Test public void deleteBatchIds() { int rows = userInfoMapper.deleteBatchIds(Arrays.asList(123,335,54656)); System.out.println("影響記錄數:"+rows); }

    /**date

    • 根據條件刪除,使用lambda */ @Test public 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); }

}List

相關文章
相關標籤/搜索