38 lines
794 B
Go
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,
|
|
}
|
|
}
|