mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
doc: 添加多种字段类型的逻辑删除处理器使用文档。
This commit is contained in:
parent
75bd9799d4
commit
afd043051e
@ -126,8 +126,25 @@ LogicDeleteManager.execWithoutLogicDelete(() ->
|
||||
accountMapper.deleteById(1)
|
||||
);
|
||||
```
|
||||
|
||||
以上代码中,`accountMapper` 会直接对 `Account` 数据进行物理删除,忽略逻辑删除字段配置。
|
||||
|
||||
## 内置逻辑删除处理器
|
||||
|
||||
MyBatis-Flex 提供了三种字段类型对应的逻辑删除处理器,用户可以根据逻辑删除字段的类型进行设置,它们分别是:
|
||||
|
||||
| 处理器名称 | 对应字段类型 | 数据正常时的值 | 数据被删除时的值 |
|
||||
|------------------------------|----------|---------|----------|
|
||||
| IntegerLogicDeleteProcessor | integer | 0 | 1 |
|
||||
| BooleanLogicDeleteProcessor | tinyint | false | true |
|
||||
| DateTimeLogicDeleteProcessor | datetime | null | 被删除时间 |
|
||||
|
||||
使用时,只需通过 `LogicDeleteManager` 来设置逻辑删除处理器即可,例如:
|
||||
|
||||
```java
|
||||
LogicDeleteManager.setProcessor(new DateTimeLogicDeleteProcessor);
|
||||
```
|
||||
|
||||
## 自定义逻辑删除处理功能
|
||||
|
||||
在社区中,有许多用户提出希望使用时间类型,当删除时,设置删除字段为`当前时间`,当正常时,设置为 `0` 或者 `null`。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user