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

38 lines
794 B
Go
Raw Normal View History

2023-09-20 07:07:12 +00:00
package svc
import (
"fusenapi/server/order/internal/config"
2023-09-28 09:53:41 +00:00
"fusenapi/utils/queue"
2023-09-20 07:07:12 +00:00
"fusenapi/initalize"
"fusenapi/model/gmodel"
"gorm.io/gorm"
)
type ServiceContext struct {
Config config.Config
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
Repositories *initalize.Repositories
2023-09-28 09:53:41 +00:00
DelayQueue *queue.DelayMessage
2023-09-20 07:07:12 +00:00
}
func NewServiceContext(c config.Config) *ServiceContext {
conn := initalize.InitMysql(c.SourceMysql)
2023-10-07 07:42:25 +00:00
// delayQueue := initalize.InitDelayMessage()
2023-09-28 09:53:41 +00:00
repositories := initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
2023-10-07 07:42:25 +00:00
GormDB: conn,
// DelayQueue: delayQueue,
2023-09-28 09:53:41 +00:00
})
2023-09-20 07:07:12 +00:00
return &ServiceContext{
2023-09-28 09:53:41 +00:00
Config: c,
MysqlConn: conn,
AllModels: gmodel.NewAllModels(conn),
Repositories: repositories,
2023-10-07 07:42:25 +00:00
// DelayQueue: delayQueue,
2023-09-20 07:07:12 +00:00
}
}