use of com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById in project mybatis-plus-samples by baomidou.
the class MybatisPlusConfig method globalConfig.
@Bean
public GlobalConfig globalConfig() {
GlobalConfig conf = new GlobalConfig();
conf.setDbConfig(new GlobalConfig.DbConfig().setColumnFormat("`%s`"));
DefaultSqlInjector logicSqlInjector = new DefaultSqlInjector() {
/**
* 注入自定义全局方法
*/
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
// 不要逻辑删除字段, 不要乐观锁字段, 不要填充策略是 UPDATE 的字段
methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete() && !t.isVersion() && t.getFieldFill() != FieldFill.UPDATE));
// 不要填充策略是 INSERT 的字段, 不要字段名是 column4 的字段
methodList.add(new AlwaysUpdateSomeColumnById(t -> t.getFieldFill() != FieldFill.INSERT && !t.getProperty().equals("column4")));
return methodList;
}
};
conf.setSqlInjector(logicSqlInjector);
return conf;
}
use of com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById in project mybatis-plus-samples by baomidou.
the class MySqlInjector method getMethodList.
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
// 增加自定义方法
methodList.add(new DeleteAll());
methodList.add(new FindOne());
/**
* 以下 3 个为内置选装件
* 头 2 个支持字段筛选函数
*/
// 例: 不要指定了 update 填充的字段
methodList.add(new InsertBatchSomeColumn(i -> i.getFieldFill() != FieldFill.UPDATE));
methodList.add(new AlwaysUpdateSomeColumnById());
methodList.add(new LogicDeleteByIdWithFill());
return methodList;
}
Aggregations