fusenapi/server/order/internal/svc/servicecontext.go
2023-10-07 15:42:25 +08:00

38 lines
794 B
Go

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