1、数据库添加逻辑删除字段 deleted,类型int,默认0,0为未删除。
2、实体类添加属性 deleted,并用注解@TableLogin
@TableLogic private Integer deleted;
3、配置yml文件(一定要在mybatis-plus下)
mybatis-plus:
global-config:
db-config:
logic-not-delete-value: 0
logic-delete-value: 1
结果:删除操作数据库实际为更新操作,把deleted由0变成1.
再执行查询操作,此条数据不在显示