1.在逻辑删除字段上添加@TableLogic注解
@ApiModelProperty(value = "状态:0未删除,1已删除")
@TableLogic(value = "0",delval = "1")
private Integer isDeleted;
或者在yml文件中全局配置逻辑删除字段
##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.在MpConfig配置类中添加逻辑删除的Bean
@Configuration
public class MpConfig {
/**
* 逻辑删除插件
* @return
*/
@Bean
public ISqlInjector iSqlInjector(){
return new LogicSqlInjector();
}
}
标签:逻辑,mybatisPlus,删除,global,value,mybatis,config
From: https://www.cnblogs.com/blog-zyx/p/17016891.html