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

34 lines
737 B
Go
Raw Normal View History

2024-06-12 13:46:14 +08:00
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),
}
}
type Model struct {
MarketLogs genModel.ServerMiddleMarketLogsModel
ZLTXLogs genModel.ServerMiddleZltxLogsModel
}