mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
test: 测试分页查询。
This commit is contained in:
parent
dc3cf163ff
commit
d5dbd80b20
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.mybatisflex.test.mapper;
|
package com.mybatisflex.test.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.test.model.UserInfo;
|
import com.mybatisflex.test.model.UserInfo;
|
||||||
import com.mybatisflex.test.model.UserVO;
|
import com.mybatisflex.test.model.UserVO;
|
||||||
@ -39,6 +40,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
|
|||||||
* @since 2023-06-07
|
* @since 2023-06-07
|
||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
|
@SuppressWarnings("all")
|
||||||
class UserMapperTest {
|
class UserMapperTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -114,4 +116,21 @@ class UserMapperTest {
|
|||||||
userInfos.forEach(System.err::println);
|
userInfos.forEach(System.err::println);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testPage() {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.select(USER.USER_ID, USER.USER_NAME, ROLE.ALL_COLUMNS)
|
||||||
|
.from(USER.as("u"))
|
||||||
|
.leftJoin(USER_ROLE).as("ur").on(USER_ROLE.USER_ID.eq(USER.USER_ID))
|
||||||
|
.leftJoin(ROLE).as("r").on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID));
|
||||||
|
System.err.println(queryWrapper.toSQL());
|
||||||
|
Page<UserVO> page;
|
||||||
|
int pageNumber = 0;
|
||||||
|
do {
|
||||||
|
page = Page.of(++pageNumber, 1);
|
||||||
|
page = userMapper.paginateAs(page, queryWrapper, UserVO.class);
|
||||||
|
System.err.println(page);
|
||||||
|
} while (page.hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user