mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-10 07:42:26 +08:00
rebase release-2.0
This commit is contained in:
30
wechat.go
30
wechat.go
@@ -1,24 +1,20 @@
|
||||
package wechat
|
||||
|
||||
import (
|
||||
"github.com/silenceper/wechat/v2/cache"
|
||||
"github.com/silenceper/wechat/v2/miniprogram"
|
||||
miniConfig "github.com/silenceper/wechat/v2/miniprogram/config"
|
||||
payConfig "github.com/silenceper/wechat/v2/pay/config"
|
||||
|
||||
"github.com/silenceper/wechat/v2/officialaccount"
|
||||
offConfig "github.com/silenceper/wechat/v2/officialaccount/config"
|
||||
"github.com/silenceper/wechat/v2/openplatform"
|
||||
openConfig "github.com/silenceper/wechat/v2/openplatform/config"
|
||||
"github.com/silenceper/wechat/v2/pay"
|
||||
payConfig "github.com/silenceper/wechat/v2/pay/config"
|
||||
)
|
||||
|
||||
// Wechat struct
|
||||
type Wechat struct {
|
||||
}
|
||||
|
||||
// Config for user
|
||||
type Config struct {
|
||||
PayMchID string //支付 - 商户 ID
|
||||
PayNotifyURL string //支付 - 接受微信支付结果通知的接口地址
|
||||
PayKey string //支付 - 商户后台设置的支付 key
|
||||
cache cache.Cache
|
||||
}
|
||||
|
||||
// NewWechat init
|
||||
@@ -26,13 +22,24 @@ func NewWechat() *Wechat {
|
||||
return &Wechat{}
|
||||
}
|
||||
|
||||
//SetCache 设置cache
|
||||
func (wc *Wechat) SetCache(cahce cache.Cache) {
|
||||
wc.cache = cahce
|
||||
}
|
||||
|
||||
//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)
|
||||
}
|
||||
|
||||
@@ -40,3 +47,8 @@ func (wc *Wechat) GetMiniProgram(cfg *miniConfig.Config) *miniprogram.MiniProgra
|
||||
func (wc *Wechat) GetPay(cfg *payConfig.Config) *pay.Pay {
|
||||
return pay.NewPay(cfg)
|
||||
}
|
||||
|
||||
// GetOpenPlatform 获取微信开放平台的实例
|
||||
func (wc *Wechat) GetOpenPlatform(cfg *openConfig.Config) *openplatform.OpenPlatform {
|
||||
return openplatform.NewOpenPlatform(cfg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user