逻辑删除
解释:在数据库中没有被移除,而是通过一个变量来让他失效! deleted=0→deleted=1
1.添加数据库字段
2.实体类上加入属性
/逻辑删除
@TableLogic
private Integer deleted;
3.添加配置
//注册逻辑删除
@Bean
public ISqlInjector sqlInjector(){
return new LogicSqlInjector();
}
4.springboot配置
# 配置逻辑删除
mybatis-plus.global-config.db-config.logic-delete-value=1
mybatis-plus.global-config.db-config.logic-not-delete-value=0
5.测试
@Test
public void delteTest(){
int i = userMapper.deleteById(1440247717122842671L);
}