-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: mybatis plus plugin supported page
- Loading branch information
Showing
2 changed files
with
9 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package com.xiaomi.youpin.docean.plugin.mybatisplus; | ||
|
||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | ||
import com.xiaomi.youpin.docean.Aop; | ||
import com.xiaomi.youpin.docean.Ioc; | ||
import com.xiaomi.youpin.docean.anno.DOceanPlugin; | ||
|
@@ -33,6 +34,7 @@ | |
import org.apache.ibatis.plugin.Interceptor; | ||
import org.apache.ibatis.session.SqlSession; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import javax.sql.DataSource; | ||
import java.lang.reflect.InvocationHandler; | ||
|
@@ -47,7 +49,7 @@ | |
/** | ||
* @author [email protected] | ||
*/ | ||
@DOceanPlugin | ||
@DOceanPlugin(order = Integer.MAX_VALUE - 1) | ||
@Slf4j | ||
public class MybatisPlugin implements IPlugin { | ||
|
||
|
@@ -93,6 +95,11 @@ private void addDAO(Ioc ioc, String beanName, String mapperLocation, boolean one | |
bean.setPlugins(new Interceptor[]{interceptor}); | ||
} | ||
|
||
Set<MybatisPlusInterceptor> plusInterceptors = ioc.getBeans(MybatisPlusInterceptor.class); | ||
if (!CollectionUtils.isEmpty(plusInterceptors)) { | ||
bean.setPlugins(plusInterceptors.toArray(new Interceptor[]{})); | ||
} | ||
|
||
SqlSessionFactory factory = bean.buildSqlSessionFactory(); | ||
|
||
ioc.putBean("mybatis_" + beanName + config.getName(), factory); | ||
|