Skip to content

Commit 2dbd465

Browse files
committed
升级适配gobatis v0.0.5+
1 parent ae24f66 commit 2dbd465

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,17 @@ v0.1.0已添加此特性 :返回总记录数
1515
### 1、使用pagehelper的Factory生成SessionManager
1616

1717
```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+
})))
3229
sessMgr := gobatis.NewSessionManager(pFac)
3330
```
3431

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/xfali/pagehelper
22

33
go 1.12
44

5-
require github.com/xfali/gobatis v0.0.4
5+
require github.com/xfali/gobatis v0.0.5

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
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=
23
github.com/xfali/gobatis v0.0.4 h1:rBR8m18xMQAL58jDIr+i9zj8RYC+Mfa9rOw4ZB3shf0=
34
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=

orm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ func (f *Factory) InitDB() error {
9393
return f.fac.InitDB()
9494
}
9595

96+
func (f *Factory) Close() error {
97+
return f.fac.Close()
98+
}
99+
96100
func (f *Factory) CreateTransaction() transaction.Transaction {
97101
return f.fac.CreateTransaction()
98102
}

pagehelper_test.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ package pagehelper
1111
import (
1212
"context"
1313
"github.com/xfali/gobatis"
14-
"github.com/xfali/gobatis/factory"
15-
"github.com/xfali/gobatis/logging"
14+
"github.com/xfali/gobatis/datasource"
1615
"strings"
1716
"testing"
1817
"time"
@@ -99,20 +98,18 @@ func TestPageHelper(t *testing.T) {
9998
}
10099

101100
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)
116113
session := sessMgr.NewSession()
117114
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
118115
ctx = StartPage(ctx, 1, 2)

0 commit comments

Comments
 (0)