mybatis-plus配置逻辑删除

springboot整合mybatis-plus

<dependency>
   <groupId>com.baomidou</groupId>
   <artifactId>mybatis-plus-boot-starter</artifactId>
   <version>${mybatis.plus.boot.starter}</version>
</dependency>

1、application.properties 添加一下配置

#逻辑删除配置
mybatis-plus.global-config.sql-injector=com.baomidou.mybatisplus.mapper.LogicSqlInjector
#配置逻辑删除字段为1是删除
mybatis-plus.global-config.logic-delete-value=1
#配置逻辑删除字段为0是未删除
mybatis-plus.global-config.logic-not-delete-value=0

2、实体类添加注解,标记该字段为逻辑删除字段

@TableLogic
    protected Integer isDel = 0; //0:正常 1:删除

3、然后调用mybatis-plus的delete相关方法即是逻辑删除

猜你喜欢

转载自blog.csdn.net/zsj777/article/details/80800333