package svc import ( "lone-services/pkg/sms" "lone-services/pkg/utils" "lone-services/services/chore/internal/config" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" ) type ServiceContext struct { Config config.Config DB *gorm.DB ProductSvcName string SaleSvcName string UserSvcName string SMS sms.SMS } func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext { productSvc := utils.GetConfigString("services.product") if productSvc == utils.StringEmpty { logx.Error("config services.product empty") } saleSvc := utils.GetConfigString("services.sale") if saleSvc == utils.StringEmpty { logx.Error("config services.sale empty") } userSvc := utils.GetConfigString("services.user") if userSvc == utils.StringEmpty { logx.Error("config services.user empty") } smsClient, err := config.NewSMS() if err != nil { logx.Errorf("sms init: %v", err) } return &ServiceContext{ Config: c, DB: db, ProductSvcName: productSvc, SaleSvcName: saleSvc, UserSvcName: userSvc, SMS: smsClient, } }