-
Notifications
You must be signed in to change notification settings - Fork 0
/
wechat.go
36 lines (30 loc) · 827 Bytes
/
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
package wechat
import (
"github.com/duffiye/wechat/cache"
"github.com/duffiye/wechat/miniprogram"
miniConfig "github.com/duffiye/wechat/miniprogram/config"
"github.com/duffiye/wechat/wechatpay"
wechatPayConfig "github.com/duffiye/wechat/wechatpay/config"
)
// Wechat wc
type Wechat struct {
cache cache.Cache
}
// NewWechat Create Wechat
func NewWechat() *Wechat {
return &Wechat{}
}
//SetCache 设置cache
func (wc *Wechat) SetCache(cahce cache.Cache) {
wc.cache = cahce
}
// GetMiniProgram 获取小程序的实例
func (wc *Wechat) GetMiniProgram(cfg *miniConfig.Config) *miniprogram.MiniProgram {
if cfg.Cache == nil {
cfg.Cache = wc.cache
}
return miniprogram.NewMiniProgram(cfg)
}
func (wc *Wechat) GetWechatPay(cfg *wechatPayConfig.Config) *wechatpay.WechatPay {
return wechatpay.NewWechatPay(cfg)
}