Search in sources :

Example 1 with EntityListComplexVO

use of diboot.core.test.binder.vo.EntityListComplexVO in project diboot by dibo-software.

the class TestEntityListBinder method testComplexBinder.

/**
 * 验证通过中间表间接关联的绑定
 */
@Test
public void testComplexBinder() {
    // 加载测试数据
    LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.in(User::getId, 1001L, 1002L);
    List<User> userList = userService.getEntityList(queryWrapper);
    // 自动绑定
    List<EntityListComplexVO> voList = Binder.convertAndBindRelations(userList, EntityListComplexVO.class);
    // 验证绑定结果
    Assert.assertTrue(V.notEmpty(voList));
    for (EntityListComplexVO vo : voList) {
        // 验证通过中间表间接关联的绑定
        Assert.assertTrue(V.notEmpty(vo.getRoleList()));
        System.out.println(JSON.stringify(vo));
    }
}
Also used : User(diboot.core.test.binder.entity.User) EntityListComplexVO(diboot.core.test.binder.vo.EntityListComplexVO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 User (diboot.core.test.binder.entity.User)1 EntityListComplexVO (diboot.core.test.binder.vo.EntityListComplexVO)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1