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

42 lines
1.1 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{
MarketLogs: genModel.NewServerMiddleMarketLogsModel(sqlConn),
ZLTXLogs: genModel.NewServerMiddleZltxLogsModel(sqlConn),
RSLogs: genModel.NewServerMiddleRsLogsModel(sqlConn),
OrderRs: genModel.NewServerOrderRsModel(sqlConn),
OrderMarket: genModel.NewServerOrderMarketModel(sqlConn),
OrderZLTX: genModel.NewServerOrderZltxModel(sqlConn),
}
}
type Model struct {
MarketLogs genModel.ServerMiddleMarketLogsModel
ZLTXLogs genModel.ServerMiddleZltxLogsModel
RSLogs genModel.ServerMiddleRsLogsModel
OrderRs genModel.ServerOrderRsModel
OrderMarket genModel.ServerOrderMarketModel
OrderZLTX genModel.ServerOrderZltxModel
}