Search in sources :

Example 1 with AbstractMethod

use of com.baomidou.mybatisplus.core.injector.AbstractMethod in project ballcat by ballcat-projects.

the class MybatisPlusConfig method customSqlInjector.

/**
 * 自定义批量插入方法注入
 * @return ISqlInjector
 */
@Bean
@ConditionalOnMissingBean(ISqlInjector.class)
public ISqlInjector customSqlInjector() {
    List<AbstractMethod> list = new ArrayList<>();
    // 对于只在更新时进行填充的字段不做插入处理
    list.add(new InsertBatchSomeColumnByCollection(t -> t.getFieldFill() != FieldFill.UPDATE));
    return new CustomSqlInjector(list);
}
Also used : ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) MetaObjectHandler(com.baomidou.mybatisplus.core.handlers.MetaObjectHandler) InsertBatchSomeColumnByCollection(com.hccake.extend.mybatis.plus.methods.InsertBatchSomeColumnByCollection) ISqlInjector(com.baomidou.mybatisplus.core.injector.ISqlInjector) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) CustomSqlInjector(com.hccake.extend.mybatis.plus.injector.CustomSqlInjector) DbType(com.baomidou.mybatisplus.annotation.DbType) ArrayList(java.util.ArrayList) Configuration(org.springframework.context.annotation.Configuration) MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) List(java.util.List) FieldFill(com.baomidou.mybatisplus.annotation.FieldFill) Bean(org.springframework.context.annotation.Bean) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) CustomSqlInjector(com.hccake.extend.mybatis.plus.injector.CustomSqlInjector) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) ArrayList(java.util.ArrayList) InsertBatchSomeColumnByCollection(com.hccake.extend.mybatis.plus.methods.InsertBatchSomeColumnByCollection) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with AbstractMethod

use of com.baomidou.mybatisplus.core.injector.AbstractMethod in project ballcat-codegen by ballcat-projects.

the class MybatisPlusConfig method customSqlInjector.

/**
 * 自定义批量插入方法注入
 * @return ISqlInjector
 */
@Bean
@ConditionalOnMissingBean(ISqlInjector.class)
public ISqlInjector customSqlInjector() {
    List<AbstractMethod> list = new ArrayList<>();
    // 对于只在更新时进行填充的字段不做插入处理
    list.add(new InsertBatchSomeColumnByCollection(t -> t.getFieldFill() != FieldFill.UPDATE));
    return new CustomSqlInjector(list);
}
Also used : Configuration(org.springframework.context.annotation.Configuration) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) List(java.util.List) InsertBatchSomeColumnByCollection(com.hccake.extend.mybatis.plus.methods.InsertBatchSomeColumnByCollection) ISqlInjector(com.baomidou.mybatisplus.core.injector.ISqlInjector) FieldFill(com.baomidou.mybatisplus.annotation.FieldFill) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) CustomSqlInjector(com.hccake.extend.mybatis.plus.injector.CustomSqlInjector) Bean(org.springframework.context.annotation.Bean) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) ArrayList(java.util.ArrayList) CustomSqlInjector(com.hccake.extend.mybatis.plus.injector.CustomSqlInjector) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) ArrayList(java.util.ArrayList) InsertBatchSomeColumnByCollection(com.hccake.extend.mybatis.plus.methods.InsertBatchSomeColumnByCollection) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with AbstractMethod

use of com.baomidou.mybatisplus.core.injector.AbstractMethod in project onex-boot by zhangchaoxu.

the class MySqlInjector method getMethodList.

@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
    List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
    // 增加自动填充逻辑删除
    methodList.add(new LogicDeleteByIdWithFill());
    methodList.add(new LogicDeleteBatchByIdsWithFill());
    methodList.add(new LogicDeleteByWrapperWithFill());
    methodList.add(new SelectCountById());
    return methodList;
}
Also used : SelectCountById(com.nb6868.onex.common.jpa.injector.methods.SelectCountById) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) LogicDeleteByWrapperWithFill(com.nb6868.onex.common.jpa.injector.methods.LogicDeleteByWrapperWithFill) LogicDeleteBatchByIdsWithFill(com.nb6868.onex.common.jpa.injector.methods.LogicDeleteBatchByIdsWithFill) LogicDeleteByIdWithFill(com.nb6868.onex.common.jpa.injector.methods.LogicDeleteByIdWithFill)

