fusenapi/server/order/internal/svc/servicecontext.go
2023-09-20 15:07:12 +08:00

32 lines
592 B
Go

package svc
import (
"fusenapi/server/order/internal/config"
"fusenapi/initalize"
"fusenapi/model/gmodel"
"gorm.io/gorm"
)
type ServiceContext struct {
Config config.Config
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
Repositories *initalize.Repositories
}
func NewServiceContext(c config.Config) *ServiceContext {
conn := initalize.InitMysql(c.SourceMysql)
return &ServiceContext{
Config: c,
MysqlConn: conn,
AllModels: gmodel.NewAllModels(conn),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: conn,
}),
}
}