From 7e0fb6cb56901e6c0820c428784231e26acb4595 Mon Sep 17 00:00:00 2001 From: wangzhs Date: Sun, 12 Mar 2023 17:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Mybaits=20Plus=20Join?= =?UTF-8?q?=E7=9A=84SQL=E6=B3=A8=E5=85=A5=E5=99=A8=E5=88=B0YudaoMybatisAut?= =?UTF-8?q?oConfiguration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/MybatisPlusJoinConfiguration.java | 19 ------------------- .../config/YudaoMybatisAutoConfiguration.java | 7 +++++++ 2 files changed, 7 insertions(+), 19 deletions(-) delete mode 100644 yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/MybatisPlusJoinConfiguration.java diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/MybatisPlusJoinConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/MybatisPlusJoinConfiguration.java deleted file mode 100644 index 63529ca20..000000000 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/MybatisPlusJoinConfiguration.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.framework.mybatis.config; - -import com.baomidou.mybatisplus.core.injector.AbstractMethod; -import com.baomidou.mybatisplus.core.metadata.TableInfo; -import icu.mhb.mybatisplus.plugln.injector.JoinDefaultSqlInjector; -import org.springframework.context.annotation.Configuration; - -import java.util.List; - -// TODO @升平:是不是作为 YudaoMybatisAutoConfiguration 的 bean 即可呀?然后 getMethodList 不用重写 -@Configuration -public class MybatisPlusJoinConfiguration extends JoinDefaultSqlInjector { - - @Override - public List getMethodList(Class mapperClass, TableInfo tableInfo) { - return super.getMethodList(mapperClass, tableInfo); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java index 78ee259c8..0c040013f 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java @@ -5,12 +5,14 @@ import cn.iocoder.yudao.framework.mybatis.core.handler.DefaultDBFieldHandler; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator; +import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; import com.baomidou.mybatisplus.extension.incrementer.H2KeyGenerator; import com.baomidou.mybatisplus.extension.incrementer.KingbaseKeyGenerator; import com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator; import com.baomidou.mybatisplus.extension.incrementer.PostgreKeyGenerator; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import icu.mhb.mybatisplus.plugln.injector.JoinDefaultSqlInjector; import org.apache.ibatis.annotations.Mapper; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -40,6 +42,11 @@ public class YudaoMybatisAutoConfiguration { return new DefaultDBFieldHandler(); // 自动填充参数类 } + @Bean + public DefaultSqlInjector defaultSqlInjector() { + return new JoinDefaultSqlInjector(); // 使用Mybaits Plus Join定义的SQL注入器 + } + @Bean @ConditionalOnProperty(prefix = "mybatis-plus.global-config.db-config", name = "id-type", havingValue = "INPUT") public IKeyGenerator keyGenerator(ConfigurableEnvironment environment) {