33 lines
658 B
Go
33 lines
658 B
Go
package svc
|
|
|
|
import (
|
|
"fusenapi/server/info/internal/config"
|
|
"fusenapi/shared"
|
|
|
|
"fusenapi/initalize"
|
|
"fusenapi/model/gmodel"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ServiceContext struct {
|
|
Config config.Config
|
|
|
|
SharedState *shared.SharedState
|
|
MysqlConn *gorm.DB
|
|
AllModels *gmodel.AllModelsGen
|
|
RabbitMq *initalize.RabbitMqHandle
|
|
}
|
|
|
|
func NewServiceContext(c config.Config) *ServiceContext {
|
|
conn := initalize.InitMysql(c.SourceMysql)
|
|
|
|
return &ServiceContext{
|
|
Config: c,
|
|
MysqlConn: conn,
|
|
SharedState: nil,
|
|
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
|
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
|
}
|
|
}
|