mybatis plus邏輯刪除

2021-10-07 08:04:29 字數 954 閱讀 3071

1.先在資料庫加delete_status欄位,還有實體類加deletestatus欄位(你試試實體類加delete_status,會有問題,預設是駝峰),這就是告訴spring,我要把這欄位設為刪除標誌

@tablelogic//邏輯刪除

private integer deleted;

2.在3.1.1版本之前需要在自己寫的配置類中配置,後續版本直接跳過,spring幫著配好了

@configuration

public

class

myconfig

}

#邏輯刪除配置

mybatis-plus.global-config.db-config.logic-

delete

-value=

1mybatis-plus.global-config.db-config.logic-not-

delete

-value=

0

4.測試

//測試刪除

@test

public

void

deletetest()

結果,其實是更新,把deleted=0設為1,查詢時只查為零的資料

==

> preparing:

update user set deleted=

1where id=

?and deleted=0==

> parameters:

1271075432286806022

(long)

<=

= updates:

1

mybatis plus 邏輯刪除

整合步驟 1 匯入依賴 2 配置 資料來源 驅動 鏈結資訊 spring datasource username root password root url jdbc mysql driver class name com.mysql.cj.jdbc.driver name gulimall pr...

MybatisPlus邏輯刪除

新增 deleted欄位 altertable user add column deleted boolean default false新增deleted 字段,並加上 tablelogic 註解 tablelogic private integer deleted mybatis plus.gl...

mybatisplus邏輯刪除

springboot 配置方式 mybatis plus global config db config logic delete value 1 邏輯已刪除值 預設為 1 logic not delete value 0 邏輯未刪除值 預設為 0 註冊 bean import com.baomid...