From fadcad436d42b7b877fe3d2455ffc24909339d31 Mon Sep 17 00:00:00 2001 From: yulichang <570810310@qq.com> Date: Thu, 24 Nov 2022 18:52:31 +0800 Subject: [PATCH] test --- mybatis-plus-join-test/pom.xml | 7 +++++- .../test/collection/CollectionTest.java | 1 + .../test/join/LambdaWrapperTest.java | 23 +++++++++++++------ .../yulichang/test/join/entity/TableA.java | 15 ------------ .../yulichang/test/join/entity/TableB.java | 17 -------------- .../yulichang/test/join/entity/TableC.java | 17 -------------- .../yulichang/test/join/entity/TableD.java | 17 -------------- .../yulichang/test/join/entity/TableE.java | 17 -------------- .../test/join/mapper/TableAMapper.java | 11 --------- .../test/join/mapper/TableBMapper.java | 11 --------- .../test/join/mapper/TableCMapper.java | 11 --------- .../test/join/mapper/TableDMapper.java | 11 --------- .../test/join/mapper/TableEMapper.java | 11 --------- .../src/test/resources/application.yml | 3 ++- 14 files changed, 25 insertions(+), 147 deletions(-) delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableA.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableB.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableC.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableD.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableE.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableAMapper.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableBMapper.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableCMapper.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableDMapper.java delete mode 100644 mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableEMapper.java diff --git a/mybatis-plus-join-test/pom.xml b/mybatis-plus-join-test/pom.xml index 396ae49..dcf51c4 100644 --- a/mybatis-plus-join-test/pom.xml +++ b/mybatis-plus-join-test/pom.xml @@ -71,7 +71,7 @@ com.baomidou mybatis-plus-boot-starter - 3.4.2 + 3.5.2 com.github.yulichang @@ -89,6 +89,11 @@ jackson-databind 2.14.0 + + com.baomidou + mybatis-plus-boot-starter + 3.5.2 + org.springframework spring-jdbc diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/collection/CollectionTest.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/collection/CollectionTest.java index 7487c66..1c16508 100644 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/collection/CollectionTest.java +++ b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/collection/CollectionTest.java @@ -42,6 +42,7 @@ class CollectionTest { .leftJoin(TableE.class, TableE::getDid, TableD::getId); List dtos = tableAMapper.selectJoinList(TableADTO.class, wrapper); + assert dtos.size() == 1; System.out.println(dtos); } } diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/LambdaWrapperTest.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/LambdaWrapperTest.java index 7dae67e..847869b 100644 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/LambdaWrapperTest.java +++ b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/LambdaWrapperTest.java @@ -40,8 +40,14 @@ class LambdaWrapperTest { .association(AreaDO.class, AddressDTO::getArea)) .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId) .leftJoin(AreaDO.class, AreaDO::getId, AddressDO::getAreaId) - .orderByDesc(UserDO::getId); + .orderByDesc(UserDO::getId) + .last("unfdjknsnnjkfd"); List list = userMapper.selectJoinList(UserDTO.class, wrapper); + String s = wrapper.getSqlSegment(); + System.out.println(s); + if (list.size() != 1) { + throw new RuntimeException(); + } list.forEach(System.out::println); } @@ -57,7 +63,8 @@ class LambdaWrapperTest { .select(AddressDO::getAddress) .select(AreaDO::getProvince) .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId) - .leftJoin(AreaDO.class, AreaDO::getId, AddressDO::getAreaId)); + .leftJoin(AreaDO.class, AreaDO::getId, AddressDO::getAreaId) + .last("unfdjknsnnjkfd")); iPage.getRecords().forEach(System.out::println); } @@ -78,7 +85,8 @@ class LambdaWrapperTest { .and(i -> i.eq(UserDO::getHeadImg, "er") .or() .eq(AddressDO::getUserId, 1)) - .eq(UserDO::getId, 1)); + .eq(UserDO::getId, 1) + .last("ljfnkegrwbgejkwbenf")); page.getRecords().forEach(System.out::println); } @@ -91,7 +99,7 @@ class LambdaWrapperTest { .selectSum(UserDO::getId) .selectMax(UserDO::getId, UserDTO::getHeadImg) .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId) - .eq(UserDO::getId, 1)); + .last("unfdjknsnnjkfd")); System.out.println(one); } @@ -101,14 +109,15 @@ class LambdaWrapperTest { */ @Test void test6() { - userMapper.selectPage(new Page<>(1, 10),new QueryWrapper<>()); + userMapper.selectPage(new Page<>(1, 10), new QueryWrapper<>()); IPage page = userMapper.selectJoinPage(new Page<>(1, 10), UserDTO.class, MPJWrappers.lambdaJoin() .selectAll(UserDO.class) .select(AddressDO.class, p -> true) .select(AddressDO::getAddress) .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId) - .eq(UserDO::getId, 1)); + .eq(UserDO::getId, 1) + .last("unfdjknsnnjkfd")); page.getRecords().forEach(System.out::println); } @@ -122,7 +131,7 @@ class LambdaWrapperTest { .selectAll(UserDO.class) .select(AddressDO::getAddress) .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId) - .eq(UserDO::getId, 1)); + .last("unfdjknsnnjkfd")); list.forEach(System.out::println); } } diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableA.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableA.java deleted file mode 100644 index e22d6d7..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableA.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.yulichang.test.join.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("table_a") -public class TableA { - - @TableId - private Integer id; - - private String name; -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableB.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableB.java deleted file mode 100644 index 80205b0..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableB.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.yulichang.test.join.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("table_b") -public class TableB { - - @TableId - private Integer id; - - private Integer aid; - - private String name; -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableC.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableC.java deleted file mode 100644 index 1ed74e2..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableC.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.yulichang.test.join.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("table_c") -public class TableC { - - @TableId - private Integer id; - - private Integer bid; - - private String name; -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableD.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableD.java deleted file mode 100644 index c44940c..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableD.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.yulichang.test.join.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("table_d") -public class TableD { - - @TableId - private Integer id; - - private Integer cid; - - private String name; -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableE.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableE.java deleted file mode 100644 index e69a7ef..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/entity/TableE.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.yulichang.test.join.entity; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -@Data -@TableName("table_e") -public class TableE { - - @TableId - private Integer id; - - private Integer did; - - private String name; -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableAMapper.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableAMapper.java deleted file mode 100644 index 91a3bea..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableAMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.yulichang.test.join.mapper; - -import com.github.yulichang.base.MPJBaseMapper; -import com.github.yulichang.test.join.entity.TableA; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -@SuppressWarnings("unused") -public interface TableAMapper extends MPJBaseMapper { - -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableBMapper.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableBMapper.java deleted file mode 100644 index a3a2173..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableBMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.yulichang.test.join.mapper; - -import com.github.yulichang.base.MPJBaseMapper; -import com.github.yulichang.test.join.entity.TableB; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -@SuppressWarnings("unused") -public interface TableBMapper extends MPJBaseMapper { - -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableCMapper.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableCMapper.java deleted file mode 100644 index b74a614..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableCMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.yulichang.test.join.mapper; - -import com.github.yulichang.base.MPJBaseMapper; -import com.github.yulichang.test.join.entity.TableC; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -@SuppressWarnings("unused") -public interface TableCMapper extends MPJBaseMapper { - -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableDMapper.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableDMapper.java deleted file mode 100644 index 2bd16d6..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableDMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.yulichang.test.join.mapper; - -import com.github.yulichang.base.MPJBaseMapper; -import com.github.yulichang.test.join.entity.TableD; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -@SuppressWarnings("unused") -public interface TableDMapper extends MPJBaseMapper { - -} diff --git a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableEMapper.java b/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableEMapper.java deleted file mode 100644 index 2f70960..0000000 --- a/mybatis-plus-join-test/src/test/java/com/github/yulichang/test/join/mapper/TableEMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.yulichang.test.join.mapper; - -import com.github.yulichang.base.MPJBaseMapper; -import com.github.yulichang.test.join.entity.TableE; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -@SuppressWarnings("unused") -public interface TableEMapper extends MPJBaseMapper { - -} diff --git a/mybatis-plus-join-test/src/test/resources/application.yml b/mybatis-plus-join-test/src/test/resources/application.yml index b0ad69e..21a04ba 100644 --- a/mybatis-plus-join-test/src/test/resources/application.yml +++ b/mybatis-plus-join-test/src/test/resources/application.yml @@ -18,4 +18,5 @@ mybatis-plus: # 打印 mybatis plus join banner mybatis-plus-join: - banner: true \ No newline at end of file + banner: true + sub-table-logic: true \ No newline at end of file