diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index caef2d31c..74083bcbe 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -26,7 +26,7 @@ 3.5.3.1 3.5.3.1 3.6.1 - 1.3.4 + 1.4.3.1 3.18.0 2.2.3 @@ -211,9 +211,9 @@ - icu.mhb - mybatis-plus-join - ${mybatis-plus-join.version} + com.github.yulichang + mybatis-plus-join-boot-starter + ${mybatis-plus-join-boot-starter.version} diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml b/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml index 3bfa86871..4424c72b6 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml @@ -60,8 +60,8 @@ - icu.mhb - mybatis-plus-join + com.github.yulichang + mybatis-plus-join-boot-starter 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 0c040013f..78ee259c8 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,14 +5,12 @@ 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; @@ -42,11 +40,6 @@ 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) { diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java index 2a7a828df..9819bf551 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.toolkit.Db; -import icu.mhb.mybatisplus.plugln.base.mapper.JoinBaseMapper; +import com.github.yulichang.base.MPJBaseMapper; import org.apache.ibatis.annotations.Param; import java.util.Collection; @@ -17,10 +17,10 @@ import java.util.List; /** * 在 MyBatis Plus 的 BaseMapper 的基础上拓展,提供更多的能力 - * - * 为什么继承 JoinBaseMapper 接口?支持 MyBatis Plus 多表 Join 的能力。 + *

+ * 为什么继承 MPJBaseMapper 接口?支持 MyBatis Plus 多表 Join 的能力。 */ -public interface BaseMapperX extends JoinBaseMapper { +public interface BaseMapperX extends MPJBaseMapper { default PageResult selectPage(PageParam pageParam, @Param("ew") Wrapper queryWrapper) { // MyBatis Plus 查询 diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java index 7ff1c4a11..316c4d52f 100644 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java +++ b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java @@ -5,8 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import icu.mhb.mybatisplus.plugln.interceptor.JoinInterceptor; -import icu.mhb.mybatisplus.plugln.interceptor.JoinInterceptorConfig; +import com.github.yulichang.autoconfigure.MybatisPlusJoinAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -36,9 +35,7 @@ public class BaseDbUnitTest { // MyBatis 配置类 YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - // TODO @升平:看看有没可能去掉下面两个类 - JoinInterceptor.class, // MyBatis 的Join配置类 - JoinInterceptorConfig.class, // MyBatis 的Join配置类 + MybatisPlusJoinAutoConfiguration.class, // MyBatis 的Join配置类 }) public static class Application { } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java index 2ca77ff37..ff8012938 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java @@ -10,8 +10,6 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; -import icu.mhb.mybatisplus.plugln.annotations.JoinField; -import icu.mhb.mybatisplus.plugln.constant.RelevancyType; import lombok.*; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -100,9 +98,6 @@ public class AdminUserDO extends TenantBaseDO { /** * 用户所属部门 */ - @JoinField(masterModelClass = AdminUserDO.class, masterModelField = "deptId", - sunModelClass = DeptDO.class, sunModelField = "id", - relevancyType = RelevancyType.ONT_TO_ONE, sunAlias = "d") @TableField(exist = false, typeHandler = FastjsonTypeHandler.class) private DeptDO dept; diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java index 43edc3b59..4ba5645f9 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java @@ -24,7 +24,7 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService; import cn.iocoder.yudao.module.system.service.dept.PostService; import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import icu.mhb.mybatisplus.plugln.extend.Joins; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.junit.jupiter.api.Test; import org.mockito.stubbing.Answer; import org.springframework.boot.test.mock.mockito.MockBean; @@ -776,7 +776,6 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { @Test public void testSelectUserIncludeDept_success() { - // 需设置 application-unit-test.yaml 文件中 spring.main.lazy-initialization: false // 准备部门数据 DeptDO dept = new DeptDO(); @@ -795,13 +794,13 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { // 调用 Long userId = userService.createUser(reqVO); - // 断言 - AdminUserDO user = Joins.of(AdminUserDO.class) + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(AdminUserDO.class) + .selectAll(AdminUserDO.class) + .selectAssociation(DeptDO.class, AdminUserDO::getDept) .leftJoin(DeptDO.class, DeptDO::getId, AdminUserDO::getDeptId) - .oneToOneSelect(AdminUserDO::getDept, DeptDO.class) - .end() - .eq(AdminUserDO::getId, userId) - .joinGetOne(AdminUserDO.class); + .eq(AdminUserDO::getId, userId); + AdminUserDO user = userMapper.selectJoinOne(AdminUserDO.class, wrapper); + System.out.println("=========>" + user); }