物理删除:真实删除,将对应数据从数据库中删除,之后查询不到此条被删除数据

    1、根据id删除记录,

    1. package com.wzy.bootmtp.test;
    2. import com.baomidou.mybatisplus.core.metadata.IPage;
    3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
    4. import com.wzy.bootmtp.mapper.UserMapper;
    5. import com.wzy.bootmtp.pojo.User;
    6. import org.junit.Test;
    7. import org.junit.runner.RunWith;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.boot.test.context.SpringBootTest;
    10. import org.springframework.test.context.junit4.SpringRunner;
    11. import java.util.Map;
    12. @RunWith(SpringRunner.class)
    13. @SpringBootTest
    14. public class TestSpringBoot {
    15. @Autowired
    16. private UserMapper userMapper;
    17. @Test
    18. public void testDeleteById(){
    19. int result = userMapper.deleteById(2L);
    20. System.out.println(result);
    21. }
    22. }

    2、批量删除

    1. package com.wzy.bootmtp.test;
    2. import com.baomidou.mybatisplus.core.metadata.IPage;
    3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
    4. import com.wzy.bootmtp.mapper.UserMapper;
    5. import com.wzy.bootmtp.pojo.User;
    6. import org.junit.Test;
    7. import org.junit.runner.RunWith;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.boot.test.context.SpringBootTest;
    10. import org.springframework.test.context.junit4.SpringRunner;
    11. import java.util.Arrays;
    12. import java.util.Map;
    13. @RunWith(SpringRunner.class)
    14. @SpringBootTest
    15. public class TestSpringBoot {
    16. @Autowired
    17. private UserMapper userMapper;
    18. @Test
    19. public void testDeleteBatchIds() {
    20. int result = userMapper.deleteBatchIds(Arrays.asList(4, 5, 6));
    21. System.out.println(result);
    22. }
    23. }