From f4df72c74785c587dfe7248d2299098825c7dc7d Mon Sep 17 00:00:00 2001 From: bjdys Date: Tue, 24 Aug 2021 09:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AD=97=E6=AE=B5=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E5=8D=87=E7=BA=A7=20mybatis=20plus=20->=203.4.3.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MAPPING.md | 37 +++++++++++++++++++++++-------------- pom.xml | 2 +- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/MAPPING.md b/MAPPING.md index 01adc3d..7517f9c 100644 --- a/MAPPING.md +++ b/MAPPING.md @@ -1,6 +1,6 @@ # mybatis-plus-join -* 本页功能只能在1.2.0测试版中使用,最新版本 1.2.0.Beta3 +* 本页功能只能在1.2.0测试版中使用,最新版本 1.2.0.Beta5 * 点个Star支持一下吧 :) @@ -15,12 +15,12 @@ QQ群:1022221898 com.github.yulichang mybatis-plus-join - 1.2.0.Beta3 + 1.2.0.Beta5 ``` - Gradle ``` - implementation group: 'com.github.yulichang', name: 'mybatis-plus-join', version: '1.2.0.Beta3' + implementation group: 'com.github.yulichang', name: 'mybatis-plus-join', version: '1.2.0.Beta5' ``` 或者clone代码到本地执行 mvn install, 再引入以上依赖
@@ -49,18 +49,32 @@ public class UserDO { /* 其他属性略 */ /** - * 一对一 + * 查询上级 一对一 */ @TableField(exist = false) - @MPJMapping(tag = UserDO.class, thisField = "pid", joinField = "id") + @EntityMapping(thisField = "pid", joinField = "id") private UserDO pUser; /** - * 一对多 + * 查询下级 一对多 */ @TableField(exist = false) - @MPJMapping(tag = UserDO.class, thisField = "id", joinField = "pid") - private List childUserList; + @EntityMapping(thisField = "id", joinField = "pid") + private List childUser; + + /** + * 查询地址 (一对多) + */ + @TableField(exist = false) + @EntityMapping(thisField = "id", joinField = "userId") + private List addressList; + + /** + * 绑定字段 (一对多) + */ + @TableField(exist = false) + @FieldMapping(tag = UserDO.class, thisField = "id", joinField = "pid", select = "id") + private List childIds; } ``` @@ -87,11 +101,10 @@ class MappingTest { * 第一次查询目标UserDO * 第二次根据pid查询上级用户 * 第三次根据自身id查询下级用户 - * */ @Test void test1() { - UserDO deep = userMapper.selectByIdDeep(1); + UserDO deep = userMapper.selectByIdDeep(2); System.out.println(deep); } @@ -103,7 +116,6 @@ class MappingTest { * 第一次查询目标UserDO集合 * 第二次根据pid查询上级用户(不会一条记录一条记录的去查询,对pid进行汇总,用in语句一次性查出来,然后进行匹配) * 第三次根据自身id查询下级用户(不会一条记录一条记录的去查询,对id进行汇总,用in语句一次性查出来,然后进行匹配) - * */ @Test void test2() { @@ -122,9 +134,6 @@ class MappingTest { page.getRecords().forEach(System.out::println); } - -} - ``` MPJMapping 说明: diff --git a/pom.xml b/pom.xml index d342399..bc8def3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.yulichang mybatis-plus-join - 1.2.0.Beta4 + 1.2.0.Beta5 mybatis-plus-join An enhanced toolkit of Mybatis-Plus to simplify development. https://github.com/yulichang/mybatis-plus-join