| | |
| | | package com.yuanchu.limslaboratory.mybatis_config; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 批量添加 |
| | | */ |
| | | @Component |
| | | public class MySqlInjector extends DefaultSqlInjector { |
| | | |
| | | @Override |
| | | public List<AbstractMethod> getMethodList(Class<?> mapperClass) { |
| | | List<AbstractMethod> methodList = super.getMethodList(mapperClass); |
| | | public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) { |
| | | List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo); |
| | | //增加自定义方法,字段注解上不等于FieldFill.DEFAULT的字段才会插入 |
| | | methodList.add(new InsertBatchSomeColumn(i -> i.getFieldFill() != FieldFill.DEFAULT)); |
| | | methodList.add(new InsertBatchSomeColumn(t->!t.isLogicDelete())); |
| | | return methodList; |
| | | } |
| | | |
| | | } |