-
Notifications
You must be signed in to change notification settings - Fork 0
/
wechat.go
57 lines (48 loc) · 1.45 KB
/
wechat.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
package wechat
import (
"github.com/36625090/wechat/cache"
"github.com/36625090/wechat/miniprogram"
miniConfig "github.com/36625090/wechat/miniprogram/config"
"github.com/36625090/wechat/officialaccount"
offConfig "github.com/36625090/wechat/officialaccount/config"
"github.com/36625090/wechat/openplatform"
openConfig "github.com/36625090/wechat/openplatform/config"
"github.com/36625090/wechat/work"
workConfig "github.com/36625090/wechat/work/config"
)
func init() {
}
// Wechat WeChat struct
type Wechat struct {
cache cache.Cache
}
// NewWechat init
func NewWechat() *Wechat {
return &Wechat{}
}
// SetCache 设置cache
func (wc *Wechat) SetCache(cache cache.Cache) {
wc.cache = cache
}
// GetOfficialAccount 获取微信公众号实例
func (wc *Wechat) GetOfficialAccount(cfg *offConfig.Config) *officialaccount.OfficialAccount {
if cfg.Cache == nil {
cfg.Cache = wc.cache
}
return officialaccount.NewOfficialAccount(cfg)
}
// GetMiniProgram 获取小程序的实例
func (wc *Wechat) GetMiniProgram(cfg *miniConfig.Config) *miniprogram.MiniProgram {
if cfg.Cache == nil {
cfg.Cache = wc.cache
}
return miniprogram.NewMiniProgram(cfg)
}
// GetOpenPlatform 获取微信开放平台的实例
func (wc *Wechat) GetOpenPlatform(cfg *openConfig.Config) *openplatform.OpenPlatform {
return openplatform.NewOpenPlatform(cfg)
}
// GetWork 获取企业微信的实例
func (wc *Wechat) GetWork(cfg *workConfig.Config) *work.Work {
return work.NewWork(cfg)
}