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

36 lines
842 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),
2024-06-18 16:34:14 +08:00
RSLogs: genModel.NewServerMiddleRsLogsModel(sqlConn),
2024-06-12 13:46:14 +08:00
}
}
type Model struct {
MarketLogs genModel.ServerMiddleMarketLogsModel
ZLTXLogs genModel.ServerMiddleZltxLogsModel
2024-06-18 16:34:14 +08:00
RSLogs genModel.ServerMiddleRsLogsModel
2024-06-12 13:46:14 +08:00
}