fusenapi/server/order/internal/svc/servicecontext.go

32 lines
592 B
Go
Raw Normal View History

2023-09-20 07:07:12 +00:00
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,
}),
}
}