transfer_middleware/cmd/rpc/internal/queue/mq/mqSvc/serviceContext.go

50 lines
1.6 KiB
Go

package mqSvc
import (
"github.com/zeromicro/go-zero/core/stores/sqlx"
"trasfer_middleware/cmd/rpc/internal/config"
"trasfer_middleware/genModel"
)
type ServiceContext struct {
Config config.Config
DbWrite *Model
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
DbWrite: DbModel(c.DB.Master.DataSource, c),
}
}
func DbModel(datasource string, c config.Config) *Model {
sqlConn := sqlx.NewMysql(datasource)
return &Model{
NewMarketLogs: genModel.NewServerMiddleNewMarketLogsModel(sqlConn),
MarketLogs: genModel.NewServerMiddleMarketLogsModel(sqlConn),
ZLTXLogs: genModel.NewServerMiddleZltxLogsModel(sqlConn),
RSLogs: genModel.NewServerMiddleRsLogsModel(sqlConn),
PhysicalLogs: genModel.NewServerMiddlePhysicalLogsModel(sqlConn),
OrderRs: genModel.NewServerOrderRsModel(sqlConn),
OrderMarket: genModel.NewServerOrderMarketModel(sqlConn),
OrderZLTX: genModel.NewServerOrderZltxModel(sqlConn),
OrderNewMarket: genModel.NewServerOrderNewMarketModel(sqlConn),
OrderPhysical: genModel.NewServerOrderPhysicalModel(sqlConn),
}
}
type Model struct {
NewMarketLogs genModel.ServerMiddleNewMarketLogsModel
MarketLogs genModel.ServerMiddleMarketLogsModel
ZLTXLogs genModel.ServerMiddleZltxLogsModel
RSLogs genModel.ServerMiddleRsLogsModel
PhysicalLogs genModel.ServerMiddlePhysicalLogsModel
OrderRs genModel.ServerOrderRsModel
OrderMarket genModel.ServerOrderMarketModel
OrderZLTX genModel.ServerOrderZltxModel
OrderNewMarket genModel.ServerOrderNewMarketModel
OrderPhysical genModel.ServerOrderPhysicalModel
}