Skip to content

Commit

Permalink
refactor: mybatis plus plugin supported page
Browse files Browse the repository at this point in the history
  • Loading branch information
wtt40122 committed Sep 3, 2024
1 parent e760c77 commit 224272a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author shanwb
* @date 2022-09-13
*/
@DOceanPlugin(order = Integer.MAX_VALUE)
@DOceanPlugin(order = Integer.MAX_VALUE - 2)
@Slf4j
public class ConfigurationPlugin implements IPlugin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -47,7 +49,7 @@
/**
* @author [email protected]
*/
@DOceanPlugin
@DOceanPlugin(order = Integer.MAX_VALUE - 1)
@Slf4j
public class MybatisPlugin implements IPlugin {

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 224272a

Please sign in to comment.