• 执行逻辑删除后的查询,sql语句会自动添加 逻辑删除字段的判断。当逻辑删除的字段 deleted =0(即未被删除) 才能被查到。 ```java package com.wzy.bootmtp.test;

    import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wzy.bootmtp.mapper.UserMapper; import com.wzy.bootmtp.pojo.User; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;

    import java.util.Arrays; import java.util.List; import java.util.Map;

    @RunWith(SpringRunner.class) @SpringBootTest public class TestSpringBoot {

    1. @Autowired
    2. private UserMapper userMapper;
    3. @Test
    4. public void test3(){
    5. //逻辑删除
    6. int result = userMapper.deleteById(6);
    7. System.out.println(result);
    8. //查询
    9. List<User> users = userMapper.selectList(null);
    10. users.forEach(user -> System.out.println("user"));
    11. }

    }

    ``` 输出结果与表中数据对比:

    • 执行逻辑删除后的查询,sql语句会自动添加 逻辑删除字段的判断。当逻辑删除的字段 deleted =0 才能被查到。

    image.png
    image.png