Search in sources :

Example 1 with CustomSqlInjector

use of com.hccake.extend.mybatis.plus.injector.CustomSqlInjector 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 CustomSqlInjector

use of com.hccake.extend.mybatis.plus.injector.CustomSqlInjector 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)

Aggregations

FieldFill (com.baomidou.mybatisplus.annotation.FieldFill)2 AbstractMethod (com.baomidou.mybatisplus.core.injector.AbstractMethod)2 ISqlInjector (com.baomidou.mybatisplus.core.injector.ISqlInjector)2 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)2 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)2 CustomSqlInjector (com.hccake.extend.mybatis.plus.injector.CustomSqlInjector)2 InsertBatchSomeColumnByCollection (com.hccake.extend.mybatis.plus.methods.InsertBatchSomeColumnByCollection)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 Bean (org.springframework.context.annotation.Bean)2 Configuration (org.springframework.context.annotation.Configuration)2 DbType (com.baomidou.mybatisplus.annotation.DbType)1 MetaObjectHandler (com.baomidou.mybatisplus.core.handlers.MetaObjectHandler)1