邯城往事

>>> 展颜笑夙愿,一笑泯恩仇 <<<

目录
mybatis-plus相关设置
/  

mybatis-plus相关设置

逻辑删除配置

yml配置

mybatis-plus:
  global-config:
    db-config:
      logic-delete-value: 1 # 逻辑已删除值(默认为 1)
      logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)

添加逻辑删除拦截器

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class MyBatisPlusConfiguration {
 
    @Bean
    public ISqlInjector sqlInjector() {
        return new LogicSqlInjector();
    }
}

实体类字段上加上@TableLogic注解

@TableLogic
private Integer delState;

控制台打印sql

logging:  
level: 
com.dy.springboot.server.mapper: DEBUG
评论
取消