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

36 lines
842 B
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),
}
}
type Model struct {
MarketLogs genModel.ServerMiddleMarketLogsModel
ZLTXLogs genModel.ServerMiddleZltxLogsModel
RSLogs genModel.ServerMiddleRsLogsModel
}