Example 4 with AbstractMethod

use of com.baomidou.mybatisplus.core.injector.AbstractMethod in project lamp-util by zuihou.

the class LampSqlInjector method getMethodList.

@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
    List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
    // 增加自定义方法
    methodList.add(new InsertBatchSomeColumn(i -> i.getFieldFill() != FieldFill.UPDATE));
    methodList.add(new UpdateAllById(field -> !ArrayUtil.containsAny(new String[] { SuperEntity.CREATE_TIME_COLUMN, SuperEntity.CREATED_BY_COLUMN }, field.getColumn())));
    return methodList;
}
Also used : List(java.util.List) TableInfo(com.baomidou.mybatisplus.core.metadata.TableInfo) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn) ArrayUtil(cn.hutool.core.util.ArrayUtil) FieldFill(com.baomidou.mybatisplus.annotation.FieldFill) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) SuperEntity(top.tangyh.basic.base.entity.SuperEntity) UpdateAllById(top.tangyh.basic.database.injector.method.UpdateAllById) DefaultSqlInjector(com.baomidou.mybatisplus.core.injector.DefaultSqlInjector) UpdateAllById(top.tangyh.basic.database.injector.method.UpdateAllById) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn)

Example 5 with AbstractMethod

use of com.baomidou.mybatisplus.core.injector.AbstractMethod in project albedo by somowhere.

the class LampSqlInjector method getMethodList.

@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
    List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
    // 增加自定义方法
    methodList.add(new InsertBatchSomeColumn(i -> i.getFieldFill() != FieldFill.UPDATE));
    methodList.add(new UpdateAllById(field -> !ArrayUtil.containsAny(new String[] { BaseDo.F_SQL_CREATED_DATE, BaseDo.F_SQL_CREATED_BY }, field.getColumn())));
    return methodList;
}
Also used : UpdateAllById(com.albedo.java.plugins.database.injector.method.UpdateAllById) List(java.util.List) TableInfo(com.baomidou.mybatisplus.core.metadata.TableInfo) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn) ArrayUtil(cn.hutool.core.util.ArrayUtil) FieldFill(com.baomidou.mybatisplus.annotation.FieldFill) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) BaseDo(com.albedo.java.common.core.basic.domain.BaseDo) DefaultSqlInjector(com.baomidou.mybatisplus.core.injector.DefaultSqlInjector) UpdateAllById(com.albedo.java.plugins.database.injector.method.UpdateAllById) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn)

Aggregations

AbstractMethod (com.baomidou.mybatisplus.core.injector.AbstractMethod)11 FieldFill (com.baomidou.mybatisplus.annotation.FieldFill)6 List (java.util.List)6 InsertBatchSomeColumn (com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn)5 DefaultSqlInjector (com.baomidou.mybatisplus.core.injector.DefaultSqlInjector)4 TableInfo (com.baomidou.mybatisplus.core.metadata.TableInfo)4 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)3 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)3 Bean (org.springframework.context.annotation.Bean)3 Configuration (org.springframework.context.annotation.Configuration)3 ArrayUtil (cn.hutool.core.util.ArrayUtil)2 ISqlInjector (com.baomidou.mybatisplus.core.injector.ISqlInjector)2 SelectById (com.baomidou.mybatisplus.core.injector.methods.SelectById)2 AlwaysUpdateSomeColumnById (com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById)2 DeleteAll (com.baomidou.mybatisplus.samples.deluxe.methods.DeleteAll)2 MyInsertAll (com.baomidou.mybatisplus.samples.deluxe.methods.MyInsertAll)2 MysqlInsertAllBatch (com.baomidou.mybatisplus.samples.deluxe.methods.MysqlInsertAllBatch)2 DeleteAll (com.baomidou.samples.injector.methods.DeleteAll)2 CustomSqlInjector (com.hccake.extend.mybatis.plus.injector.CustomSqlInjector)2 InsertBatchSomeColumnByCollection (com.hccake.extend.mybatis.plus.methods.InsertBatchSomeColumnByCollection)2