mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
test
This commit is contained in:
parent
01376dcc0c
commit
fadcad436d
@ -71,7 +71,7 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
@ -89,6 +89,11 @@
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.14.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
|
@ -42,6 +42,7 @@ class CollectionTest {
|
||||
.leftJoin(TableE.class, TableE::getDid, TableD::getId);
|
||||
|
||||
List<TableADTO> dtos = tableAMapper.selectJoinList(TableADTO.class, wrapper);
|
||||
assert dtos.size() == 1;
|
||||
System.out.println(dtos);
|
||||
}
|
||||
}
|
||||
|
@ -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<UserDTO> 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<UserDTO> page = userMapper.selectJoinPage(new Page<>(1, 10), UserDTO.class,
|
||||
MPJWrappers.<UserDO>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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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<TableA> {
|
||||
|
||||
}
|
@ -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<TableB> {
|
||||
|
||||
}
|
@ -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<TableC> {
|
||||
|
||||
}
|
@ -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<TableD> {
|
||||
|
||||
}
|
@ -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<TableE> {
|
||||
|
||||
}
|
@ -18,4 +18,5 @@ mybatis-plus:
|
||||
|
||||
# 打印 mybatis plus join banner
|
||||
mybatis-plus-join:
|
||||
banner: true
|
||||
banner: true
|
||||
sub-table-logic: true
|
Loading…
x
Reference in New Issue
Block a user