forked from lilishop/lilishop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cbbc57
commit 950274f
Showing
10 changed files
with
136 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cn.lili.mybatis.mybatisplus; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author paulG | ||
* @since 2022/7/18 | ||
**/ | ||
public interface SpiceBaseMapper<T> { | ||
|
||
/** | ||
* 批量插入 | ||
* {@link com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn} | ||
* | ||
* @param entityList 要插入的数据 | ||
* @return 成功插入的数据条数 | ||
*/ | ||
long insertBatchSomeColumn(List<T> entityList); | ||
} |
33 changes: 33 additions & 0 deletions
33
framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cn.lili.mybatis.mybatisplus; | ||
|
||
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; | ||
|
||
/** | ||
* @author paulG | ||
* @since 2022/7/18 | ||
**/ | ||
@Component | ||
public class SpiceSqlInjector extends DefaultSqlInjector { | ||
|
||
/** | ||
* 如果只需增加方法,保留mybatis plus自带方法, | ||
* 可以先获取super.getMethodList(),再添加add | ||
*/ | ||
@Override | ||
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) { | ||
// 注意:此SQL注入器继承了DefaultSqlInjector(默认注入器),调用了DefaultSqlInjector的getMethodList方法,保留了mybatis-plus的自带方法 | ||
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo); | ||
// 注入InsertBatchSomeColumn | ||
// 在!t.isLogicDelete()表示不要逻辑删除字段,!"update_time".equals(t.getColumn())表示不要字段名为 update_time 的字段,不对进行操作 | ||
// methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete() && !"update_time".equals(t.getColumn()))); | ||
// 要逻辑删除 t.isLogicDelete() 默认不要 | ||
methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete())); | ||
return methodList; | ||
} | ||
} |