File tree Expand file tree Collapse file tree 5 files changed +32
-31
lines changed Expand file tree Collapse file tree 5 files changed +32
-31
lines changed Original file line number Diff line number Diff line change @@ -15,20 +15,17 @@ v0.1.0已添加此特性 :返回总记录数
15
15
### 1、使用pagehelper的Factory生成SessionManager
16
16
17
17
``` cassandraql
18
- pFac := pagehelper.New(&factory.DefaultFactory{
19
- Host: "localhost",
20
- Port: 3306,
21
- DBName: "test",
22
- Username: "root",
23
- Password: "123",
24
- Charset: "utf8",
25
-
26
- MaxConn: 1000,
27
- MaxIdleConn: 500,
28
-
29
- Log: logging.DefaultLogf,
30
- })
31
- pFac.InitDB()
18
+ pFac := pagehelper.New(gobatis.NewFactory(
19
+ gobatis.SetMaxConn(100),
20
+ gobatis.SetMaxIdleConn(50),
21
+ gobatis.SetDataSource(&datasource.MysqlDataSource{
22
+ Host: "localhost",
23
+ Port: 3306,
24
+ DBName: "test",
25
+ Username: "root",
26
+ Password: "123",
27
+ Charset: "utf8",
28
+ })))
32
29
sessMgr := gobatis.NewSessionManager(pFac)
33
30
```
34
31
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ module github.com/xfali/pagehelper
2
2
3
3
go 1.12
4
4
5
- require github.com/xfali/gobatis v0.0.4
5
+ require github.com/xfali/gobatis v0.0.5
Original file line number Diff line number Diff line change 1
1
github.com/go-sql-driver/mysql v1.4.1 /go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w =
2
+ github.com/mattn/go-sqlite3 v1.10.0 /go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc =
2
3
github.com/xfali/gobatis v0.0.4 h1:rBR8m18xMQAL58jDIr+i9zj8RYC+Mfa9rOw4ZB3shf0 =
3
4
github.com/xfali/gobatis v0.0.4 /go.mod h1:hXP3PcXMSYpYFHQejG04qQjSQJtrt8jWpslftkUMBrg =
5
+ github.com/xfali/gobatis v0.0.5 h1:JFpkn0Gihxocc3ZXqKRv4p5q1JiIeRanL0rTdZRZX0Q =
6
+ github.com/xfali/gobatis v0.0.5 /go.mod h1:nAml9g3T+vn1qDF5nLzSQM9t4l9Fu56GYQ33bYp5Mok =
Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ func (f *Factory) InitDB() error {
93
93
return f .fac .InitDB ()
94
94
}
95
95
96
+ func (f * Factory ) Close () error {
97
+ return f .fac .Close ()
98
+ }
99
+
96
100
func (f * Factory ) CreateTransaction () transaction.Transaction {
97
101
return f .fac .CreateTransaction ()
98
102
}
Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ package pagehelper
11
11
import (
12
12
"context"
13
13
"github.com/xfali/gobatis"
14
- "github.com/xfali/gobatis/factory"
15
- "github.com/xfali/gobatis/logging"
14
+ "github.com/xfali/gobatis/datasource"
16
15
"strings"
17
16
"testing"
18
17
"time"
@@ -99,20 +98,18 @@ func TestPageHelper(t *testing.T) {
99
98
}
100
99
101
100
func TestPageHelper2 (t * testing.T ) {
102
- fac := factory.DefaultFactory {
103
- Host : "localhost" ,
104
- Port : 3306 ,
105
- DBName : "test" ,
106
- Username : "root" ,
107
- Password : "123" ,
108
- Charset : "utf8" ,
109
-
110
- MaxConn : 1000 ,
111
- MaxIdleConn : 500 ,
112
-
113
- Log : logging .DefaultLogf ,
114
- }
115
- sessMgr := gobatis .NewSessionManager (New (& fac ))
101
+ pFac := New (gobatis .NewFactory (
102
+ gobatis .SetMaxConn (100 ),
103
+ gobatis .SetMaxIdleConn (50 ),
104
+ gobatis .SetDataSource (& datasource.MysqlDataSource {
105
+ Host : "localhost" ,
106
+ Port : 3306 ,
107
+ DBName : "test" ,
108
+ Username : "root" ,
109
+ Password : "123" ,
110
+ Charset : "utf8" ,
111
+ })))
112
+ sessMgr := gobatis .NewSessionManager (pFac )
116
113
session := sessMgr .NewSession ()
117
114
ctx , _ := context .WithTimeout (context .Background (), 2 * time .Second )
118
115
ctx = StartPage (ctx , 1 , 2 )
You can’t perform that action at this time.
0 commit comments