package svc import ( "lone-services/pkg/utils" "lone-services/services/user/internal/config" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" ) type ServiceContext struct { Config config.Config DB *gorm.DB Prefix string JWT *config.JWTAuth SaleSvcName string ChoreSvcName string AnalysisSvcName string StoreSvcName string } func NewServiceContext(c config.Config, db *gorm.DB, jwtAuth *config.JWTAuth) *ServiceContext { saleSvc := utils.GetConfigString("services.sale") if saleSvc == utils.StringEmpty { logx.Error("config services.sale empty") } choreSvc := utils.GetConfigString("services.chore") if choreSvc == utils.StringEmpty { logx.Error("config services.chore empty") } analysisSvc := utils.GetConfigString("services.analysis") if analysisSvc == utils.StringEmpty { logx.Error("config services.analysis empty") } storeSvc := utils.GetConfigString("services.store") if storeSvc == utils.StringEmpty { logx.Error("config services.store empty") } return &ServiceContext{ Config: c, DB: db, Prefix: utils.GetConfigString("mysql.prefix"), JWT: jwtAuth, SaleSvcName: saleSvc, ChoreSvcName: choreSvc, AnalysisSvcName: analysisSvc, StoreSvcName: storeSvc, } }