32 lines
592 B
Go
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,
|
||
|
}),
|
||
|
}
|
||
|
}
|