package svc import ( "context" "gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/auth_service/internal/config" cli2 "gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/auth_service/pkg" redisCache "github.com/silenceper/wechat/v2/cache" ) type ServiceContext struct { Config config.Config Cli cli2.Helper } func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, } } func (svc *ServiceContext) InitClient(c config.Config) { dwCache := redisCache.NewRedis(context.Background(), &redisCache.RedisOpts{Host: c.Redis.Host}) //配置小程序cli(抖音&微信) for _, v := range c.AppData { var c cli2.DWClient switch v.Type { case cli2.DouyinClientType: c = cli2.NewDouYinApi(v.AppId, v.AppSecret, dwCache) case cli2.WechatClientType: c = cli2.NewWechatApi(v.AppId, v.AppSecret, dwCache) default: continue } svc.Cli.Set(v.AppId, c) } }