package svc import ( "context" "gitea.youtukeji.com.cn/xiabin/youtu_grpc/auth_service/internal/config" cli "gitea.youtukeji.com.cn/xiabin/youtu_grpc/auth_service/pkg" redisCache "github.com/silenceper/wechat/v2/cache" ) type ServiceContext struct { Config config.Config Cli cli.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 cli.DWClient switch v.Type { case cli.DouyinClientType: c = cli.NewDouYinApi(v.AppId, v.AppSecret, dwCache) case cli.WechatClientType: c = cli.NewWechatApi(v.AppId, v.AppSecret, dwCache) default: continue } svc.Cli.Set(v.AppId, c) } }