1.用postman演示物理删除
数据直接删除成功,没有任何的逻辑校验,这种删除安全隐患很大,在实际开发采用较少
2.逻辑删除
2.1.在application.yml中配置全局逻辑删除规则
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto #主键自增
logic-delete-value: 1 #逻辑已删除值(默认为 1)
logic-not-delete-value: 0 #逻辑未删除值(默认为 0)
2.2.实体类字段上加上@TableLogic
注解
在CategoryEntity的showStatus字段上加注解
/**
* 是否显示[0-不显示,1显示]
*/
@TableLogic(value = "1",delval = "0")
private Integer showStatus;
详情请参考MP官网添加链接描述
3.用postman演示逻辑删除
控制台信息
2021-11-10 20:51:29.454 INFO 9644 --- [io-10000-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-11-10 20:51:29.464 DEBUG 9644 --- [io-10000-exec-1] c.a.g.p.dao.CategoryDao.deleteBatchIds : ==> Preparing: UPDATE pms_category SET show_status=0 WHERE cat_id IN ( ? ) AND show_status=1
2021-11-10 20:51:29.489 DEBUG 9644 --- [io-10000-exec-1] c.a.g.p.dao.CategoryDao.deleteBatchIds : ==> Parameters: 1431(Long)
2021-11-10 20:51:29.493 DEBUG 9644 --- [io-10000-exec-1] c.a.g.p.dao.CategoryDao.deleteBatchIds : <== Updates: 1
可以发送是update语句