Search in sources :

Example 1 with InsertBatchSomeColumn

use of com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn 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 2 with InsertBatchSomeColumn

use of com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn 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)

Example 3 with InsertBatchSomeColumn

use of com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn 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;
}
Also used : OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) GlobalConfig(com.baomidou.mybatisplus.core.config.GlobalConfig) MapperScan(org.mybatis.spring.annotation.MapperScan) Configuration(org.springframework.context.annotation.Configuration) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) MybatisConfiguration(com.baomidou.mybatisplus.core.MybatisConfiguration) MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) List(java.util.List) TableInfo(com.baomidou.mybatisplus.core.metadata.TableInfo) MybatisMapWrapperFactory(com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory) SqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory) DataSource(javax.sql.DataSource) FieldFill(com.baomidou.mybatisplus.annotation.FieldFill) AlwaysUpdateSomeColumnById(com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById) JdbcType(org.apache.ibatis.type.JdbcType) Bean(org.springframework.context.annotation.Bean) DefaultSqlInjector(com.baomidou.mybatisplus.core.injector.DefaultSqlInjector) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) GlobalConfig(com.baomidou.mybatisplus.core.config.GlobalConfig) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) DefaultSqlInjector(com.baomidou.mybatisplus.core.injector.DefaultSqlInjector) TableInfo(com.baomidou.mybatisplus.core.metadata.TableInfo) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn) AlwaysUpdateSomeColumnById(com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById) MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with InsertBatchSomeColumn

use of com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn 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;
}
Also used : FindOne(com.baomidou.samples.injector.methods.FindOne) List(java.util.List) TableInfo(com.baomidou.mybatisplus.core.metadata.TableInfo) FindOne(com.baomidou.samples.injector.methods.FindOne) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn) FieldFill(com.baomidou.mybatisplus.annotation.FieldFill) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) AlwaysUpdateSomeColumnById(com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById) LogicDeleteByIdWithFill(com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill) DeleteAll(com.baomidou.samples.injector.methods.DeleteAll) DefaultSqlInjector(com.baomidou.mybatisplus.core.injector.DefaultSqlInjector) DeleteAll(com.baomidou.samples.injector.methods.DeleteAll) AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn) LogicDeleteByIdWithFill(com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill) AlwaysUpdateSomeColumnById(com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById)

Example 5 with InsertBatchSomeColumn

use of com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn in project smart-cloud by smart-cloud.

the class SmartSqlInjector method getMethodList.

@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
    List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
    // 添加in-line式批量插入
    methodList.add(new InsertBatchSomeColumn());
    methodList.add(new Truncate(TRUNCATE_METHOD_NAME));
    return methodList;
}
Also used : AbstractMethod(com.baomidou.mybatisplus.core.injector.AbstractMethod) Truncate(org.smartframework.cloud.starter.mybatis.plus.injector.methods.Truncate) InsertBatchSomeColumn(com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn)

Aggregations

AbstractMethod (com.baomidou.mybatisplus.core.injector.AbstractMethod)5 InsertBatchSomeColumn (com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn)5 FieldFill (com.baomidou.mybatisplus.annotation.FieldFill)4 DefaultSqlInjector (com.baomidou.mybatisplus.core.injector.DefaultSqlInjector)4 TableInfo (com.baomidou.mybatisplus.core.metadata.TableInfo)4 List (java.util.List)4 ArrayUtil (cn.hutool.core.util.ArrayUtil)2 AlwaysUpdateSomeColumnById (com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById)2 BaseDo (com.albedo.java.common.core.basic.domain.BaseDo)1 UpdateAllById (com.albedo.java.plugins.database.injector.method.UpdateAllById)1 MybatisConfiguration (com.baomidou.mybatisplus.core.MybatisConfiguration)1 GlobalConfig (com.baomidou.mybatisplus.core.config.GlobalConfig)1 MybatisMapWrapperFactory (com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory)1 LogicDeleteByIdWithFill (com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill)1 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)1 OptimisticLockerInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor)1 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)1 MybatisSqlSessionFactoryBean (com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean)1 DeleteAll (com.baomidou.samples.injector.methods.DeleteAll)1 FindOne (com.baomidou.samples.injector.methods.FindOne)1