mybatis-plus 逻辑删除
一、参考地址
https://mp.baomidou.com/guide/logic-delete.html#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95%EF%BC%9A
逻辑删除对比物理删除
一直在用,确不知道此方法是逻辑删除
二、过程
1、添加字段 isdel
= 1 为 逻辑删除
= 0 为 正常
2、实体类
添加属性
package com.wt.pojo; import com.baomidou.mybatisplus.annotation.*; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; @Data @AllArgsConstructor @NoArgsConstructor public class User { private Long id; private String name; private Integer age; private String email; private int isdel; @Version private Integer version; @TableField(fill = FieldFill.INSERT) private Date createTime; @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; }
3、application.yaml
#开启日志
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 逻辑删除
global-config:
db-config:
logic-delete-field: isdel
logic-delete-value: 1
logic-not-delete-value: 0
4、测试
a、删除一个数据(显示为更新操作)
b、查找删除的数据(结果显示为null)