W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
說(shuō)明:
只對(duì)自動(dòng)注入的 sql 起效:
where
條件過(guò)濾掉已刪除數(shù)據(jù),且使用 ?wrapper.entity
? 生成的 where 條件會(huì)忽略該字段where
條件防止更新到已刪除數(shù)據(jù),且使用 wrapper.entity 生成的 where 條件會(huì)忽略該字段例如:
update user set deleted=1 where id = 1 and deleted=0
?select id,name,deleted from user where deleted=0
?字段類(lèi)型支持說(shuō)明:
Integer
?,?Boolean
?,?LocalDateTime
?)datetime
?,邏輯未刪除值和已刪除值支持配置為字符串?null
?,另一個(gè)值支持配置為函數(shù)來(lái)獲取值如?now()
?附錄:
com.baomidou.mybatisplus.core.config.GlobalConfig$DbConfig
?例如: ?application.yml
?
mybatis-plus:
global-config:
db-config:
logic-delete-field: flag # 全局邏輯刪除的實(shí)體字段名(since 3.3.0,配置后可以忽略不配置步驟2)
logic-delete-value: 1 # 邏輯已刪除值(默認(rèn)為 1)
logic-not-delete-value: 0 # 邏輯未刪除值(默認(rèn)為 0)
@TableLogic
?注解@TableLogic
private Integer deleted;
insert
前自己 ?set
值
update
方法并: ?UpdateWrapper.set(column, value)
?(推薦)
update
方法并: ?UpdateWrapper.setSql("column=value")
?com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill
? 并使用(推薦)Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: