package initialize import ( "github.com/flipped-aurora/gin-vue-admin/server/global" wechat "github.com/silenceper/wechat/v2" "github.com/silenceper/wechat/v2/cache" offConfig "github.com/silenceper/wechat/v2/officialaccount/config" "go.uber.org/zap" ) func Wechat() { redisCfg := global.GVA_CONFIG.Redis redisOpts := &cache.RedisOpts{ Host: redisCfg.Addr, Password: redisCfg.Password, Database: redisCfg.DB, MaxActive: 0, MaxIdle: 5, IdleTimeout: 9000, } redisCache := cache.NewRedis(redisOpts) wc := &wechat.Wechat{} wc.SetCache(redisCache) wxCfg := global.GVA_CONFIG.Wxxcx offCfg := &offConfig.Config{ AppID: wxCfg.Wxid, AppSecret: wxCfg.Wxkey, Token: "zk1006", EncodingAESKey: "wNwYix6c48AsPYlJvttcTRbcBivOvncPhBoUOI9YwSH", } global.GVA_LOG.Debug("offCfg=", zap.Any("offCfg", offCfg)) global.GVA_WECHAT = wc.GetOfficialAccount(offCfg) }