|
@@ -0,0 +1,34 @@
|
|
1
|
+import com.github.pagehelper.PageHelper;
|
|
2
|
+import com.mapper.AccountMapper;
|
|
3
|
+import com.mapper.DepartmentMapper;
|
|
4
|
+import com.pojo.entity.AccountRealEntity;
|
|
5
|
+import org.apache.ibatis.io.Resources;
|
|
6
|
+import org.apache.ibatis.session.SqlSession;
|
|
7
|
+import org.apache.ibatis.session.SqlSessionFactory;
|
|
8
|
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
|
9
|
+import org.junit.Before;
|
|
10
|
+import org.junit.Test;
|
|
11
|
+
|
|
12
|
+import java.io.IOException;
|
|
13
|
+import java.io.InputStream;
|
|
14
|
+import java.util.List;
|
|
15
|
+
|
|
16
|
+public class TestMybatisPage {
|
|
17
|
+ SqlSession sqlSession;
|
|
18
|
+ AccountMapper accountMapper;
|
|
19
|
+ @Before
|
|
20
|
+ public void before() throws IOException {
|
|
21
|
+ InputStream resourceAsStream = Resources.getResourceAsStream("mybatisConfig.xml");
|
|
22
|
+ SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsStream);
|
|
23
|
+ sqlSession = build.openSession(true);
|
|
24
|
+ accountMapper = sqlSession.getMapper(AccountMapper.class);
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ @Test
|
|
28
|
+ public void page1() {
|
|
29
|
+ // 查询分页功能 在查询列表之前先开启分页
|
|
30
|
+ PageHelper.startPage(2,2);
|
|
31
|
+ List<AccountRealEntity> byDepId = accountMapper.findByDepId(1);
|
|
32
|
+ byDepId.forEach(System.out::println);
|
|
33
|
+ }
|
|
34
|
+}
|