mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
refactor: 继承 NullableColumnLogicDeleteProcessor 减少代码量。
This commit is contained in:
parent
206f4a080b
commit
fb3d2e6012
@ -16,11 +16,7 @@
|
||||
|
||||
package com.mybatisflex.core.logicdelete.impl;
|
||||
|
||||
import com.mybatisflex.core.dialect.IDialect;
|
||||
import com.mybatisflex.core.logicdelete.AbstractLogicDeleteProcessor;
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.table.TableInfo;
|
||||
import com.mybatisflex.core.logicdelete.NullableColumnLogicDeleteProcessor;
|
||||
|
||||
/**
|
||||
* {@link java.time.LocalDateTime} 类型的属性对应的逻辑删除处理器。
|
||||
@ -28,26 +24,7 @@ import com.mybatisflex.core.table.TableInfo;
|
||||
* @author 王帅
|
||||
* @since 2023-06-20
|
||||
*/
|
||||
public class DateTimeLogicDeleteProcessor extends AbstractLogicDeleteProcessor {
|
||||
|
||||
@Override
|
||||
public String buildLogicNormalCondition(String logicColumn, TableInfo tableInfo, IDialect dialect) {
|
||||
return dialect.wrap(logicColumn) + " IS NULL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildQueryCondition(QueryWrapper queryWrapper, TableInfo tableInfo) {
|
||||
QueryColumn queryColumn = new QueryColumn(tableInfo.getSchema(), tableInfo.getTableName(), tableInfo.getLogicDeleteColumn());
|
||||
queryWrapper.and(queryColumn.isNull());
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除字段值为 {@code null} 表示数据未删除。
|
||||
*/
|
||||
@Override
|
||||
public Object getLogicNormalValue() {
|
||||
return null;
|
||||
}
|
||||
public class DateTimeLogicDeleteProcessor extends NullableColumnLogicDeleteProcessor {
|
||||
|
||||
/**
|
||||
* 逻辑删除字段值为 {@code NOW()} 表示数据删除,并记录删除时间。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user