forked from glennliao/apijson-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall.go
More file actions
38 lines (29 loc) · 1.11 KB
/
all.go
File metadata and controls
38 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package goframe
import (
"context"
"github.com/glennliao/apijson-go/action"
"github.com/glennliao/apijson-go/config"
gfConfig "github.com/glennliao/apijson-go/drivers/goframe/config"
gfExecutor "github.com/glennliao/apijson-go/drivers/goframe/executor"
"github.com/glennliao/apijson-go/query"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
func init() {
config.RegAccessListProvider(gfConfig.ProviderName, gfConfig.AccessListDBProvider)
config.RegRequestListProvider(gfConfig.ProviderName, gfConfig.RequestListProvider)
config.RegDbMetaProvider(gfConfig.ProviderName, gfConfig.DbMetaProvider)
query.RegExecutor("default", gfExecutor.New)
action.RegExecutor("default", &gfExecutor.ActionExecutor{
DbResolver: func(ctx context.Context) gdb.DB {
return g.DB()
},
})
action.RegTransactionResolver(func(ctx context.Context, req *action.Action) action.TransactionHandler {
return func(ctx context.Context, action func(ctx context.Context) error) error {
return g.DB().Ctx(ctx).Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
return action(ctx)
})
}
})
}