37 lines
819 B
Go
37 lines
819 B
Go
package svc
|
|
|
|
import (
|
|
"lone-services/pkg/utils"
|
|
"lone-services/services/sale/internal/config"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ServiceContext struct {
|
|
Config config.Config
|
|
DB *gorm.DB
|
|
Prefix string
|
|
ChoreSvcName string
|
|
UserSvcName string
|
|
}
|
|
|
|
func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext {
|
|
choreSvc := utils.GetConfigString("services.chore")
|
|
if choreSvc == utils.StringEmpty {
|
|
logx.Error("config services.chore empty")
|
|
}
|
|
userSvc := utils.GetConfigString("services.user")
|
|
if userSvc == utils.StringEmpty {
|
|
logx.Error("config services.user empty")
|
|
}
|
|
|
|
return &ServiceContext{
|
|
Config: c,
|
|
DB: db,
|
|
Prefix: utils.GetConfigString("mysql.prefix"),
|
|
ChoreSvcName: choreSvc,
|
|
UserSvcName: userSvc,
|
|
}
|
|
}
|