Skip to content

Commit 7c4ca6f

Browse files
committed
Adapt to goframe v2.3.2
1 parent b410f0c commit 7c4ca6f

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

adapter.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/casbin/casbin/v2/model"
1111
"github.com/casbin/casbin/v2/persist"
12+
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
1213
"github.com/gogf/gf/v2/database/gdb"
1314
)
1415

@@ -255,7 +256,7 @@ func (a *adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules []
255256
return
256257
}
257258

258-
err = a.db.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
259+
err = a.db.Transaction(context.TODO(), func(ctx context.Context, tx gdb.TX) error {
259260
for i := 0; i < int(math.Min(float64(len(oldRules)), float64(len(newRules)))); i++ {
260261
if _, err = tx.Model(a.table).Update(a.buildPolicyRule(ptype, newRules[i]), a.buildPolicyRule(ptype, oldRules[i])); err != nil {
261262
return err
@@ -268,7 +269,7 @@ func (a *adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules []
268269
return
269270
}
270271

271-
// 加载策略规则
272+
// load a policy rule
272273
func (a *adapter) loadPolicyRule(rule policyRule, model model.Model) {
273274
ruleText := rule.PType
274275

@@ -299,7 +300,7 @@ func (a *adapter) loadPolicyRule(rule policyRule, model model.Model) {
299300
persist.LoadPolicyLine(ruleText, model)
300301
}
301302

302-
// 构建策略规则
303+
// build a policy rule.
303304
func (a *adapter) buildPolicyRule(ptype string, data []string) policyRule {
304305
rule := policyRule{PType: ptype}
305306

go.mod

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
11
module github.com/dobyte/gf-casbin
22

3-
go 1.16
3+
go 1.17
44

55
require (
66
github.com/casbin/casbin/v2 v2.41.0
7-
github.com/gogf/gf/v2 v2.0.0
7+
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.3.2
8+
github.com/gogf/gf/v2 v2.3.2
9+
)
10+
11+
require (
12+
github.com/BurntSushi/toml v1.1.0 // indirect
13+
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
14+
github.com/clbanning/mxj/v2 v2.5.5 // indirect
15+
github.com/fatih/color v1.13.0 // indirect
16+
github.com/fsnotify/fsnotify v1.5.4 // indirect
17+
github.com/go-logr/logr v1.2.3 // indirect
18+
github.com/go-logr/stdr v1.2.2 // indirect
19+
github.com/go-sql-driver/mysql v1.6.0 // indirect
20+
github.com/gorilla/websocket v1.5.0 // indirect
21+
github.com/grokify/html-strip-tags-go v0.0.1 // indirect
22+
github.com/magiconair/properties v1.8.6 // indirect
23+
github.com/mattn/go-colorable v0.1.9 // indirect
24+
github.com/mattn/go-isatty v0.0.14 // indirect
25+
github.com/mattn/go-runewidth v0.0.9 // indirect
26+
github.com/olekukonko/tablewriter v0.0.5 // indirect
27+
go.opentelemetry.io/otel v1.7.0 // indirect
28+
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
29+
go.opentelemetry.io/otel/trace v1.7.0 // indirect
30+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
31+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
32+
golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 // indirect
33+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
834
)

0 commit comments

Comments
 (0)