-
Notifications
You must be signed in to change notification settings - Fork 171
/
application.go
92 lines (77 loc) · 2.57 KB
/
application.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package miniProgram
import (
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/providers"
"github.com/ArtisanCloud/PowerWeChat/v3/src/miniProgram"
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/material"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/account"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/auth"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/code"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/domain"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/privacy"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/setting"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/tester"
)
type Application struct {
*miniProgram.MiniProgram
Auth *auth.Client
Account *account.Client
Code *code.Client
Domain *domain.Client
Material *material.Client
Privacy *privacy.Client
Setting *setting.Client
Tester *tester.Client
}
func NewApplication(config *miniProgram.UserConfig, extraInfos ...*kernel.ExtraInfo) (*Application, error) {
var extraInfo, _ = kernel.NewExtraInfo()
if len(extraInfos) > 0 {
extraInfo = extraInfos[0]
}
miniProgram, err := miniProgram.NewMiniProgram(config, extraInfo)
if err != nil {
return nil, err
}
app := &Application{
MiniProgram: miniProgram,
}
//-------------- global app config --------------
// global app config
app.Config = providers.RegisterConfigProvider(app)
//-------------- register Aggregate --------------
app.Account, err = account.RegisterProvider(app)
if err != nil {
return nil, err
}
//-------------- register Code --------------
app.Code, err = code.RegisterProvider(app)
if err != nil {
return nil, err
}
//-------------- register Domain --------------
app.Domain, err = domain.RegisterProvider(app)
if err != nil {
return nil, err
}
//-------------- register Material --------------
app.Material, err = material.RegisterProvider(app)
if err != nil {
return nil, err
}
//-------------- register Privacy --------------
app.Privacy, err = privacy.RegisterProvider(app)
if err != nil {
return nil, err
}
//-------------- register Setting --------------
app.Setting, err = setting.RegisterProvider(app)
if err != nil {
return nil, err
}
//-------------- register Tester --------------
app.Tester, err = tester.RegisterProvider(app)
if err != nil {
return nil, err
}
return app, err
}